diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-04-19 11:55:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-04-19 11:55:40 +0000 |
commit | 50c4e060fc721dfe2af9115639a4d47e88e04f00 (patch) | |
tree | 5ba39a3f1335c65bd750261cc78db9f39bb076fc /src/util/test_service.c | |
parent | 93a5401e858e978aa2d7fc090fc1f6612c15dc3f (diff) | |
download | gnunet-50c4e060fc721dfe2af9115639a4d47e88e04f00.tar.gz gnunet-50c4e060fc721dfe2af9115639a4d47e88e04f00.zip |
-simplifying destruction of connections, cleaning up server API -- all for #2274
Diffstat (limited to 'src/util/test_service.c')
-rw-r--r-- | src/util/test_service.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/util/test_service.c b/src/util/test_service.c index 716e90d78..83fbdec95 100644 --- a/src/util/test_service.c +++ b/src/util/test_service.c | |||
@@ -41,18 +41,18 @@ static struct GNUNET_SERVICE_Context *sctx; | |||
41 | 41 | ||
42 | static int ok = 1; | 42 | static int ok = 1; |
43 | 43 | ||
44 | static struct GNUNET_CLIENT_Connection *client; | ||
45 | |||
44 | 46 | ||
45 | static size_t | 47 | static size_t |
46 | build_msg (void *cls, size_t size, void *buf) | 48 | build_msg (void *cls, size_t size, void *buf) |
47 | { | 49 | { |
48 | struct GNUNET_CLIENT_Connection *client = cls; | ||
49 | struct GNUNET_MessageHeader *msg = buf; | 50 | struct GNUNET_MessageHeader *msg = buf; |
50 | 51 | ||
51 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client connected, transmitting\n"); | 52 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client connected, transmitting\n"); |
52 | GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); | 53 | GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); |
53 | msg->type = htons (MY_TYPE); | 54 | msg->type = htons (MY_TYPE); |
54 | msg->size = htons (sizeof (struct GNUNET_MessageHeader)); | 55 | msg->size = htons (sizeof (struct GNUNET_MessageHeader)); |
55 | GNUNET_CLIENT_disconnect (client); | ||
56 | return sizeof (struct GNUNET_MessageHeader); | 56 | return sizeof (struct GNUNET_MessageHeader); |
57 | } | 57 | } |
58 | 58 | ||
@@ -72,23 +72,24 @@ ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
72 | GNUNET_CLIENT_notify_transmit_ready (client, | 72 | GNUNET_CLIENT_notify_transmit_ready (client, |
73 | sizeof (struct GNUNET_MessageHeader), | 73 | sizeof (struct GNUNET_MessageHeader), |
74 | GNUNET_TIME_UNIT_SECONDS, GNUNET_NO, | 74 | GNUNET_TIME_UNIT_SECONDS, GNUNET_NO, |
75 | &build_msg, client); | 75 | &build_msg, NULL); |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | static void | 79 | static void |
80 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 80 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
81 | { | 81 | { |
82 | GNUNET_CLIENT_disconnect (client); | ||
82 | GNUNET_SERVICE_stop (sctx); | 83 | GNUNET_SERVICE_stop (sctx); |
83 | } | 84 | } |
84 | 85 | ||
85 | 86 | ||
86 | static void | 87 | static void |
87 | recv_cb (void *cls, struct GNUNET_SERVER_Client *client, | 88 | recv_cb (void *cls, struct GNUNET_SERVER_Client *sc, |
88 | const struct GNUNET_MessageHeader *message) | 89 | const struct GNUNET_MessageHeader *message) |
89 | { | 90 | { |
90 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n"); | 91 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n"); |
91 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 92 | GNUNET_SERVER_receive_done (sc, GNUNET_OK); |
92 | if (sctx != NULL) | 93 | if (sctx != NULL) |
93 | GNUNET_SCHEDULER_add_now (&do_stop, NULL); | 94 | GNUNET_SCHEDULER_add_now (&do_stop, NULL); |
94 | else | 95 | else |
@@ -146,7 +147,6 @@ static void | |||
146 | ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 147 | ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
147 | { | 148 | { |
148 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 149 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
149 | struct GNUNET_CLIENT_Connection *client; | ||
150 | 150 | ||
151 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 ready\n"); | 151 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 ready\n"); |
152 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); | 152 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); |
@@ -156,7 +156,7 @@ ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
156 | GNUNET_CLIENT_notify_transmit_ready (client, | 156 | GNUNET_CLIENT_notify_transmit_ready (client, |
157 | sizeof (struct GNUNET_MessageHeader), | 157 | sizeof (struct GNUNET_MessageHeader), |
158 | GNUNET_TIME_UNIT_SECONDS, GNUNET_NO, | 158 | GNUNET_TIME_UNIT_SECONDS, GNUNET_NO, |
159 | &build_msg, client); | 159 | &build_msg, NULL); |
160 | } | 160 | } |
161 | 161 | ||
162 | static void | 162 | static void |