From: Martin Schanzenbach Date: Sun, 26 Feb 2012 13:45:30 +0000 (+0000) Subject: -periodic put fix, namestore stub fix X-Git-Tag: initial-import-from-subversion-38251~14645 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=69685227863090eb24ee20d07e8c0f139264c061;p=oweals%2Fgnunet.git -periodic put fix, namestore stub fix --- 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) GNUNET_NAMESTORE_zone_iterator_next(namestore_iter); } +/* prototype */ +static void +update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); + /** * Function used to put all records successively into the DHT. * FIXME bug here @@ -1100,7 +1104,9 @@ put_gns_record(void *cls, if (NULL == name) //We're done { + GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Zone iteration finished\n"); GNUNET_NAMESTORE_zone_iteration_stop (namestore_iter); + GNUNET_SCHEDULER_add_now (&update_zone_dht_start, NULL); return; } /** @@ -1141,8 +1147,18 @@ static void update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Update zone!\n"); - dht_update_interval = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, + if (0 == num_public_records) + { + dht_update_interval = GNUNET_TIME_relative_multiply( + GNUNET_TIME_UNIT_SECONDS, + 1); + } + else + { + dht_update_interval = GNUNET_TIME_relative_multiply( + GNUNET_TIME_UNIT_SECONDS, (3600/num_public_records)); + } num_public_records = 0; //start counting again namestore_iter = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle, &zone_hash, @@ -1221,10 +1237,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, * We have roughly an hour for all records; */ dht_update_interval = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, - 60); //FIXME from cfg - //GNUNET_SCHEDULER_add_delayed (dht_update_interval, - // &update_zone_dht_start, - // NULL); + 1); //FIXME from cfg + GNUNET_SCHEDULER_add_now (&update_zone_dht_start, NULL); GNUNET_log(GNUNET_ERROR_TYPE_INFO, "GNS Init done!\n"); } 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 uint32_t no_flags; uint32_t flags; struct GNUNET_NAMESTORE_Handle *h; + struct GNUNET_NAMESTORE_SimpleRecord *sr; }; struct GNUNET_NAMESTORE_SimpleRecord @@ -380,6 +381,7 @@ GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, h->locked = 1; it = GNUNET_malloc(sizeof(struct GNUNET_NAMESTORE_ZoneIterator)); it->h = h; + it->sr = h->records_head; it->proc = proc; it->proc_cls = proc_cls; it->zone = zone; @@ -392,30 +394,30 @@ GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it) { - struct GNUNET_NAMESTORE_SimpleRecord *sr; if (it->h->locked == 0) return; + if (it->sr == NULL) + { + it->proc(it->proc_cls, NULL, GNUNET_TIME_UNIT_ZERO_ABS, + NULL, 0, NULL, NULL); + return; + } - sr = it->h->records_head; - for (; sr != NULL; sr = sr->next) + if (GNUNET_CRYPTO_hash_cmp(it->sr->zone, it->zone)) { - if (GNUNET_CRYPTO_hash_cmp(sr->zone, it->zone)) - { - //Simply always return all records - //check flags - it->proc(it->proc_cls, sr->zone_key, GNUNET_TIME_UNIT_FOREVER_ABS, //FIXME - sr->name, sr->rd_count, sr->rd, NULL); - } + //Simply always return all records + //check flags + it->proc(it->proc_cls, it->sr->zone_key, GNUNET_TIME_UNIT_FOREVER_ABS, + it->sr->name, it->sr->rd_count, it->sr->rd, NULL); } - it->proc(it->proc_cls, NULL, GNUNET_TIME_UNIT_ZERO_ABS, NULL, 0, NULL, NULL); + it->sr = it->sr->next; } void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it) { - it->h->locked = 0; - GNUNET_free(it); + //it->h->locked = 0; } /**