diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-09-05 11:44:56 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-09-05 11:44:56 +0000 |
commit | 1744330ca7033f849bf486188bf125a2b3818498 (patch) | |
tree | dce611a6df10def20b3ebbc44ab6ebe149f43137 /src/testbed/test_testbed_api.c | |
parent | 270a6392703fe1cb99f69ed8a35c1be0c864b11f (diff) | |
download | gnunet-1744330ca7033f849bf486188bf125a2b3818498.tar.gz gnunet-1744330ca7033f849bf486188bf125a2b3818498.zip |
service connect callback instead of operation completion callback
Diffstat (limited to 'src/testbed/test_testbed_api.c')
-rw-r--r-- | src/testbed/test_testbed_api.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/testbed/test_testbed_api.c b/src/testbed/test_testbed_api.c index 529072cee..b2a07650a 100644 --- a/src/testbed/test_testbed_api.c +++ b/src/testbed/test_testbed_api.c | |||
@@ -198,8 +198,10 @@ dht_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
198 | static void | 198 | static void |
199 | dht_disconnect_adapter (void *cls, void *op_result) | 199 | dht_disconnect_adapter (void *cls, void *op_result) |
200 | { | 200 | { |
201 | if (NULL != op_result) | 201 | GNUNET_assert (NULL != op_result); |
202 | GNUNET_DHT_disconnect (op_result); | 202 | GNUNET_assert (op_result == dht_handle); |
203 | GNUNET_DHT_disconnect (dht_handle); | ||
204 | dht_handle = NULL; | ||
203 | GNUNET_assert (PEER_SERVICE_CONNECT == sub_test); | 205 | GNUNET_assert (PEER_SERVICE_CONNECT == sub_test); |
204 | GNUNET_assert (NULL != operation); | 206 | GNUNET_assert (NULL != operation); |
205 | operation = GNUNET_TESTBED_peer_stop (peer); | 207 | operation = GNUNET_TESTBED_peer_stop (peer); |
@@ -208,15 +210,17 @@ dht_disconnect_adapter (void *cls, void *op_result) | |||
208 | 210 | ||
209 | 211 | ||
210 | /** | 212 | /** |
211 | * Callback to be called when an operation is completed | 213 | * Callback to be called when a service connect operation is completed |
212 | * | 214 | * |
213 | * @param cls the callback closure from functions generating an operation | 215 | * @param cls the callback closure from functions generating an operation |
214 | * @param op the operation that has been finished | 216 | * @param op the operation that has been finished |
217 | * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter() | ||
215 | * @param emsg error message in case the operation has failed; will be NULL if | 218 | * @param emsg error message in case the operation has failed; will be NULL if |
216 | * operation has executed successfully. | 219 | * operation has executed successfully. |
217 | */ | 220 | */ |
218 | static void | 221 | static void |
219 | op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) | 222 | service_connect_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, |
223 | void *ca_result, const char *emsg) | ||
220 | { | 224 | { |
221 | switch (sub_test) | 225 | switch (sub_test) |
222 | { | 226 | { |
@@ -224,8 +228,9 @@ op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) | |||
224 | GNUNET_assert (operation == op); | 228 | GNUNET_assert (operation == op); |
225 | GNUNET_assert (NULL == emsg); | 229 | GNUNET_assert (NULL == emsg); |
226 | GNUNET_assert (NULL == cls); | 230 | GNUNET_assert (NULL == cls); |
231 | GNUNET_assert (ca_result == dht_handle); | ||
227 | GNUNET_TESTBED_operation_done (operation); /* This results in call to | 232 | GNUNET_TESTBED_operation_done (operation); /* This results in call to |
228 | * disconnect adapter */ | 233 | * disconnect adapter */ |
229 | break; | 234 | break; |
230 | default: | 235 | default: |
231 | GNUNET_assert (0); | 236 | GNUNET_assert (0); |
@@ -233,6 +238,7 @@ op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) | |||
233 | } | 238 | } |
234 | 239 | ||
235 | 240 | ||
241 | |||
236 | /** | 242 | /** |
237 | * Callback to be called when the requested peer information is available | 243 | * Callback to be called when the requested peer information is available |
238 | * | 244 | * |
@@ -307,7 +313,8 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
307 | GNUNET_assert (OTHER == sub_test); | 313 | GNUNET_assert (OTHER == sub_test); |
308 | GNUNET_TESTBED_operation_done (operation); | 314 | GNUNET_TESTBED_operation_done (operation); |
309 | operation = | 315 | operation = |
310 | GNUNET_TESTBED_service_connect (NULL, peer, "dht", &op_comp_cb, NULL, | 316 | GNUNET_TESTBED_service_connect (NULL, peer, "dht", |
317 | &service_connect_comp_cb, NULL, | ||
311 | &dht_connect_adapter, | 318 | &dht_connect_adapter, |
312 | &dht_disconnect_adapter, NULL); | 319 | &dht_disconnect_adapter, NULL); |
313 | GNUNET_assert (NULL != operation); | 320 | GNUNET_assert (NULL != operation); |