diff options
-rw-r--r-- | src/namestore/gnunet-namestore.c | 62 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_monitoring.c | 5 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_monitoring_existing.c | 55 | ||||
-rw-r--r-- | src/zonemaster/gnunet-service-zonemaster.c | 16 |
4 files changed, 110 insertions, 28 deletions
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index d329dcb3b..32b1a39d0 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -374,16 +374,12 @@ zone_iteration_error_cb (void *cls) | |||
374 | /** | 374 | /** |
375 | * Process a record that was stored in the namestore. | 375 | * Process a record that was stored in the namestore. |
376 | * | 376 | * |
377 | * @param cls closure | ||
378 | * @param zone_key private key of the zone | ||
379 | * @param rname name that is being mapped (at most 255 characters long) | 377 | * @param rname name that is being mapped (at most 255 characters long) |
380 | * @param rd_len number of entries in @a rd array | 378 | * @param rd_len number of entries in @a rd array |
381 | * @param rd array of records with data to store | 379 | * @param rd array of records with data to store |
382 | */ | 380 | */ |
383 | static void | 381 | static void |
384 | display_record (void *cls, | 382 | display_record (const char *rname, |
385 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | ||
386 | const char *rname, | ||
387 | unsigned int rd_len, | 383 | unsigned int rd_len, |
388 | const struct GNUNET_GNSRECORD_Data *rd) | 384 | const struct GNUNET_GNSRECORD_Data *rd) |
389 | { | 385 | { |
@@ -393,8 +389,6 @@ display_record (void *cls, | |||
393 | struct GNUNET_TIME_Absolute at; | 389 | struct GNUNET_TIME_Absolute at; |
394 | struct GNUNET_TIME_Relative rt; | 390 | struct GNUNET_TIME_Relative rt; |
395 | 391 | ||
396 | (void) cls; | ||
397 | (void) zone_key; | ||
398 | if ( (NULL != name) && | 392 | if ( (NULL != name) && |
399 | (0 != strcmp (name, rname)) ) | 393 | (0 != strcmp (name, rname)) ) |
400 | { | 394 | { |
@@ -442,12 +436,62 @@ display_record (void *cls, | |||
442 | GNUNET_free (s); | 436 | GNUNET_free (s); |
443 | } | 437 | } |
444 | FPRINTF (stdout, "%s", "\n"); | 438 | FPRINTF (stdout, "%s", "\n"); |
439 | } | ||
440 | |||
441 | |||
442 | /** | ||
443 | * Process a record that was stored in the namestore. | ||
444 | * | ||
445 | * @param cls closure | ||
446 | * @param zone_key private key of the zone | ||
447 | * @param rname name that is being mapped (at most 255 characters long) | ||
448 | * @param rd_len number of entries in @a rd array | ||
449 | * @param rd array of records with data to store | ||
450 | */ | ||
451 | static void | ||
452 | display_record_iterator (void *cls, | ||
453 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | ||
454 | const char *rname, | ||
455 | unsigned int rd_len, | ||
456 | const struct GNUNET_GNSRECORD_Data *rd) | ||
457 | { | ||
458 | (void) cls; | ||
459 | (void) zone_key; | ||
460 | display_record (rname, | ||
461 | rd_len, | ||
462 | rd); | ||
445 | GNUNET_NAMESTORE_zone_iterator_next (list_it, | 463 | GNUNET_NAMESTORE_zone_iterator_next (list_it, |
446 | 1); | 464 | 1); |
447 | } | 465 | } |
448 | 466 | ||
449 | 467 | ||
450 | /** | 468 | /** |
469 | * Process a record that was stored in the namestore. | ||
470 | * | ||
471 | * @param cls closure | ||
472 | * @param zone_key private key of the zone | ||
473 | * @param rname name that is being mapped (at most 255 characters long) | ||
474 | * @param rd_len number of entries in @a rd array | ||
475 | * @param rd array of records with data to store | ||
476 | */ | ||
477 | static void | ||
478 | display_record_monitor (void *cls, | ||
479 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | ||
480 | const char *rname, | ||
481 | unsigned int rd_len, | ||
482 | const struct GNUNET_GNSRECORD_Data *rd) | ||
483 | { | ||
484 | (void) cls; | ||
485 | (void) zone_key; | ||
486 | display_record (rname, | ||
487 | rd_len, | ||
488 | rd); | ||
489 | GNUNET_NAMESTORE_zone_monitor_next (zm, | ||
490 | 1); | ||
491 | } | ||
492 | |||
493 | |||
494 | /** | ||
451 | * Function called once we are in sync in monitor mode. | 495 | * Function called once we are in sync in monitor mode. |
452 | * | 496 | * |
453 | * @param cls NULL | 497 | * @param cls NULL |
@@ -956,7 +1000,7 @@ identity_cb (void *cls, | |||
956 | &zone_pkey, | 1000 | &zone_pkey, |
957 | &zone_iteration_error_cb, | 1001 | &zone_iteration_error_cb, |
958 | NULL, | 1002 | NULL, |
959 | &display_record, | 1003 | &display_record_iterator, |
960 | NULL, | 1004 | NULL, |
961 | &zone_iteration_finished, | 1005 | &zone_iteration_finished, |
962 | NULL); | 1006 | NULL); |
@@ -1054,7 +1098,7 @@ identity_cb (void *cls, | |||
1054 | GNUNET_YES, | 1098 | GNUNET_YES, |
1055 | &monitor_error_cb, | 1099 | &monitor_error_cb, |
1056 | NULL, | 1100 | NULL, |
1057 | &display_record, | 1101 | &display_record_monitor, |
1058 | NULL, | 1102 | NULL, |
1059 | &sync_cb, | 1103 | &sync_cb, |
1060 | NULL); | 1104 | NULL); |
diff --git a/src/namestore/test_namestore_api_monitoring.c b/src/namestore/test_namestore_api_monitoring.c index f6d4fe226..cd38b2c80 100644 --- a/src/namestore/test_namestore_api_monitoring.c +++ b/src/namestore/test_namestore_api_monitoring.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2013 GNUnet e.V. | 3 | Copyright (C) 2013, 2018 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -192,7 +192,8 @@ zone_proc (void *cls, | |||
192 | GNUNET_break (0); | 192 | GNUNET_break (0); |
193 | fail = GNUNET_YES; | 193 | fail = GNUNET_YES; |
194 | } | 194 | } |
195 | 195 | GNUNET_NAMESTORE_zone_monitor_next (zm, | |
196 | 1); | ||
196 | if (2 == ++returned_records) | 197 | if (2 == ++returned_records) |
197 | { | 198 | { |
198 | if (endbadly_task != NULL) | 199 | if (endbadly_task != NULL) |
diff --git a/src/namestore/test_namestore_api_monitoring_existing.c b/src/namestore/test_namestore_api_monitoring_existing.c index 17f726eb1..f6a74609e 100644 --- a/src/namestore/test_namestore_api_monitoring_existing.c +++ b/src/namestore/test_namestore_api_monitoring_existing.c | |||
@@ -159,19 +159,24 @@ zone_proc (void *cls, | |||
159 | "Comparing results name %s\n", | 159 | "Comparing results name %s\n", |
160 | name); | 160 | name); |
161 | 161 | ||
162 | if (0 != memcmp (zone_key, privkey, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) | 162 | if (0 != memcmp (zone_key, |
163 | privkey, | ||
164 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) | ||
163 | { | 165 | { |
164 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 166 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
165 | "Monitoring returned wrong zone key\n"); | 167 | "Monitoring returned wrong zone key\n"); |
166 | GNUNET_break (0); | 168 | GNUNET_break (0); |
167 | GNUNET_SCHEDULER_cancel (endbadly_task); | 169 | GNUNET_SCHEDULER_cancel (endbadly_task); |
168 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 170 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, |
171 | NULL); | ||
169 | return; | 172 | return; |
170 | } | 173 | } |
171 | 174 | ||
172 | if (0 == strcmp (name, s_name_1)) | 175 | if (0 == strcmp (name, s_name_1)) |
173 | { | 176 | { |
174 | if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_1)) | 177 | if (GNUNET_YES != |
178 | GNUNET_GNSRECORD_records_cmp (rd, | ||
179 | s_rd_1)) | ||
175 | { | 180 | { |
176 | GNUNET_break (0); | 181 | GNUNET_break (0); |
177 | fail = GNUNET_YES; | 182 | fail = GNUNET_YES; |
@@ -179,7 +184,9 @@ zone_proc (void *cls, | |||
179 | } | 184 | } |
180 | else if (0 == strcmp (name, s_name_2)) | 185 | else if (0 == strcmp (name, s_name_2)) |
181 | { | 186 | { |
182 | if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_2)) | 187 | if (GNUNET_YES != |
188 | GNUNET_GNSRECORD_records_cmp (rd, | ||
189 | s_rd_2)) | ||
183 | { | 190 | { |
184 | GNUNET_break (0); | 191 | GNUNET_break (0); |
185 | fail = GNUNET_YES; | 192 | fail = GNUNET_YES; |
@@ -192,7 +199,8 @@ zone_proc (void *cls, | |||
192 | GNUNET_break (0); | 199 | GNUNET_break (0); |
193 | fail = GNUNET_YES; | 200 | fail = GNUNET_YES; |
194 | } | 201 | } |
195 | 202 | GNUNET_NAMESTORE_zone_monitor_next (zm, | |
203 | 1); | ||
196 | if (2 == ++returned_records) | 204 | if (2 == ++returned_records) |
197 | { | 205 | { |
198 | if (endbadly_task != NULL) | 206 | if (endbadly_task != NULL) |
@@ -201,9 +209,11 @@ zone_proc (void *cls, | |||
201 | endbadly_task = NULL; | 209 | endbadly_task = NULL; |
202 | } | 210 | } |
203 | if (GNUNET_YES == fail) | 211 | if (GNUNET_YES == fail) |
204 | GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 212 | GNUNET_SCHEDULER_add_now (&endbadly, |
213 | NULL); | ||
205 | else | 214 | else |
206 | GNUNET_SCHEDULER_add_now (&end, NULL); | 215 | GNUNET_SCHEDULER_add_now (&end, |
216 | NULL); | ||
207 | } | 217 | } |
208 | } | 218 | } |
209 | 219 | ||
@@ -223,7 +233,9 @@ sync_cb (void *cls) | |||
223 | 233 | ||
224 | 234 | ||
225 | static void | 235 | static void |
226 | put_cont (void *cls, int32_t success, const char *emsg) | 236 | put_cont (void *cls, |
237 | int32_t success, | ||
238 | const char *emsg) | ||
227 | { | 239 | { |
228 | static int c = 0; | 240 | static int c = 0; |
229 | char *label = cls; | 241 | char *label = cls; |
@@ -238,11 +250,15 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
238 | if (success == GNUNET_OK) | 250 | if (success == GNUNET_OK) |
239 | { | 251 | { |
240 | c++; | 252 | c++; |
241 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record %u: `%s'\n", c, label); | 253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
254 | "Created record %u: `%s'\n", | ||
255 | c, | ||
256 | label); | ||
242 | } | 257 | } |
243 | else | 258 | else |
244 | { | 259 | { |
245 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to created records\n"); | 260 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
261 | "Failed to created records\n"); | ||
246 | GNUNET_break (0); | 262 | GNUNET_break (0); |
247 | GNUNET_SCHEDULER_cancel (endbadly_task); | 263 | GNUNET_SCHEDULER_cancel (endbadly_task); |
248 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 264 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); |
@@ -262,9 +278,11 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
262 | NULL); | 278 | NULL); |
263 | if (NULL == zm) | 279 | if (NULL == zm) |
264 | { | 280 | { |
265 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone monitor\n"); | 281 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
282 | "Failed to create zone monitor\n"); | ||
266 | GNUNET_break (0); | 283 | GNUNET_break (0); |
267 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 284 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, |
285 | NULL); | ||
268 | return; | 286 | return; |
269 | } | 287 | } |
270 | } | 288 | } |
@@ -354,14 +372,17 @@ run (void *cls, | |||
354 | GNUNET_assert (NULL != (ns_ops[0] = GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1, | 372 | GNUNET_assert (NULL != (ns_ops[0] = GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1, |
355 | 1, s_rd_1, &put_cont, s_name_1))); | 373 | 1, s_rd_1, &put_cont, s_name_1))); |
356 | 374 | ||
357 | |||
358 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n"); | 375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n"); |
359 | GNUNET_asprintf(&s_name_2, "dummy2"); | 376 | GNUNET_asprintf(&s_name_2, "dummy2"); |
360 | s_rd_2 = create_record(1); | 377 | s_rd_2 = create_record(1); |
361 | GNUNET_assert (NULL != (ns_ops[1] = GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_2, | 378 | GNUNET_assert (NULL != (ns_ops[1] = |
362 | 1, s_rd_2, &put_cont, s_name_2))); | 379 | GNUNET_NAMESTORE_records_store (nsh, |
363 | 380 | privkey, | |
364 | 381 | s_name_2, | |
382 | 1, | ||
383 | s_rd_2, | ||
384 | &put_cont, | ||
385 | s_name_2))); | ||
365 | } | 386 | } |
366 | 387 | ||
367 | 388 | ||
diff --git a/src/zonemaster/gnunet-service-zonemaster.c b/src/zonemaster/gnunet-service-zonemaster.c index 7129cf44f..cbb890589 100644 --- a/src/zonemaster/gnunet-service-zonemaster.c +++ b/src/zonemaster/gnunet-service-zonemaster.c | |||
@@ -60,6 +60,12 @@ | |||
60 | #define DHT_QUEUE_LIMIT 2000 | 60 | #define DHT_QUEUE_LIMIT 2000 |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * How many events may the namestore give us before it has to wait | ||
64 | * for us to keep up? | ||
65 | */ | ||
66 | #define NAMESTORE_QUEUE_LIMIT 50 | ||
67 | |||
68 | /** | ||
63 | * The initial interval in milliseconds btween puts in | 69 | * The initial interval in milliseconds btween puts in |
64 | * a zone iteration | 70 | * a zone iteration |
65 | */ | 71 | */ |
@@ -374,6 +380,8 @@ dht_put_monitor_continuation (void *cls) | |||
374 | { | 380 | { |
375 | struct DhtPutActivity *ma = cls; | 381 | struct DhtPutActivity *ma = cls; |
376 | 382 | ||
383 | GNUNET_NAMESTORE_zone_monitor_next (zmon, | ||
384 | 1); | ||
377 | ma_queue_length--; | 385 | ma_queue_length--; |
378 | GNUNET_CONTAINER_DLL_remove (ma_head, | 386 | GNUNET_CONTAINER_DLL_remove (ma_head, |
379 | ma_tail, | 387 | ma_tail, |
@@ -924,7 +932,11 @@ handle_monitor_event (void *cls, | |||
924 | rd_count, | 932 | rd_count, |
925 | rd_public); | 933 | rd_public); |
926 | if (0 == rd_public_count) | 934 | if (0 == rd_public_count) |
935 | { | ||
936 | GNUNET_NAMESTORE_zone_monitor_next (zmon, | ||
937 | 1); | ||
927 | return; /* nothing to do */ | 938 | return; /* nothing to do */ |
939 | } | ||
928 | num_public_records++; | 940 | num_public_records++; |
929 | ma = GNUNET_new (struct DhtPutActivity); | 941 | ma = GNUNET_new (struct DhtPutActivity); |
930 | ma->start_date = GNUNET_TIME_absolute_get (); | 942 | ma->start_date = GNUNET_TIME_absolute_get (); |
@@ -938,6 +950,8 @@ handle_monitor_event (void *cls, | |||
938 | { | 950 | { |
939 | /* PUT failed, do not remember operation */ | 951 | /* PUT failed, do not remember operation */ |
940 | GNUNET_free (ma); | 952 | GNUNET_free (ma); |
953 | GNUNET_NAMESTORE_zone_monitor_next (zmon, | ||
954 | 1); | ||
941 | return; | 955 | return; |
942 | } | 956 | } |
943 | GNUNET_CONTAINER_DLL_insert_tail (ma_head, | 957 | GNUNET_CONTAINER_DLL_insert_tail (ma_head, |
@@ -1097,6 +1111,8 @@ run (void *cls, | |||
1097 | NULL, | 1111 | NULL, |
1098 | &monitor_sync_event, | 1112 | &monitor_sync_event, |
1099 | NULL); | 1113 | NULL); |
1114 | GNUNET_NAMESTORE_zone_monitor_next (zmon, | ||
1115 | NAMESTORE_QUEUE_LIMIT - 1); | ||
1100 | GNUNET_break (NULL != zmon); | 1116 | GNUNET_break (NULL != zmon); |
1101 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 1117 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1102 | NULL); | 1118 | NULL); |