fixing 1671
authorChristian Grothoff <christian@grothoff.org>
Thu, 28 Apr 2011 08:39:27 +0000 (08:39 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 28 Apr 2011 08:39:27 +0000 (08:39 +0000)
src/statistics/Makefile.am
src/statistics/statistics_api.c
src/statistics/test_statistics_api_data.conf
src/statistics/test_statistics_api_watch.c

index 2de8772ba07e1ab3f388d035d7de10b7bd2ce001..2a1d0d529f4ab099cb2b9cf3954041021f0a231c 100644 (file)
@@ -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
 
index d44bc77d11c25ed310103a5acc6963cb62226851..290a7b93fe3afdcd96b4397f8b663fc6816a04d5 100644 (file)
@@ -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;
 }
 
index d93758fd3d1802f928eca49fceef7b45e9198485..794d143ba35fd16ba8256c418f8b8e6c8b16c001 100644 (file)
@@ -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
index 0e5b7ae86accbdc90117520c058e6b6e4fc3268e..a7ae490a7b8924308bdf987ef8c8a8d1aa01fdac 100644 (file)
@@ -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;
 }