diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-04-28 08:39:27 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-04-28 08:39:27 +0000 |
commit | f93fea70b8018262f5142f2ed57ab90356acd372 (patch) | |
tree | 53554d8dad991efe7b655638454707aa1e14370c /src | |
parent | 66683153d35bf38d449a3bbfd071884cf1e0b156 (diff) | |
download | gnunet-f93fea70b8018262f5142f2ed57ab90356acd372.tar.gz gnunet-f93fea70b8018262f5142f2ed57ab90356acd372.zip |
fixing 1671
Diffstat (limited to 'src')
-rw-r--r-- | src/statistics/Makefile.am | 9 | ||||
-rw-r--r-- | src/statistics/statistics_api.c | 8 | ||||
-rw-r--r-- | src/statistics/test_statistics_api_data.conf | 2 | ||||
-rw-r--r-- | src/statistics/test_statistics_api_watch.c | 16 |
4 files changed, 27 insertions, 8 deletions
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 = \ | |||
46 | 46 | ||
47 | check_PROGRAMS = \ | 47 | check_PROGRAMS = \ |
48 | test_statistics_api \ | 48 | test_statistics_api \ |
49 | test_statistics_api_loop | 49 | test_statistics_api_loop \ |
50 | test_statistics_api_watch | ||
50 | 51 | ||
51 | if !DISABLE_TEST_RUN | 52 | if !DISABLE_TEST_RUN |
52 | TESTS = $(check_PROGRAMS) $(check_SCRIPTS) | 53 | TESTS = $(check_PROGRAMS) $(check_SCRIPTS) |
@@ -64,6 +65,12 @@ test_statistics_api_loop_LDADD = \ | |||
64 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 65 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
65 | $(top_builddir)/src/util/libgnunetutil.la | 66 | $(top_builddir)/src/util/libgnunetutil.la |
66 | 67 | ||
68 | test_statistics_api_watch_SOURCES = \ | ||
69 | test_statistics_api_watch.c | ||
70 | test_statistics_api_watch_LDADD = \ | ||
71 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
72 | $(top_builddir)/src/util/libgnunetutil.la | ||
73 | |||
67 | check_SCRIPTS = \ | 74 | check_SCRIPTS = \ |
68 | test_gnunet_statistics.sh | 75 | test_gnunet_statistics.sh |
69 | 76 | ||
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) | |||
620 | finish (handle, GNUNET_SYSERR); | 620 | finish (handle, GNUNET_SYSERR); |
621 | return 0; | 621 | return 0; |
622 | } | 622 | } |
623 | #if DEBUG_STATISTICS | ||
624 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
625 | "Transmitting watch request for `%s'\n", | ||
626 | handle->current->name); | ||
627 | #endif | ||
623 | slen1 = strlen (handle->current->subsystem) + 1; | 628 | slen1 = strlen (handle->current->subsystem) + 1; |
624 | slen2 = strlen (handle->current->name) + 1; | 629 | slen2 = strlen (handle->current->name) + 1; |
625 | msize = slen1 + slen2 + sizeof (struct GNUNET_MessageHeader); | 630 | msize = slen1 + slen2 + sizeof (struct GNUNET_MessageHeader); |
@@ -633,7 +638,7 @@ transmit_watch (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) | |||
633 | 2, | 638 | 2, |
634 | handle->current->subsystem, | 639 | handle->current->subsystem, |
635 | handle->current->name)); | 640 | handle->current->name)); |
636 | if (! handle->receiving) | 641 | if (GNUNET_YES != handle->receiving) |
637 | { | 642 | { |
638 | handle->receiving = GNUNET_YES; | 643 | handle->receiving = GNUNET_YES; |
639 | GNUNET_CLIENT_receive (handle->client, | 644 | GNUNET_CLIENT_receive (handle->client, |
@@ -641,6 +646,7 @@ transmit_watch (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) | |||
641 | handle, | 646 | handle, |
642 | GNUNET_TIME_UNIT_FOREVER_REL); | 647 | GNUNET_TIME_UNIT_FOREVER_REL); |
643 | } | 648 | } |
649 | finish (handle, GNUNET_OK); | ||
644 | return msize; | 650 | return msize; |
645 | } | 651 | } |
646 | 652 | ||
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 | |||
5 | [statistics] | 5 | [statistics] |
6 | PORT = 22353 | 6 | PORT = 22353 |
7 | UNIXPATH = /tmp/test-statistics-service-statistics.unix | 7 | UNIXPATH = /tmp/test-statistics-service-statistics.unix |
8 | DEBUG = NO | 8 | #DEBUG = YES |
9 | 9 | ||
10 | [arm] | 10 | [arm] |
11 | PORT = 22354 | 11 | 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 @@ | |||
29 | #include "gnunet_scheduler_lib.h" | 29 | #include "gnunet_scheduler_lib.h" |
30 | #include "gnunet_statistics_service.h" | 30 | #include "gnunet_statistics_service.h" |
31 | 31 | ||
32 | #define VERBOSE GNUNET_YES | 32 | #define VERBOSE GNUNET_NO |
33 | 33 | ||
34 | #define START_SERVICE GNUNET_YES | 34 | #define START_SERVICE GNUNET_YES |
35 | 35 | ||
@@ -53,6 +53,14 @@ force_shutdown (void *cls, | |||
53 | ok = 7; | 53 | ok = 7; |
54 | } | 54 | } |
55 | 55 | ||
56 | static void | ||
57 | normal_shutdown (void *cls, | ||
58 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
59 | { | ||
60 | GNUNET_STATISTICS_destroy (h, GNUNET_NO); | ||
61 | GNUNET_STATISTICS_destroy (h2, GNUNET_NO); | ||
62 | } | ||
63 | |||
56 | static int | 64 | static int |
57 | watch_1 (void *cls, | 65 | watch_1 (void *cls, |
58 | const char *subsystem, | 66 | const char *subsystem, |
@@ -66,9 +74,8 @@ watch_1 (void *cls, | |||
66 | ok &= ~1; | 74 | ok &= ~1; |
67 | if (0 == ok) | 75 | if (0 == ok) |
68 | { | 76 | { |
69 | GNUNET_STATISTICS_destroy (h, GNUNET_NO); | ||
70 | GNUNET_STATISTICS_destroy (h2, GNUNET_NO); | ||
71 | GNUNET_SCHEDULER_cancel (shutdown_task); | 77 | GNUNET_SCHEDULER_cancel (shutdown_task); |
78 | GNUNET_SCHEDULER_add_now (&normal_shutdown, NULL); | ||
72 | } | 79 | } |
73 | return GNUNET_OK; | 80 | return GNUNET_OK; |
74 | } | 81 | } |
@@ -86,9 +93,8 @@ watch_2 (void *cls, | |||
86 | ok &= ~2; | 93 | ok &= ~2; |
87 | if (0 == ok) | 94 | if (0 == ok) |
88 | { | 95 | { |
89 | GNUNET_STATISTICS_destroy (h, GNUNET_NO); | ||
90 | GNUNET_STATISTICS_destroy (h2, GNUNET_NO); | ||
91 | GNUNET_SCHEDULER_cancel (shutdown_task); | 96 | GNUNET_SCHEDULER_cancel (shutdown_task); |
97 | GNUNET_SCHEDULER_add_now (&normal_shutdown, NULL); | ||
92 | } | 98 | } |
93 | return GNUNET_OK; | 99 | return GNUNET_OK; |
94 | } | 100 | } |