diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-04-24 23:28:24 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-04-24 23:28:24 +0200 |
commit | bdbb7c684f2c9711989d2543ecc08a95be23e6c4 (patch) | |
tree | 28c453ab36c79aa5058ec64f4b42889216098c5a /src/namestore | |
parent | 72b802f9173bdd0f5d6830c56d7c51c3349073fe (diff) | |
download | gnunet-bdbb7c684f2c9711989d2543ecc08a95be23e6c4.tar.gz gnunet-bdbb7c684f2c9711989d2543ecc08a95be23e6c4.zip |
code cleanup, more diagnostics, more statistics
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 3ba4f9ec3..cc41f071d 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include "gnunet_namecache_service.h" | 31 | #include "gnunet_namecache_service.h" |
32 | #include "gnunet_namestore_service.h" | 32 | #include "gnunet_namestore_service.h" |
33 | #include "gnunet_namestore_plugin.h" | 33 | #include "gnunet_namestore_plugin.h" |
34 | #include "gnunet_statistics_service.h" | ||
34 | #include "gnunet_signatures.h" | 35 | #include "gnunet_signatures.h" |
35 | #include "namestore.h" | 36 | #include "namestore.h" |
36 | 37 | ||
@@ -206,6 +207,11 @@ static const struct GNUNET_CRYPTO_EcdsaPrivateKey zero; | |||
206 | static const struct GNUNET_CONFIGURATION_Handle *GSN_cfg; | 207 | static const struct GNUNET_CONFIGURATION_Handle *GSN_cfg; |
207 | 208 | ||
208 | /** | 209 | /** |
210 | * Handle to the statistics service | ||
211 | */ | ||
212 | static struct GNUNET_STATISTICS_Handle *statistics; | ||
213 | |||
214 | /** | ||
209 | * Namecache handle. | 215 | * Namecache handle. |
210 | */ | 216 | */ |
211 | static struct GNUNET_NAMECACHE_Handle *namecache; | 217 | static struct GNUNET_NAMECACHE_Handle *namecache; |
@@ -280,6 +286,12 @@ cleanup_task (void *cls) | |||
280 | GNUNET_notification_context_destroy (monitor_nc); | 286 | GNUNET_notification_context_destroy (monitor_nc); |
281 | monitor_nc = NULL; | 287 | monitor_nc = NULL; |
282 | } | 288 | } |
289 | if (NULL != statistics) | ||
290 | { | ||
291 | GNUNET_STATISTICS_destroy (statistics, | ||
292 | GNUNET_NO); | ||
293 | statistics = NULL; | ||
294 | } | ||
283 | } | 295 | } |
284 | 296 | ||
285 | 297 | ||
@@ -582,6 +594,10 @@ send_lookup_response (struct NamestoreClient *nc, | |||
582 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 594 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
583 | "Sending RECORD_RESULT message with %u records\n", | 595 | "Sending RECORD_RESULT message with %u records\n", |
584 | res_count); | 596 | res_count); |
597 | GNUNET_STATISTICS_update (statistics, | ||
598 | "Record sets sent to clients", | ||
599 | 1, | ||
600 | GNUNET_NO); | ||
585 | GNUNET_MQ_send (nc->mq, | 601 | GNUNET_MQ_send (nc->mq, |
586 | env); | 602 | env); |
587 | if (rd != res) | 603 | if (rd != res) |
@@ -707,6 +723,10 @@ refresh_block (struct NamestoreClient *nc, | |||
707 | name, | 723 | name, |
708 | res_count, | 724 | res_count, |
709 | GNUNET_GNSRECORD_z2s (&pkey)); | 725 | GNUNET_GNSRECORD_z2s (&pkey)); |
726 | GNUNET_STATISTICS_update (statistics, | ||
727 | "Namecache updates pushed", | ||
728 | 1, | ||
729 | GNUNET_NO); | ||
710 | cop = GNUNET_new (struct CacheOperation); | 730 | cop = GNUNET_new (struct CacheOperation); |
711 | cop->nc = nc; | 731 | cop->nc = nc; |
712 | cop->rid = rid; | 732 | cop->rid = rid; |
@@ -774,7 +794,8 @@ lookup_it (void *cls, | |||
774 | unsigned int rdc_res; | 794 | unsigned int rdc_res; |
775 | 795 | ||
776 | (void) private_key; | 796 | (void) private_key; |
777 | if (0 == strcmp (label, rlc->label)) | 797 | if (0 == strcmp (label, |
798 | rlc->label)) | ||
778 | { | 799 | { |
779 | rlc->found = GNUNET_YES; | 800 | rlc->found = GNUNET_YES; |
780 | if (0 != rd_count) | 801 | if (0 != rd_count) |
@@ -1332,7 +1353,8 @@ zone_iterate_proc (void *cls, | |||
1332 | struct ZoneIterationProcResult *proc = cls; | 1353 | struct ZoneIterationProcResult *proc = cls; |
1333 | int do_refresh_block; | 1354 | int do_refresh_block; |
1334 | 1355 | ||
1335 | if ((NULL == zone_key) && (NULL == name)) | 1356 | if ( (NULL == zone_key) && |
1357 | (NULL == name) ) | ||
1336 | { | 1358 | { |
1337 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1359 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1338 | "Iteration done\n"); | 1360 | "Iteration done\n"); |
@@ -1391,11 +1413,14 @@ run_zone_iteration_round (struct ZoneIteration *zi) | |||
1391 | { | 1413 | { |
1392 | if (GNUNET_SYSERR == | 1414 | if (GNUNET_SYSERR == |
1393 | (ret = GSN_database->iterate_records (GSN_database->cls, | 1415 | (ret = GSN_database->iterate_records (GSN_database->cls, |
1394 | (0 == memcmp (&zi->zone, &zero, sizeof (zero))) | 1416 | (0 == memcmp (&zi->zone, |
1417 | &zero, | ||
1418 | sizeof (zero))) | ||
1395 | ? NULL | 1419 | ? NULL |
1396 | : &zi->zone, | 1420 | : &zi->zone, |
1397 | zi->offset, | 1421 | zi->offset, |
1398 | &zone_iterate_proc, &proc))) | 1422 | &zone_iterate_proc, |
1423 | &proc))) | ||
1399 | { | 1424 | { |
1400 | GNUNET_break (0); | 1425 | GNUNET_break (0); |
1401 | break; | 1426 | break; |
@@ -1503,6 +1528,10 @@ handle_iteration_next (void *cls, | |||
1503 | 1528 | ||
1504 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1529 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1505 | "Received ZONE_ITERATION_NEXT message\n"); | 1530 | "Received ZONE_ITERATION_NEXT message\n"); |
1531 | GNUNET_STATISTICS_update (statistics, | ||
1532 | "Iteration NEXT messages received", | ||
1533 | 1, | ||
1534 | GNUNET_NO); | ||
1506 | rid = ntohl (zis_msg->gns_header.r_id); | 1535 | rid = ntohl (zis_msg->gns_header.r_id); |
1507 | for (zi = nc->op_head; NULL != zi; zi = zi->next) | 1536 | for (zi = nc->op_head; NULL != zi; zi = zi->next) |
1508 | if (zi->request_id == rid) | 1537 | if (zi->request_id == rid) |
@@ -1569,6 +1598,10 @@ monitor_iterate_cb (void *cls, | |||
1569 | monitor_sync (zm); | 1598 | monitor_sync (zm); |
1570 | return; | 1599 | return; |
1571 | } | 1600 | } |
1601 | GNUNET_STATISTICS_update (statistics, | ||
1602 | "Monitor notifications sent", | ||
1603 | 1, | ||
1604 | GNUNET_NO); | ||
1572 | send_lookup_response (zm->nc, | 1605 | send_lookup_response (zm->nc, |
1573 | 0, | 1606 | 0, |
1574 | zone_key, | 1607 | zone_key, |
@@ -1684,6 +1717,8 @@ run (void *cls, | |||
1684 | GSN_database = GNUNET_PLUGIN_load (db_lib_name, | 1717 | GSN_database = GNUNET_PLUGIN_load (db_lib_name, |
1685 | (void *) GSN_cfg); | 1718 | (void *) GSN_cfg); |
1686 | GNUNET_free (database); | 1719 | GNUNET_free (database); |
1720 | statistics = GNUNET_STATISTICS_create ("namestore", | ||
1721 | cfg); | ||
1687 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, | 1722 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, |
1688 | NULL); | 1723 | NULL); |
1689 | if (NULL == GSN_database) | 1724 | if (NULL == GSN_database) |