X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fstatistics%2Fstatistics_api.c;h=ad4453b2a62a0e8515317e0d972bdd1c740aabab;hb=a015c3df2059a98a8692e7f2b06038e066bbc916;hp=7f5a257d97418b5adf1643630b99d8140dfd9c57;hpb=d980fb328a9ba1f6fe2e54d9b2d88b57d0d8016f;p=oweals%2Fgnunet.git diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index 7f5a257d9..ad4453b2a 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c @@ -295,12 +295,18 @@ update_memory_statistics (struct GNUNET_STATISTICS_Handle *h) if (current_heap_size > h->peak_heap_size) { h->peak_heap_size = current_heap_size; - GNUNET_STATISTICS_set (h, "# peak heap size", current_heap_size, GNUNET_NO); + GNUNET_STATISTICS_set (h, + "# peak heap size", + current_heap_size, + GNUNET_NO); } if (current_rss > h->peak_rss) { h->peak_rss = current_rss; - GNUNET_STATISTICS_set (h, "# peak resident set size", current_rss, GNUNET_NO); + GNUNET_STATISTICS_set (h, + "# peak resident set size", + current_rss, + GNUNET_NO); } #endif } @@ -570,16 +576,16 @@ do_destroy (void *cls) /** - * Handle a #GNUNET_MESSAGE_TYPE_TEST (sic) message. We receive this - * message at the end of the shutdown when the service confirms that - * all data has been written to disk. + * Handle a #GNUNET_MESSAGE_TYPE_STATISTICS_DISCONNECT_CONFIRM + * message. We receive this message at the end of the shutdown when + * the service confirms that all data has been written to disk. * * @param cls our `struct GNUNET_STATISTICS_Handle *` * @param msg the message */ static void -handle_test (void *cls, - const struct GNUNET_MessageHeader *msg) +handle_disconnect_confirm (void *cls, + const struct GNUNET_MessageHeader *msg) { struct GNUNET_STATISTICS_Handle *h = cls; @@ -592,7 +598,7 @@ handle_test (void *cls, return; } LOG (GNUNET_ERROR_TYPE_DEBUG, - "Received TEST message from statistics, can complete disconnect\n"); + "Received DISCONNNECT_CONFIRM message from statistics, can complete disconnect\n"); if (NULL != h->destroy_task) GNUNET_SCHEDULER_cancel (h->destroy_task); h->destroy_task = GNUNET_SCHEDULER_add_now (&do_destroy, @@ -646,23 +652,23 @@ handle_statistics_end (void *cls, static int try_connect (struct GNUNET_STATISTICS_Handle *h) { - GNUNET_MQ_hd_fixed_size (test, - GNUNET_MESSAGE_TYPE_TEST, - struct GNUNET_MessageHeader); - GNUNET_MQ_hd_fixed_size (statistics_end, - GNUNET_MESSAGE_TYPE_STATISTICS_END, - struct GNUNET_MessageHeader); - GNUNET_MQ_hd_var_size (statistics_value, - GNUNET_MESSAGE_TYPE_STATISTICS_VALUE, - struct GNUNET_STATISTICS_ReplyMessage); - GNUNET_MQ_hd_fixed_size (statistics_watch_value, - GNUNET_MESSAGE_TYPE_STATISTICS_WATCH_VALUE, - struct GNUNET_STATISTICS_WatchValueMessage); struct GNUNET_MQ_MessageHandler handlers[] = { - make_test_handler (h), - make_statistics_end_handler (h), - make_statistics_value_handler (h), - make_statistics_watch_value_handler (h), + GNUNET_MQ_hd_fixed_size (disconnect_confirm, + GNUNET_MESSAGE_TYPE_STATISTICS_DISCONNECT_CONFIRM, + struct GNUNET_MessageHeader, + h), + GNUNET_MQ_hd_fixed_size (statistics_end, + GNUNET_MESSAGE_TYPE_STATISTICS_END, + struct GNUNET_MessageHeader, + h), + GNUNET_MQ_hd_var_size (statistics_value, + GNUNET_MESSAGE_TYPE_STATISTICS_VALUE, + struct GNUNET_STATISTICS_ReplyMessage, + h), + GNUNET_MQ_hd_fixed_size (statistics_watch_value, + GNUNET_MESSAGE_TYPE_STATISTICS_WATCH_VALUE, + struct GNUNET_STATISTICS_WatchValueMessage, + h), GNUNET_MQ_handler_end () }; struct GNUNET_STATISTICS_GetHandle *gh; @@ -672,7 +678,7 @@ try_connect (struct GNUNET_STATISTICS_Handle *h) return GNUNET_NO; if (NULL != h->mq) return GNUNET_YES; - h->mq = GNUNET_CLIENT_connecT (h->cfg, + h->mq = GNUNET_CLIENT_connect (h->cfg, "statistics", handlers, &mq_error_handler, @@ -739,7 +745,8 @@ reconnect_later (struct GNUNET_STATISTICS_Handle *h) */ loss = GNUNET_NO; for (gh = h->action_head; NULL != gh; gh = gh->next) - if ( (gh->make_persistent) && (ACTION_SET == gh->type) ) + if ( (gh->make_persistent) && + (ACTION_SET == gh->type) ) loss = GNUNET_YES; if (GNUNET_YES == loss) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -921,7 +928,8 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, return; GNUNET_assert (GNUNET_NO == h->do_destroy); /* Don't call twice. */ if ( (sync_first) && - (GNUNET_YES == try_connect (h)) ) + (NULL != h->mq) && + (0 != GNUNET_MQ_get_length (h->mq)) ) { if ( (NULL != h->current) && (ACTION_GET == h->current->type) ) @@ -931,8 +939,7 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, { next = pos->next; if ( (ACTION_GET == pos->type) || - (ACTION_WATCH == pos->type) || - (GNUNET_NO == pos->make_persistent) ) + (ACTION_WATCH == pos->type) ) { GNUNET_CONTAINER_DLL_remove (h->action_head, h->action_tail, @@ -1007,8 +1014,8 @@ schedule_action (void *cls) reconnect_later (h); return; } - if (0 < GNUNET_MQ_get_length (h->mq) ) - return; /* Wait for queue to be reduced more */ + if (0 < GNUNET_MQ_get_length (h->mq)) + return; /* Wait for queue to be reduced more */ /* schedule next action */ while (NULL == h->current) { @@ -1025,7 +1032,7 @@ schedule_action (void *cls) "Notifying service that we are done\n"); h->do_destroy = GNUNET_SYSERR; /* in 'TEST' mode */ env = GNUNET_MQ_msg (hdr, - GNUNET_MESSAGE_TYPE_TEST); + GNUNET_MESSAGE_TYPE_STATISTICS_DISCONNECT); GNUNET_MQ_notify_sent (env, &schedule_action, h); @@ -1198,8 +1205,10 @@ GNUNET_STATISTICS_watch_cancel (struct GNUNET_STATISTICS_Handle *handle, continue; if ( (w->proc == proc) && (w->proc_cls == proc_cls) && - (0 == strcmp (w->name, name)) && - (0 == strcmp (w->subsystem, subsystem)) ) + (0 == strcmp (w->name, + name)) && + (0 == strcmp (w->subsystem, + subsystem)) ) { GNUNET_free (w->name); GNUNET_free (w->subsystem); @@ -1244,8 +1253,10 @@ add_setter_action (struct GNUNET_STATISTICS_Handle *h, } for (ai = h->action_head; NULL != ai; ai = ai->next) { - if (! ( (0 == strcmp (ai->subsystem, h->subsystem)) && - (0 == strcmp (ai->name, name)) && + if (! ( (0 == strcmp (ai->subsystem, + h->subsystem)) && + (0 == strcmp (ai->name, + name)) && ( (ACTION_UPDATE == ai->type) || (ACTION_SET == ai->type) ) ) ) continue; @@ -1289,8 +1300,10 @@ add_setter_action (struct GNUNET_STATISTICS_Handle *h, ai->type = type; } } - ai->timeout = GNUNET_TIME_relative_to_absolute (SET_TRANSMIT_TIMEOUT); - ai->make_persistent = make_persistent; + ai->timeout + = GNUNET_TIME_relative_to_absolute (SET_TRANSMIT_TIMEOUT); + ai->make_persistent + = make_persistent; return; } /* no existing entry matches, create a fresh one */