From f93fea70b8018262f5142f2ed57ab90356acd372 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 28 Apr 2011 08:39:27 +0000 Subject: fixing 1671 --- src/statistics/Makefile.am | 9 ++++++++- src/statistics/statistics_api.c | 8 +++++++- src/statistics/test_statistics_api_data.conf | 2 +- src/statistics/test_statistics_api_watch.c | 16 +++++++++++----- 4 files changed, 27 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/statistics/Makefile.am b/src/statistics/Makefile.am index 2de8772ba..2a1d0d529 100644 --- a/src/statistics/Makefile.am +++ b/src/statistics/Makefile.am @@ -46,7 +46,8 @@ gnunet_service_statistics_DEPENDENCIES = \ check_PROGRAMS = \ test_statistics_api \ - test_statistics_api_loop + test_statistics_api_loop \ + test_statistics_api_watch if !DISABLE_TEST_RUN TESTS = $(check_PROGRAMS) $(check_SCRIPTS) @@ -64,6 +65,12 @@ test_statistics_api_loop_LDADD = \ $(top_builddir)/src/statistics/libgnunetstatistics.la \ $(top_builddir)/src/util/libgnunetutil.la +test_statistics_api_watch_SOURCES = \ + test_statistics_api_watch.c +test_statistics_api_watch_LDADD = \ + $(top_builddir)/src/statistics/libgnunetstatistics.la \ + $(top_builddir)/src/util/libgnunetutil.la + check_SCRIPTS = \ test_gnunet_statistics.sh diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index d44bc77d1..290a7b93f 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c @@ -620,6 +620,11 @@ transmit_watch (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) finish (handle, GNUNET_SYSERR); return 0; } +#if DEBUG_STATISTICS + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Transmitting watch request for `%s'\n", + handle->current->name); +#endif slen1 = strlen (handle->current->subsystem) + 1; slen2 = strlen (handle->current->name) + 1; msize = slen1 + slen2 + sizeof (struct GNUNET_MessageHeader); @@ -633,7 +638,7 @@ transmit_watch (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) 2, handle->current->subsystem, handle->current->name)); - if (! handle->receiving) + if (GNUNET_YES != handle->receiving) { handle->receiving = GNUNET_YES; GNUNET_CLIENT_receive (handle->client, @@ -641,6 +646,7 @@ transmit_watch (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) handle, GNUNET_TIME_UNIT_FOREVER_REL); } + finish (handle, GNUNET_OK); return msize; } diff --git a/src/statistics/test_statistics_api_data.conf b/src/statistics/test_statistics_api_data.conf index d93758fd3..794d143ba 100644 --- a/src/statistics/test_statistics_api_data.conf +++ b/src/statistics/test_statistics_api_data.conf @@ -5,7 +5,7 @@ DEFAULTCONFIG = test_statistics_api_data.conf [statistics] PORT = 22353 UNIXPATH = /tmp/test-statistics-service-statistics.unix -DEBUG = NO +#DEBUG = YES [arm] PORT = 22354 diff --git a/src/statistics/test_statistics_api_watch.c b/src/statistics/test_statistics_api_watch.c index 0e5b7ae86..a7ae490a7 100644 --- a/src/statistics/test_statistics_api_watch.c +++ b/src/statistics/test_statistics_api_watch.c @@ -29,7 +29,7 @@ #include "gnunet_scheduler_lib.h" #include "gnunet_statistics_service.h" -#define VERBOSE GNUNET_YES +#define VERBOSE GNUNET_NO #define START_SERVICE GNUNET_YES @@ -53,6 +53,14 @@ force_shutdown (void *cls, ok = 7; } +static void +normal_shutdown (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + GNUNET_STATISTICS_destroy (h, GNUNET_NO); + GNUNET_STATISTICS_destroy (h2, GNUNET_NO); +} + static int watch_1 (void *cls, const char *subsystem, @@ -66,9 +74,8 @@ watch_1 (void *cls, ok &= ~1; if (0 == ok) { - GNUNET_STATISTICS_destroy (h, GNUNET_NO); - GNUNET_STATISTICS_destroy (h2, GNUNET_NO); GNUNET_SCHEDULER_cancel (shutdown_task); + GNUNET_SCHEDULER_add_now (&normal_shutdown, NULL); } return GNUNET_OK; } @@ -86,9 +93,8 @@ watch_2 (void *cls, ok &= ~2; if (0 == ok) { - GNUNET_STATISTICS_destroy (h, GNUNET_NO); - GNUNET_STATISTICS_destroy (h2, GNUNET_NO); GNUNET_SCHEDULER_cancel (shutdown_task); + GNUNET_SCHEDULER_add_now (&normal_shutdown, NULL); } return GNUNET_OK; } -- cgit v1.2.3