aboutsummaryrefslogtreecommitdiff
path: root/src/statistics
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-23 19:55:15 +0000
committerChristian Grothoff <christian@grothoff.org>2016-06-23 19:55:15 +0000
commit01de5a0922056472969cf23a87241791a6f8cc1f (patch)
tree37619d5608d8ce0f7ebc8ffcbee7733ae5fbbe26 /src/statistics
parent44ad80664bfcb495eb82599680bde78ccb02cd6d (diff)
downloadgnunet-01de5a0922056472969cf23a87241791a6f8cc1f.tar.gz
gnunet-01de5a0922056472969cf23a87241791a6f8cc1f.zip
-try to fix stats issue
Diffstat (limited to 'src/statistics')
-rw-r--r--src/statistics/statistics_api.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c
index 6e4c768ba..efbef3f31 100644
--- a/src/statistics/statistics_api.c
+++ b/src/statistics/statistics_api.c
@@ -536,6 +536,11 @@ mq_error_handler (void *cls,
536 if (GNUNET_NO != h->do_destroy) 536 if (GNUNET_NO != h->do_destroy)
537 { 537 {
538 h->do_destroy = GNUNET_NO; 538 h->do_destroy = GNUNET_NO;
539 if (NULL != h->destroy_task)
540 {
541 GNUNET_SCHEDULER_cancel (h->destroy_task);
542 h->destroy_task = NULL;
543 }
539 GNUNET_STATISTICS_destroy (h, 544 GNUNET_STATISTICS_destroy (h,
540 GNUNET_NO); 545 GNUNET_NO);
541 return; 546 return;
@@ -551,10 +556,12 @@ mq_error_handler (void *cls,
551 * @param cls the `struct GNUNET_STATISTICS_Handle` 556 * @param cls the `struct GNUNET_STATISTICS_Handle`
552 */ 557 */
553static void 558static void
554destroy_task (void *cls) 559do_destroy (void *cls)
555{ 560{
556 struct GNUNET_STATISTICS_Handle *h = cls; 561 struct GNUNET_STATISTICS_Handle *h = cls;
557 562
563 h->destroy_task = NULL;
564 h->do_destroy = GNUNET_NO;
558 LOG (GNUNET_ERROR_TYPE_DEBUG, 565 LOG (GNUNET_ERROR_TYPE_DEBUG,
559 "Running final destruction\n"); 566 "Running final destruction\n");
560 GNUNET_STATISTICS_destroy (h, 567 GNUNET_STATISTICS_destroy (h,
@@ -584,11 +591,12 @@ handle_test (void *cls,
584 reconnect_later (h); 591 reconnect_later (h);
585 return; 592 return;
586 } 593 }
587 h->do_destroy = GNUNET_NO;
588 LOG (GNUNET_ERROR_TYPE_DEBUG, 594 LOG (GNUNET_ERROR_TYPE_DEBUG,
589 "Received TEST message from statistics, can complete disconnect\n"); 595 "Received TEST message from statistics, can complete disconnect\n");
590 GNUNET_SCHEDULER_add_now (&destroy_task, 596 if (NULL != h->destroy_task)
591 h); 597 GNUNET_SCHEDULER_cancel (h->destroy_task);
598 h->destroy_task = GNUNET_SCHEDULER_add_now (&do_destroy,
599 h);
592} 600}
593 601
594 602
@@ -711,23 +719,6 @@ reconnect_task (void *cls)
711 719
712 720
713/** 721/**
714 * Task used by #reconnect_later() to shutdown the handle
715 *
716 * @param cls the statistics handle
717 */
718static void
719do_destroy (void *cls)
720{
721 struct GNUNET_STATISTICS_Handle *h = cls;
722
723 h->destroy_task = NULL;
724 h->do_destroy = GNUNET_NO;
725 GNUNET_STATISTICS_destroy (h,
726 GNUNET_NO);
727}
728
729
730/**
731 * Reconnect at a later time, respecting back-off. 722 * Reconnect at a later time, respecting back-off.
732 * 723 *
733 * @param h statistics handle 724 * @param h statistics handle
@@ -753,7 +744,6 @@ reconnect_later (struct GNUNET_STATISTICS_Handle *h)
753 if (GNUNET_YES == loss) 744 if (GNUNET_YES == loss)
754 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 745 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
755 _("Could not save some persistent statistics\n")); 746 _("Could not save some persistent statistics\n"));
756 h->do_destroy = GNUNET_NO;
757 if (NULL != h->destroy_task) 747 if (NULL != h->destroy_task)
758 GNUNET_SCHEDULER_cancel (h->destroy_task); 748 GNUNET_SCHEDULER_cancel (h->destroy_task);
759 h->destroy_task = GNUNET_SCHEDULER_add_now (&do_destroy, 749 h->destroy_task = GNUNET_SCHEDULER_add_now (&do_destroy,
@@ -923,7 +913,7 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h,
923 913
924 if (NULL == h) 914 if (NULL == h)
925 return; 915 return;
926 GNUNET_assert (GNUNET_NO == h->do_destroy); // Don't call twice. 916 GNUNET_assert (GNUNET_NO == h->do_destroy); /* Don't call twice. */
927 if ( (sync_first) && 917 if ( (sync_first) &&
928 (GNUNET_YES == try_connect (h)) ) 918 (GNUNET_YES == try_connect (h)) )
929 { 919 {
@@ -946,6 +936,7 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h,
946 } 936 }
947 h->do_destroy = GNUNET_YES; 937 h->do_destroy = GNUNET_YES;
948 schedule_action (h); 938 schedule_action (h);
939 GNUNET_assert (NULL == h->destroy_task);
949 h->destroy_task 940 h->destroy_task
950 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (h->backoff, 941 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (h->backoff,
951 5), 942 5),