diff options
-rw-r--r-- | src/gns/gnunet-service-gns.c | 24 | ||||
-rw-r--r-- | src/gns/namestore_stub_api.c | 28 |
2 files changed, 34 insertions, 18 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 99e092b26..e4e28c14b 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -1072,6 +1072,10 @@ update_zone_dht_next(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1072 | GNUNET_NAMESTORE_zone_iterator_next(namestore_iter); | 1072 | GNUNET_NAMESTORE_zone_iterator_next(namestore_iter); |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | /* prototype */ | ||
1076 | static void | ||
1077 | update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
1078 | |||
1075 | /** | 1079 | /** |
1076 | * Function used to put all records successively into the DHT. | 1080 | * Function used to put all records successively into the DHT. |
1077 | * FIXME bug here | 1081 | * FIXME bug here |
@@ -1100,7 +1104,9 @@ put_gns_record(void *cls, | |||
1100 | 1104 | ||
1101 | if (NULL == name) //We're done | 1105 | if (NULL == name) //We're done |
1102 | { | 1106 | { |
1107 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Zone iteration finished\n"); | ||
1103 | GNUNET_NAMESTORE_zone_iteration_stop (namestore_iter); | 1108 | GNUNET_NAMESTORE_zone_iteration_stop (namestore_iter); |
1109 | GNUNET_SCHEDULER_add_now (&update_zone_dht_start, NULL); | ||
1104 | return; | 1110 | return; |
1105 | } | 1111 | } |
1106 | /** | 1112 | /** |
@@ -1141,8 +1147,18 @@ static void | |||
1141 | update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1147 | update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
1142 | { | 1148 | { |
1143 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Update zone!\n"); | 1149 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Update zone!\n"); |
1144 | dht_update_interval = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, | 1150 | if (0 == num_public_records) |
1151 | { | ||
1152 | dht_update_interval = GNUNET_TIME_relative_multiply( | ||
1153 | GNUNET_TIME_UNIT_SECONDS, | ||
1154 | 1); | ||
1155 | } | ||
1156 | else | ||
1157 | { | ||
1158 | dht_update_interval = GNUNET_TIME_relative_multiply( | ||
1159 | GNUNET_TIME_UNIT_SECONDS, | ||
1145 | (3600/num_public_records)); | 1160 | (3600/num_public_records)); |
1161 | } | ||
1146 | num_public_records = 0; //start counting again | 1162 | num_public_records = 0; //start counting again |
1147 | namestore_iter = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle, | 1163 | namestore_iter = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle, |
1148 | &zone_hash, | 1164 | &zone_hash, |
@@ -1221,10 +1237,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1221 | * We have roughly an hour for all records; | 1237 | * We have roughly an hour for all records; |
1222 | */ | 1238 | */ |
1223 | dht_update_interval = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, | 1239 | dht_update_interval = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, |
1224 | 60); //FIXME from cfg | 1240 | 1); //FIXME from cfg |
1225 | //GNUNET_SCHEDULER_add_delayed (dht_update_interval, | 1241 | GNUNET_SCHEDULER_add_now (&update_zone_dht_start, NULL); |
1226 | // &update_zone_dht_start, | ||
1227 | // NULL); | ||
1228 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "GNS Init done!\n"); | 1242 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "GNS Init done!\n"); |
1229 | 1243 | ||
1230 | } | 1244 | } |
diff --git a/src/gns/namestore_stub_api.c b/src/gns/namestore_stub_api.c index e2c9de33e..36db01f8e 100644 --- a/src/gns/namestore_stub_api.c +++ b/src/gns/namestore_stub_api.c | |||
@@ -80,6 +80,7 @@ struct GNUNET_NAMESTORE_ZoneIterator | |||
80 | uint32_t no_flags; | 80 | uint32_t no_flags; |
81 | uint32_t flags; | 81 | uint32_t flags; |
82 | struct GNUNET_NAMESTORE_Handle *h; | 82 | struct GNUNET_NAMESTORE_Handle *h; |
83 | struct GNUNET_NAMESTORE_SimpleRecord *sr; | ||
83 | }; | 84 | }; |
84 | 85 | ||
85 | struct GNUNET_NAMESTORE_SimpleRecord | 86 | struct GNUNET_NAMESTORE_SimpleRecord |
@@ -380,6 +381,7 @@ GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, | |||
380 | h->locked = 1; | 381 | h->locked = 1; |
381 | it = GNUNET_malloc(sizeof(struct GNUNET_NAMESTORE_ZoneIterator)); | 382 | it = GNUNET_malloc(sizeof(struct GNUNET_NAMESTORE_ZoneIterator)); |
382 | it->h = h; | 383 | it->h = h; |
384 | it->sr = h->records_head; | ||
383 | it->proc = proc; | 385 | it->proc = proc; |
384 | it->proc_cls = proc_cls; | 386 | it->proc_cls = proc_cls; |
385 | it->zone = zone; | 387 | it->zone = zone; |
@@ -392,30 +394,30 @@ GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, | |||
392 | void | 394 | void |
393 | GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it) | 395 | GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it) |
394 | { | 396 | { |
395 | struct GNUNET_NAMESTORE_SimpleRecord *sr; | ||
396 | 397 | ||
397 | if (it->h->locked == 0) | 398 | if (it->h->locked == 0) |
398 | return; | 399 | return; |
400 | if (it->sr == NULL) | ||
401 | { | ||
402 | it->proc(it->proc_cls, NULL, GNUNET_TIME_UNIT_ZERO_ABS, | ||
403 | NULL, 0, NULL, NULL); | ||
404 | return; | ||
405 | } | ||
399 | 406 | ||
400 | sr = it->h->records_head; | 407 | if (GNUNET_CRYPTO_hash_cmp(it->sr->zone, it->zone)) |
401 | for (; sr != NULL; sr = sr->next) | ||
402 | { | 408 | { |
403 | if (GNUNET_CRYPTO_hash_cmp(sr->zone, it->zone)) | 409 | //Simply always return all records |
404 | { | 410 | //check flags |
405 | //Simply always return all records | 411 | it->proc(it->proc_cls, it->sr->zone_key, GNUNET_TIME_UNIT_FOREVER_ABS, |
406 | //check flags | 412 | it->sr->name, it->sr->rd_count, it->sr->rd, NULL); |
407 | it->proc(it->proc_cls, sr->zone_key, GNUNET_TIME_UNIT_FOREVER_ABS, //FIXME | ||
408 | sr->name, sr->rd_count, sr->rd, NULL); | ||
409 | } | ||
410 | } | 413 | } |
411 | it->proc(it->proc_cls, NULL, GNUNET_TIME_UNIT_ZERO_ABS, NULL, 0, NULL, NULL); | 414 | it->sr = it->sr->next; |
412 | } | 415 | } |
413 | 416 | ||
414 | void | 417 | void |
415 | GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it) | 418 | GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it) |
416 | { | 419 | { |
417 | it->h->locked = 0; | 420 | //it->h->locked = 0; |
418 | GNUNET_free(it); | ||
419 | } | 421 | } |
420 | 422 | ||
421 | /** | 423 | /** |