aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-09-05 11:44:56 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-09-05 11:44:56 +0000
commit1744330ca7033f849bf486188bf125a2b3818498 (patch)
treedce611a6df10def20b3ebbc44ab6ebe149f43137 /src
parent270a6392703fe1cb99f69ed8a35c1be0c864b11f (diff)
downloadgnunet-1744330ca7033f849bf486188bf125a2b3818498.tar.gz
gnunet-1744330ca7033f849bf486188bf125a2b3818498.zip
service connect callback instead of operation completion callback
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_testbed_service.h21
-rw-r--r--src/testbed/test_testbed_api.c19
-rw-r--r--src/testbed/testbed_api_services.c6
3 files changed, 36 insertions, 10 deletions
diff --git a/src/include/gnunet_testbed_service.h b/src/include/gnunet_testbed_service.h
index 249b40752..92a7beb40 100644
--- a/src/include/gnunet_testbed_service.h
+++ b/src/include/gnunet_testbed_service.h
@@ -1041,6 +1041,25 @@ typedef void (*GNUNET_TESTBED_DisconnectAdapter)(void *cls,
1041 1041
1042 1042
1043/** 1043/**
1044 * Callback to be called when a service connect operation is completed
1045 *
1046 * @param cls the callback closure from functions generating an operation
1047 * @param op the operation that has been finished
1048 * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
1049 * @param emsg error message in case the operation has failed; will be NULL if
1050 * operation has executed successfully.
1051 */
1052typedef void (*GNUNET_TESTBED_ServiceConnectCompletionCallback) (void *cls,
1053 struct
1054 GNUNET_TESTBED_Operation
1055 *op,
1056 void
1057 *ca_result,
1058 const char
1059 *emsg );
1060
1061
1062/**
1044 * Connect to a service offered by the given peer. Will ensure that 1063 * Connect to a service offered by the given peer. Will ensure that
1045 * the request is queued to not overwhelm our ability to create and 1064 * the request is queued to not overwhelm our ability to create and
1046 * maintain connections with other systems. The actual service 1065 * maintain connections with other systems. The actual service
@@ -1065,7 +1084,7 @@ struct GNUNET_TESTBED_Operation *
1065GNUNET_TESTBED_service_connect (void *op_cls, 1084GNUNET_TESTBED_service_connect (void *op_cls,
1066 struct GNUNET_TESTBED_Peer *peer, 1085 struct GNUNET_TESTBED_Peer *peer,
1067 const char *service_name, 1086 const char *service_name,
1068 GNUNET_TESTBED_OperationCompletionCallback cb, 1087 GNUNET_TESTBED_ServiceConnectCompletionCallback cb,
1069 void *cb_cls, 1088 void *cb_cls,
1070 GNUNET_TESTBED_ConnectAdapter ca, 1089 GNUNET_TESTBED_ConnectAdapter ca,
1071 GNUNET_TESTBED_DisconnectAdapter da, 1090 GNUNET_TESTBED_DisconnectAdapter da,
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)
198static void 198static void
199dht_disconnect_adapter (void *cls, void *op_result) 199dht_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 */
218static void 221static void
219op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) 222service_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);
diff --git a/src/testbed/testbed_api_services.c b/src/testbed/testbed_api_services.c
index 3e8484022..861b35917 100644
--- a/src/testbed/testbed_api_services.c
+++ b/src/testbed/testbed_api_services.c
@@ -110,7 +110,7 @@ struct ServiceConnectData
110 /** 110 /**
111 * The operation completion callback 111 * The operation completion callback
112 */ 112 */
113 GNUNET_TESTBED_OperationCompletionCallback cb; 113 GNUNET_TESTBED_ServiceConnectCompletionCallback cb;
114 114
115 /** 115 /**
116 * The closure for operation completion callback 116 * The closure for operation completion callback
@@ -161,7 +161,7 @@ configuration_receiver (void *cls, const struct GNUNET_MessageHeader *msg)
161 (NULL != c->cc)) 161 (NULL != c->cc))
162 c->cc (c->cc_cls, &info); 162 c->cc (c->cc_cls, &info);
163 if (NULL != data->cb) 163 if (NULL != data->cb)
164 data->cb (data->cb_cls, data->operation, NULL); 164 data->cb (data->cb_cls, data->operation, data->op_result, NULL);
165} 165}
166 166
167 167
@@ -247,7 +247,7 @@ struct GNUNET_TESTBED_Operation *
247GNUNET_TESTBED_service_connect (void *op_cls, 247GNUNET_TESTBED_service_connect (void *op_cls,
248 struct GNUNET_TESTBED_Peer *peer, 248 struct GNUNET_TESTBED_Peer *peer,
249 const char *service_name, 249 const char *service_name,
250 GNUNET_TESTBED_OperationCompletionCallback cb, 250 GNUNET_TESTBED_ServiceConnectCompletionCallback cb,
251 void *cb_cls, 251 void *cb_cls,
252 GNUNET_TESTBED_ConnectAdapter ca, 252 GNUNET_TESTBED_ConnectAdapter ca,
253 GNUNET_TESTBED_DisconnectAdapter da, 253 GNUNET_TESTBED_DisconnectAdapter da,