aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-02-26 13:45:30 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-02-26 13:45:30 +0000
commit69685227863090eb24ee20d07e8c0f139264c061 (patch)
tree161e1af83a597c258dd80b92d2a6e13e3b7fb315 /src
parente6d53f7f11ebfecb182b9be97b9216723362050b (diff)
-periodic put fix, namestore stub fix
Diffstat (limited to 'src')
-rw-r--r--src/gns/gnunet-service-gns.c24
-rw-r--r--src/gns/namestore_stub_api.c28
2 files changed, 34 insertions, 18 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 99e092b266..e4e28c14b9 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 e2c9de33e4..36db01f8ea 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;
}
/**