aboutsummaryrefslogtreecommitdiff
path: root/src/zonemaster
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-04-24 23:28:24 +0200
committerChristian Grothoff <christian@grothoff.org>2018-04-24 23:28:24 +0200
commitbdbb7c684f2c9711989d2543ecc08a95be23e6c4 (patch)
tree28c453ab36c79aa5058ec64f4b42889216098c5a /src/zonemaster
parent72b802f9173bdd0f5d6830c56d7c51c3349073fe (diff)
downloadgnunet-bdbb7c684f2c9711989d2543ecc08a95be23e6c4.tar.gz
gnunet-bdbb7c684f2c9711989d2543ecc08a95be23e6c4.zip
code cleanup, more diagnostics, more statistics
Diffstat (limited to 'src/zonemaster')
-rw-r--r--src/zonemaster/gnunet-service-zonemaster.c44
1 files changed, 34 insertions, 10 deletions
diff --git a/src/zonemaster/gnunet-service-zonemaster.c b/src/zonemaster/gnunet-service-zonemaster.c
index b3a2cb8b3..bf11f7d20 100644
--- a/src/zonemaster/gnunet-service-zonemaster.c
+++ b/src/zonemaster/gnunet-service-zonemaster.c
@@ -336,11 +336,10 @@ convert_records_for_export (const struct GNUNET_GNSRECORD_Data *rd,
336{ 336{
337 struct GNUNET_TIME_Absolute now; 337 struct GNUNET_TIME_Absolute now;
338 unsigned int rd_public_count; 338 unsigned int rd_public_count;
339 unsigned int i;
340 339
341 rd_public_count = 0; 340 rd_public_count = 0;
342 now = GNUNET_TIME_absolute_get (); 341 now = GNUNET_TIME_absolute_get ();
343 for (i=0;i<rd_count;i++) 342 for (unsigned int i=0;i<rd_count;i++)
344 if (0 == (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) 343 if (0 == (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))
345 { 344 {
346 rd_public[rd_public_count] = rd[i]; 345 rd_public[rd_public_count] = rd[i];
@@ -401,6 +400,10 @@ perform_dht_put (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
401 GNUNET_GNSRECORD_query_from_private_key (key, 400 GNUNET_GNSRECORD_query_from_private_key (key,
402 label, 401 label,
403 &query); 402 &query);
403 GNUNET_STATISTICS_update (statistics,
404 "DHT put operations initiated",
405 1,
406 GNUNET_NO);
404 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 407 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
405 "Storing %u record(s) for label `%s' in DHT with expiration `%s' under key %s\n", 408 "Storing %u record(s) for label `%s' in DHT with expiration `%s' under key %s\n",
406 rd_public_count, 409 rd_public_count,
@@ -424,10 +427,13 @@ perform_dht_put (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
424 427
425/** 428/**
426 * We encountered an error in our zone iteration. 429 * We encountered an error in our zone iteration.
430 *
431 * @param cls NULL
427 */ 432 */
428static void 433static void
429zone_iteration_error (void *cls) 434zone_iteration_error (void *cls)
430{ 435{
436 (void) cls;
431 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 437 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
432 "Got disconnected from namestore database, retrying.\n"); 438 "Got disconnected from namestore database, retrying.\n");
433 namestore_iter = NULL; 439 namestore_iter = NULL;
@@ -451,10 +457,13 @@ zone_iteration_error (void *cls)
451 457
452/** 458/**
453 * Zone iteration is completed. 459 * Zone iteration is completed.
460 *
461 * @param cls NULL
454 */ 462 */
455static void 463static void
456zone_iteration_finished (void *cls) 464zone_iteration_finished (void *cls)
457{ 465{
466 (void) cls;
458 /* we're done with one iteration, calculate when to do the next one */ 467 /* we're done with one iteration, calculate when to do the next one */
459 namestore_iter = NULL; 468 namestore_iter = NULL;
460 last_num_public_records = num_public_records; 469 last_num_public_records = num_public_records;
@@ -533,10 +542,10 @@ put_gns_record (void *cls,
533 struct GNUNET_GNSRECORD_Data rd_public[rd_count]; 542 struct GNUNET_GNSRECORD_Data rd_public[rd_count];
534 unsigned int rd_public_count; 543 unsigned int rd_public_count;
535 544
545 (void) cls;
536 rd_public_count = convert_records_for_export (rd, 546 rd_public_count = convert_records_for_export (rd,
537 rd_count, 547 rd_count,
538 rd_public); 548 rd_public);
539
540 if (0 == rd_public_count) 549 if (0 == rd_public_count)
541 { 550 {
542 GNUNET_assert (NULL == zone_publish_task); 551 GNUNET_assert (NULL == zone_publish_task);
@@ -571,7 +580,10 @@ static void
571publish_zone_dht_start (void *cls) 580publish_zone_dht_start (void *cls)
572{ 581{
573 zone_publish_task = NULL; 582 zone_publish_task = NULL;
574 583 GNUNET_STATISTICS_update (statistics,
584 "Full zone iterations launched",
585 1,
586 GNUNET_NO);
575 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 587 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
576 "Starting DHT zone update!\n"); 588 "Starting DHT zone update!\n");
577 /* start counting again */ 589 /* start counting again */
@@ -610,6 +622,10 @@ handle_monitor_event (void *cls,
610 unsigned int rd_public_count; 622 unsigned int rd_public_count;
611 struct MonitorActivity *ma; 623 struct MonitorActivity *ma;
612 624
625 GNUNET_STATISTICS_update (statistics,
626 "Namestore monitor events received",
627 1,
628 GNUNET_NO);
613 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 629 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
614 "Received %u records for label `%s' via namestore monitor\n", 630 "Received %u records for label `%s' via namestore monitor\n",
615 rd_count, 631 rd_count,
@@ -648,22 +664,28 @@ handle_monitor_event (void *cls,
648static void 664static void
649monitor_sync_event (void *cls) 665monitor_sync_event (void *cls)
650{ 666{
667 (void) cls;
651 if ( (NULL == zone_publish_task) && 668 if ( (NULL == zone_publish_task) &&
652 (NULL == namestore_iter) ) 669 (NULL == namestore_iter) )
653 zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start, 670 zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start,
654 NULL); 671 NULL);
655} 672}
656 673
657 674
658/** 675/**
659 * The zone monitor is now in SYNC with the current state of the 676 * The zone monitor encountered an IPC error trying to to get in
660 * name store. Start to perform periodic iterations. 677 * sync. Restart from the beginning.
661 * 678 *
662 * @param cls NULL 679 * @param cls NULL
663 */ 680 */
664static void 681static void
665handle_monitor_error (void *cls) 682handle_monitor_error (void *cls)
666{ 683{
684 (void) cls;
685 GNUNET_STATISTICS_update (statistics,
686 "Namestore monitor errors encountered",
687 1,
688 GNUNET_NO);
667 if (NULL != zone_publish_task) 689 if (NULL != zone_publish_task)
668 { 690 {
669 GNUNET_SCHEDULER_cancel (zone_publish_task); 691 GNUNET_SCHEDULER_cancel (zone_publish_task);
@@ -698,6 +720,7 @@ run (void *cls,
698{ 720{
699 unsigned long long max_parallel_bg_queries = 128; 721 unsigned long long max_parallel_bg_queries = 128;
700 722
723 (void) cls;
701 min_relative_record_time = GNUNET_TIME_UNIT_FOREVER_REL; 724 min_relative_record_time = GNUNET_TIME_UNIT_FOREVER_REL;
702 namestore_handle = GNUNET_NAMESTORE_connect (c); 725 namestore_handle = GNUNET_NAMESTORE_connect (c);
703 if (NULL == namestore_handle) 726 if (NULL == namestore_handle)
@@ -733,7 +756,7 @@ run (void *cls,
733 max_parallel_bg_queries); 756 max_parallel_bg_queries);
734 } 757 }
735 if (0 == max_parallel_bg_queries) 758 if (0 == max_parallel_bg_queries)
736 max_parallel_bg_queries = 1; 759 max_parallel_bg_queries = 1;
737 dht_handle = GNUNET_DHT_connect (c, 760 dht_handle = GNUNET_DHT_connect (c,
738 (unsigned int) max_parallel_bg_queries); 761 (unsigned int) max_parallel_bg_queries);
739 if (NULL == dht_handle) 762 if (NULL == dht_handle)
@@ -746,7 +769,8 @@ run (void *cls,
746 769
747 /* Schedule periodic put for our records. */ 770 /* Schedule periodic put for our records. */
748 first_zone_iteration = GNUNET_YES;\ 771 first_zone_iteration = GNUNET_YES;\
749 statistics = GNUNET_STATISTICS_create ("zonemaster", c); 772 statistics = GNUNET_STATISTICS_create ("zonemaster",
773 c);
750 zmon = GNUNET_NAMESTORE_zone_monitor_start (c, 774 zmon = GNUNET_NAMESTORE_zone_monitor_start (c,
751 NULL, 775 NULL,
752 GNUNET_NO, 776 GNUNET_NO,