aboutsummaryrefslogtreecommitdiff
path: root/src/statistics/statistics_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-28 17:16:47 +0000
committerChristian Grothoff <christian@grothoff.org>2016-06-28 17:16:47 +0000
commitd980fb328a9ba1f6fe2e54d9b2d88b57d0d8016f (patch)
tree58fb1526a2b96afa360b80231be58b502444822a /src/statistics/statistics_api.c
parentb01ab9629a1e9eecbae514ec662c47b79db78042 (diff)
downloadgnunet-d980fb328a9ba1f6fe2e54d9b2d88b57d0d8016f.tar.gz
gnunet-d980fb328a9ba1f6fe2e54d9b2d88b57d0d8016f.zip
-ensure stats queues do not grow too big
Diffstat (limited to 'src/statistics/statistics_api.c')
-rw-r--r--src/statistics/statistics_api.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c
index efbef3f31..7f5a257d9 100644
--- a/src/statistics/statistics_api.c
+++ b/src/statistics/statistics_api.c
@@ -307,21 +307,21 @@ update_memory_statistics (struct GNUNET_STATISTICS_Handle *h)
307 307
308 308
309/** 309/**
310 * Schedule the next action to be performed. 310 * Reconnect at a later time, respecting back-off.
311 * 311 *
312 * @param cls statistics handle to reconnect 312 * @param h statistics handle
313 */ 313 */
314static void 314static void
315schedule_action (void *cls); 315reconnect_later (struct GNUNET_STATISTICS_Handle *h);
316 316
317 317
318/** 318/**
319 * Reconnect at a later time, respecting back-off. 319 * Schedule the next action to be performed.
320 * 320 *
321 * @param h statistics handle 321 * @param cls statistics handle to reconnect
322 */ 322 */
323static void 323static void
324reconnect_later (struct GNUNET_STATISTICS_Handle *h); 324schedule_action (void *cls);
325 325
326 326
327/** 327/**
@@ -786,6 +786,9 @@ transmit_get (struct GNUNET_STATISTICS_Handle *handle)
786 2, 786 2,
787 c->subsystem, 787 c->subsystem,
788 c->name)); 788 c->name));
789 GNUNET_MQ_notify_sent (env,
790 &schedule_action,
791 handle);
789 GNUNET_MQ_send (handle->mq, 792 GNUNET_MQ_send (handle->mq,
790 env); 793 env);
791} 794}
@@ -819,6 +822,9 @@ transmit_watch (struct GNUNET_STATISTICS_Handle *handle)
819 2, 822 2,
820 handle->current->subsystem, 823 handle->current->subsystem,
821 handle->current->name)); 824 handle->current->name));
825 GNUNET_MQ_notify_sent (env,
826 &schedule_action,
827 handle);
822 GNUNET_MQ_send (handle->mq, 828 GNUNET_MQ_send (handle->mq,
823 env); 829 env);
824 GNUNET_assert (NULL == handle->current->cont); 830 GNUNET_assert (NULL == handle->current->cont);
@@ -1001,6 +1007,8 @@ schedule_action (void *cls)
1001 reconnect_later (h); 1007 reconnect_later (h);
1002 return; 1008 return;
1003 } 1009 }
1010 if (0 < GNUNET_MQ_get_length (h->mq) )
1011 return; /* Wait for queue to be reduced more */
1004 /* schedule next action */ 1012 /* schedule next action */
1005 while (NULL == h->current) 1013 while (NULL == h->current)
1006 { 1014 {
@@ -1018,6 +1026,9 @@ schedule_action (void *cls)
1018 h->do_destroy = GNUNET_SYSERR; /* in 'TEST' mode */ 1026 h->do_destroy = GNUNET_SYSERR; /* in 'TEST' mode */
1019 env = GNUNET_MQ_msg (hdr, 1027 env = GNUNET_MQ_msg (hdr,
1020 GNUNET_MESSAGE_TYPE_TEST); 1028 GNUNET_MESSAGE_TYPE_TEST);
1029 GNUNET_MQ_notify_sent (env,
1030 &schedule_action,
1031 h);
1021 GNUNET_MQ_send (h->mq, 1032 GNUNET_MQ_send (h->mq,
1022 env); 1033 env);
1023 return; 1034 return;