diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-06-28 17:16:47 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-06-28 17:16:47 +0000 |
commit | d980fb328a9ba1f6fe2e54d9b2d88b57d0d8016f (patch) | |
tree | 58fb1526a2b96afa360b80231be58b502444822a /src/statistics | |
parent | b01ab9629a1e9eecbae514ec662c47b79db78042 (diff) | |
download | gnunet-d980fb328a9ba1f6fe2e54d9b2d88b57d0d8016f.tar.gz gnunet-d980fb328a9ba1f6fe2e54d9b2d88b57d0d8016f.zip |
-ensure stats queues do not grow too big
Diffstat (limited to 'src/statistics')
-rw-r--r-- | src/statistics/statistics_api.c | 23 |
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 | */ |
314 | static void | 314 | static void |
315 | schedule_action (void *cls); | 315 | reconnect_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 | */ |
323 | static void | 323 | static void |
324 | reconnect_later (struct GNUNET_STATISTICS_Handle *h); | 324 | schedule_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; |