diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-08-17 14:54:29 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-08-17 14:54:29 +0000 |
commit | 14c98ff17a8b1e4db1e6445f6116b7be5b4b8934 (patch) | |
tree | f08a66a8d151a4d0a16641cfcd5b0b8152bce24f /src/testbed | |
parent | d6f2d6cd9b3a14e9dc7cea1e5d1863d6d59af0af (diff) | |
download | gnunet-14c98ff17a8b1e4db1e6445f6116b7be5b4b8934.tar.gz gnunet-14c98ff17a8b1e4db1e6445f6116b7be5b4b8934.zip |
controller link as operation
Diffstat (limited to 'src/testbed')
-rw-r--r-- | src/testbed/gnunet-service-testbed.c | 91 | ||||
-rw-r--r-- | src/testbed/test_testbed_api_controllerlink.c | 34 | ||||
-rw-r--r-- | src/testbed/testbed.h | 5 | ||||
-rw-r--r-- | src/testbed/testbed_api.c | 90 | ||||
-rw-r--r-- | src/testbed/testbed_api.h | 17 | ||||
-rw-r--r-- | src/testbed/testbed_api_peers.c | 6 |
6 files changed, 184 insertions, 59 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index c9f8436e6..07a8aa714 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c | |||
@@ -470,6 +470,29 @@ struct ForwardedOperationContext | |||
470 | 470 | ||
471 | 471 | ||
472 | /** | 472 | /** |
473 | * Context information used while linking controllers | ||
474 | */ | ||
475 | struct LinkControllersContext | ||
476 | { | ||
477 | /** | ||
478 | * The client which initiated the link controller operation | ||
479 | */ | ||
480 | struct GNUNET_SERVER_Client *client; | ||
481 | |||
482 | /** | ||
483 | * The ID of the operation | ||
484 | */ | ||
485 | uint64_t operation_id; | ||
486 | |||
487 | /** | ||
488 | * Pointer to the slave handle if we are directly starting/connecting to the controller | ||
489 | */ | ||
490 | struct Slave *slave; | ||
491 | }; | ||
492 | |||
493 | |||
494 | |||
495 | /** | ||
473 | * The master context; generated with the first INIT message | 496 | * The master context; generated with the first INIT message |
474 | */ | 497 | */ |
475 | static struct Context *master_context; | 498 | static struct Context *master_context; |
@@ -978,6 +1001,29 @@ slave_event_callback(void *cls, | |||
978 | 1001 | ||
979 | 1002 | ||
980 | /** | 1003 | /** |
1004 | * Function to send generic operation success message to given client | ||
1005 | * | ||
1006 | * @param client the client to send the message to | ||
1007 | * @param operation_id the id of the operation which was successful | ||
1008 | */ | ||
1009 | static void | ||
1010 | send_operation_success_msg (struct GNUNET_SERVER_Client *client, | ||
1011 | uint64_t operation_id) | ||
1012 | { | ||
1013 | struct GNUNET_TESTBED_GenericOperationSuccessEventMessage *msg; | ||
1014 | uint16_t msize; | ||
1015 | |||
1016 | msize = sizeof (struct GNUNET_TESTBED_GenericOperationSuccessEventMessage); | ||
1017 | msg = GNUNET_malloc (msize); | ||
1018 | msg->header.size = htons (msize); | ||
1019 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GENERICOPSUCCESS); | ||
1020 | msg->operation_id = GNUNET_htonll (operation_id); | ||
1021 | msg->event_type = htonl (GNUNET_TESTBED_ET_OPERATION_FINISHED); | ||
1022 | queue_message (client, &msg->header); | ||
1023 | } | ||
1024 | |||
1025 | |||
1026 | /** | ||
981 | * Callback to signal successfull startup of the controller process | 1027 | * Callback to signal successfull startup of the controller process |
982 | * | 1028 | * |
983 | * @param cls the closure from GNUNET_TESTBED_controller_start() | 1029 | * @param cls the closure from GNUNET_TESTBED_controller_start() |
@@ -991,20 +1037,27 @@ slave_status_callback (void *cls, | |||
991 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 1037 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
992 | int status) | 1038 | int status) |
993 | { | 1039 | { |
994 | struct Slave *slave = cls; | 1040 | struct LinkControllersContext *lcc = cls; |
995 | 1041 | ||
996 | if (GNUNET_SYSERR == status) | 1042 | if (GNUNET_SYSERR == status) |
997 | { | 1043 | { |
998 | slave->controller_proc = NULL; | 1044 | lcc->slave->controller_proc = NULL; |
999 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1045 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1000 | "Unexpected slave shutdown\n"); | 1046 | "Unexpected slave shutdown\n"); |
1001 | GNUNET_SCHEDULER_shutdown (); /* We too shutdown */ | 1047 | GNUNET_SCHEDULER_shutdown (); /* We too shutdown */ |
1002 | return; | 1048 | return; |
1003 | } | 1049 | } |
1004 | slave->controller = | 1050 | lcc->slave->controller = |
1005 | GNUNET_TESTBED_controller_connect (cfg, host_list[slave->host_id], | 1051 | GNUNET_TESTBED_controller_connect (cfg, host_list[lcc->slave->host_id], |
1006 | master_context->event_mask, | 1052 | master_context->event_mask, |
1007 | &slave_event_callback, slave); | 1053 | &slave_event_callback, lcc->slave); |
1054 | if (NULL != lcc->slave->controller) | ||
1055 | send_operation_success_msg (lcc->client, lcc->operation_id); | ||
1056 | else | ||
1057 | send_operation_fail_msg (lcc->client, lcc->operation_id, | ||
1058 | "Could not connect to delegated controller"); | ||
1059 | GNUNET_SERVER_client_drop (lcc->client); | ||
1060 | GNUNET_free (lcc); | ||
1008 | } | 1061 | } |
1009 | 1062 | ||
1010 | 1063 | ||
@@ -1299,7 +1352,6 @@ handle_link_controllers (void *cls, | |||
1299 | if (slave_host_id == master_context->host_id) /* Link from us */ | 1352 | if (slave_host_id == master_context->host_id) /* Link from us */ |
1300 | { | 1353 | { |
1301 | struct Slave *slave; | 1354 | struct Slave *slave; |
1302 | |||
1303 | if ((delegated_host_id < slave_list_size) && | 1355 | if ((delegated_host_id < slave_list_size) && |
1304 | (NULL != slave_list[delegated_host_id])) /* We have already added */ | 1356 | (NULL != slave_list[delegated_host_id])) /* We have already added */ |
1305 | { | 1357 | { |
@@ -1344,20 +1396,32 @@ handle_link_controllers (void *cls, | |||
1344 | } | 1396 | } |
1345 | slave = GNUNET_malloc (sizeof (struct Slave)); | 1397 | slave = GNUNET_malloc (sizeof (struct Slave)); |
1346 | slave->host_id = delegated_host_id; | 1398 | slave->host_id = delegated_host_id; |
1347 | slave_list_add (slave); | 1399 | slave_list_add (slave); |
1400 | |||
1348 | if (1 == msg->is_subordinate) | 1401 | if (1 == msg->is_subordinate) |
1349 | { | 1402 | { |
1403 | struct LinkControllersContext *lcc; | ||
1404 | lcc = GNUNET_malloc (sizeof (struct LinkControllersContext)); | ||
1405 | lcc->operation_id = GNUNET_ntohll (msg->operation_id); | ||
1406 | GNUNET_SERVER_client_keep (client); | ||
1407 | lcc->client = client; | ||
1408 | lcc->slave = slave; | ||
1350 | slave->controller_proc = | 1409 | slave->controller_proc = |
1351 | GNUNET_TESTBED_controller_start (master_context->master_ip, | 1410 | GNUNET_TESTBED_controller_start (master_context->master_ip, |
1352 | host_list[slave->host_id], | 1411 | host_list[slave->host_id], |
1353 | cfg, &slave_status_callback, | 1412 | cfg, &slave_status_callback, |
1354 | slave); | 1413 | lcc); |
1355 | } | 1414 | } |
1356 | else { | 1415 | else { |
1357 | slave->controller = | 1416 | slave->controller = |
1358 | GNUNET_TESTBED_controller_connect (cfg, host_list[slave->host_id], | 1417 | GNUNET_TESTBED_controller_connect (cfg, host_list[slave->host_id], |
1359 | master_context->event_mask, | 1418 | master_context->event_mask, |
1360 | &slave_event_callback, slave); | 1419 | &slave_event_callback, slave); |
1420 | if (NULL != slave->controller) | ||
1421 | send_operation_success_msg (client, GNUNET_ntohll (msg->operation_id)); | ||
1422 | else | ||
1423 | send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), | ||
1424 | "Could not connect to delegated controller"); | ||
1361 | } | 1425 | } |
1362 | GNUNET_CONFIGURATION_destroy (cfg); | 1426 | GNUNET_CONFIGURATION_destroy (cfg); |
1363 | new_route = GNUNET_malloc (sizeof (struct Route)); | 1427 | new_route = GNUNET_malloc (sizeof (struct Route)); |
@@ -1594,10 +1658,8 @@ handle_peer_destroy (void *cls, | |||
1594 | const struct GNUNET_MessageHeader *message) | 1658 | const struct GNUNET_MessageHeader *message) |
1595 | { | 1659 | { |
1596 | const struct GNUNET_TESTBED_PeerDestroyMessage *msg; | 1660 | const struct GNUNET_TESTBED_PeerDestroyMessage *msg; |
1597 | struct GNUNET_TESTBED_GenericOperationSuccessEventMessage *reply; | ||
1598 | struct Peer *peer; | 1661 | struct Peer *peer; |
1599 | uint32_t peer_id; | 1662 | uint32_t peer_id; |
1600 | uint16_t reply_size; | ||
1601 | 1663 | ||
1602 | msg = (const struct GNUNET_TESTBED_PeerDestroyMessage *) message; | 1664 | msg = (const struct GNUNET_TESTBED_PeerDestroyMessage *) message; |
1603 | peer_id = ntohl (msg->peer_id); | 1665 | peer_id = ntohl (msg->peer_id); |
@@ -1622,14 +1684,7 @@ handle_peer_destroy (void *cls, | |||
1622 | GNUNET_CONFIGURATION_destroy (peer->details.local.cfg); | 1684 | GNUNET_CONFIGURATION_destroy (peer->details.local.cfg); |
1623 | peer_list_remove (peer); | 1685 | peer_list_remove (peer); |
1624 | GNUNET_free (peer); | 1686 | GNUNET_free (peer); |
1625 | reply_size = | 1687 | send_operation_success_msg (client, GNUNET_ntohll (msg->operation_id)); |
1626 | sizeof (struct GNUNET_TESTBED_GenericOperationSuccessEventMessage); | ||
1627 | reply = GNUNET_malloc (reply_size); | ||
1628 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GENERICOPSUCCESS); | ||
1629 | reply->header.size = htons (reply_size); | ||
1630 | reply->operation_id = msg->operation_id; | ||
1631 | reply->event_type = htonl (GNUNET_TESTBED_ET_OPERATION_FINISHED); | ||
1632 | queue_message (client, &reply->header); | ||
1633 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1688 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1634 | } | 1689 | } |
1635 | 1690 | ||
diff --git a/src/testbed/test_testbed_api_controllerlink.c b/src/testbed/test_testbed_api_controllerlink.c index bda27d8cf..06b0b8029 100644 --- a/src/testbed/test_testbed_api_controllerlink.c +++ b/src/testbed/test_testbed_api_controllerlink.c | |||
@@ -105,6 +105,11 @@ static struct GNUNET_CONFIGURATION_Handle *cfg; | |||
105 | static GNUNET_SCHEDULER_TaskIdentifier abort_task; | 105 | static GNUNET_SCHEDULER_TaskIdentifier abort_task; |
106 | 106 | ||
107 | /** | 107 | /** |
108 | * Operation handle for linking controllers | ||
109 | */ | ||
110 | static struct GNUNET_TESTBED_Operation *op; | ||
111 | |||
112 | /** | ||
108 | * Event mask | 113 | * Event mask |
109 | */ | 114 | */ |
110 | uint64_t event_mask; | 115 | uint64_t event_mask; |
@@ -167,7 +172,25 @@ do_abort (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
167 | static void | 172 | static void |
168 | controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) | 173 | controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) |
169 | { | 174 | { |
170 | GNUNET_assert (0); | 175 | switch (result) |
176 | { | ||
177 | case SLAVE1_REGISTERED: | ||
178 | GNUNET_assert (NULL != event); | ||
179 | GNUNET_assert (GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type); | ||
180 | GNUNET_assert (event->details.operation_finished.operation == op); | ||
181 | GNUNET_assert (NULL == event->details.operation_finished.op_cls); | ||
182 | GNUNET_assert (NULL == event->details.operation_finished.emsg); | ||
183 | GNUNET_assert (GNUNET_TESTBED_PIT_GENERIC == | ||
184 | event->details.operation_finished.pit); | ||
185 | GNUNET_assert (NULL == event->details.operation_finished.op_result.generic); | ||
186 | GNUNET_TESTBED_operation_done (op); | ||
187 | op = NULL; | ||
188 | result = SUCCESS; | ||
189 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
190 | break; | ||
191 | default: | ||
192 | GNUNET_assert (0); | ||
193 | } | ||
171 | } | 194 | } |
172 | 195 | ||
173 | 196 | ||
@@ -188,11 +211,8 @@ registration_cont (void *cls, const char *emsg) | |||
188 | GNUNET_assert (NULL != mc); | 211 | GNUNET_assert (NULL != mc); |
189 | result = SLAVE1_REGISTERED; | 212 | result = SLAVE1_REGISTERED; |
190 | GNUNET_assert (NULL != cfg); | 213 | GNUNET_assert (NULL != cfg); |
191 | GNUNET_TESTBED_controller_link (mc, slave, NULL, cfg, GNUNET_YES); | 214 | op = GNUNET_TESTBED_controller_link (mc, slave, NULL, cfg, GNUNET_YES); |
192 | result = SUCCESS; | 215 | GNUNET_assert (NULL != op); |
193 | GNUNET_SCHEDULER_add_delayed | ||
194 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), | ||
195 | &do_shutdown, NULL); | ||
196 | break; | 216 | break; |
197 | case INIT: | 217 | case INIT: |
198 | case SUCCESS: | 218 | case SUCCESS: |
@@ -256,7 +276,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
256 | cp = | 276 | cp = |
257 | GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, NULL); | 277 | GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, NULL); |
258 | abort_task = GNUNET_SCHEDULER_add_delayed | 278 | abort_task = GNUNET_SCHEDULER_add_delayed |
259 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30), | 279 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5), |
260 | &do_abort, NULL); | 280 | &do_abort, NULL); |
261 | } | 281 | } |
262 | 282 | ||
diff --git a/src/testbed/testbed.h b/src/testbed/testbed.h index b6a0e30cc..c7848135d 100644 --- a/src/testbed/testbed.h +++ b/src/testbed/testbed.h | |||
@@ -166,6 +166,11 @@ struct GNUNET_TESTBED_ControllerLinkMessage | |||
166 | uint32_t delegated_host_id GNUNET_PACKED; | 166 | uint32_t delegated_host_id GNUNET_PACKED; |
167 | 167 | ||
168 | /** | 168 | /** |
169 | * The id of the operation which created this message | ||
170 | */ | ||
171 | uint64_t operation_id GNUNET_PACKED; | ||
172 | |||
173 | /** | ||
169 | * Which host is responsible for managing the delegation? NBO | 174 | * Which host is responsible for managing the delegation? NBO |
170 | */ | 175 | */ |
171 | uint32_t slave_host_id GNUNET_PACKED; | 176 | uint32_t slave_host_id GNUNET_PACKED; |
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index afac22fba..f2431c630 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c | |||
@@ -285,25 +285,26 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c, | |||
285 | { | 285 | { |
286 | case OP_PEER_DESTROY: | 286 | case OP_PEER_DESTROY: |
287 | { | 287 | { |
288 | struct GNUNET_TESTBED_Peer *peer; | 288 | struct GNUNET_TESTBED_Peer *peer; |
289 | |||
290 | if (NULL != event) | ||
291 | { | ||
292 | event->details.operation_finished.operation = opc->op; | ||
293 | event->details.operation_finished.op_cls = NULL; | ||
294 | event->details.operation_finished.emsg = NULL; | ||
295 | event->details.operation_finished.pit = GNUNET_TESTBED_PIT_GENERIC; | ||
296 | event->details.operation_finished.op_result.generic = NULL; | ||
297 | } | ||
298 | peer = opc->data; | 289 | peer = opc->data; |
299 | GNUNET_free (peer); | 290 | GNUNET_free (peer); |
300 | opc->data = NULL; | 291 | opc->data = NULL; |
301 | //PEERDESTROYDATA | 292 | //PEERDESTROYDATA |
302 | } | 293 | } |
303 | break; | 294 | break; |
295 | case OP_LINK_CONTROLLERS: | ||
296 | break; | ||
304 | default: | 297 | default: |
305 | GNUNET_assert (0); | 298 | GNUNET_assert (0); |
306 | } | 299 | } |
300 | if (NULL != event) | ||
301 | { | ||
302 | event->details.operation_finished.operation = opc->op; | ||
303 | event->details.operation_finished.op_cls = NULL; | ||
304 | event->details.operation_finished.emsg = NULL; | ||
305 | event->details.operation_finished.pit = GNUNET_TESTBED_PIT_GENERIC; | ||
306 | event->details.operation_finished.op_result.generic = NULL; | ||
307 | } | ||
307 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 308 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
308 | opc->state = OPC_STATE_FINISHED; | 309 | opc->state = OPC_STATE_FINISHED; |
309 | if (NULL != event) | 310 | if (NULL != event) |
@@ -953,6 +954,45 @@ helper_exp_cb (void *cls) | |||
953 | 954 | ||
954 | 955 | ||
955 | /** | 956 | /** |
957 | * Function to call to start a link-controllers type operation once all queues | ||
958 | * the operation is part of declare that the operation can be activated. | ||
959 | * | ||
960 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | ||
961 | */ | ||
962 | static void | ||
963 | opstart_link_controllers (void *cls) | ||
964 | { | ||
965 | struct OperationContext *opc = cls; | ||
966 | struct GNUNET_TESTBED_ControllerLinkMessage *msg; | ||
967 | |||
968 | GNUNET_assert (NULL != opc->data); | ||
969 | msg = opc->data; | ||
970 | opc->data = NULL; | ||
971 | opc->state = OPC_STATE_STARTED; | ||
972 | GNUNET_CONTAINER_DLL_insert_tail (opc->c->ocq_head, opc->c->ocq_tail, opc); | ||
973 | GNUNET_TESTBED_queue_message_ (opc->c, &msg->header); | ||
974 | } | ||
975 | |||
976 | |||
977 | /** | ||
978 | * Callback which will be called when link-controllers type operation is released | ||
979 | * | ||
980 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | ||
981 | */ | ||
982 | static void | ||
983 | oprelease_link_controllers (void *cls) | ||
984 | { | ||
985 | struct OperationContext *opc = cls; | ||
986 | |||
987 | if (OPC_STATE_INIT == opc->state) | ||
988 | GNUNET_free (opc->data); | ||
989 | if (OPC_STATE_STARTED == opc->state) | ||
990 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | ||
991 | GNUNET_free (opc); | ||
992 | } | ||
993 | |||
994 | |||
995 | /** | ||
956 | * Starts a controller process at the host. FIXME: add controller start callback | 996 | * Starts a controller process at the host. FIXME: add controller start callback |
957 | * with the configuration with which the controller is started | 997 | * with the configuration with which the controller is started |
958 | * | 998 | * |
@@ -1320,7 +1360,7 @@ GNUNET_TESTBED_cancel_registration (struct GNUNET_TESTBED_HostRegistrationHandle | |||
1320 | * be started by the master controller; GNUNET_NO if we are just | 1360 | * be started by the master controller; GNUNET_NO if we are just |
1321 | * allowed to use the slave via TCP/IP | 1361 | * allowed to use the slave via TCP/IP |
1322 | */ | 1362 | */ |
1323 | void | 1363 | struct GNUNET_TESTBED_Operation * |
1324 | GNUNET_TESTBED_controller_link_2 (struct GNUNET_TESTBED_Controller *master, | 1364 | GNUNET_TESTBED_controller_link_2 (struct GNUNET_TESTBED_Controller *master, |
1325 | struct GNUNET_TESTBED_Host *delegated_host, | 1365 | struct GNUNET_TESTBED_Host *delegated_host, |
1326 | struct GNUNET_TESTBED_Host *slave_host, | 1366 | struct GNUNET_TESTBED_Host *slave_host, |
@@ -1329,6 +1369,7 @@ GNUNET_TESTBED_controller_link_2 (struct GNUNET_TESTBED_Controller *master, | |||
1329 | size_t scfg_size, | 1369 | size_t scfg_size, |
1330 | int is_subordinate) | 1370 | int is_subordinate) |
1331 | { | 1371 | { |
1372 | struct OperationContext *opc; | ||
1332 | struct GNUNET_TESTBED_ControllerLinkMessage *msg; | 1373 | struct GNUNET_TESTBED_ControllerLinkMessage *msg; |
1333 | uint16_t msg_size; | 1374 | uint16_t msg_size; |
1334 | 1375 | ||
@@ -1347,7 +1388,17 @@ GNUNET_TESTBED_controller_link_2 (struct GNUNET_TESTBED_Controller *master, | |||
1347 | msg->config_size = htons ((uint16_t) scfg_size); | 1388 | msg->config_size = htons ((uint16_t) scfg_size); |
1348 | msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0; | 1389 | msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0; |
1349 | memcpy (&msg[1], sxcfg, sxcfg_size); | 1390 | memcpy (&msg[1], sxcfg, sxcfg_size); |
1350 | GNUNET_TESTBED_queue_message_ (master, (struct GNUNET_MessageHeader *) msg); | 1391 | opc = GNUNET_malloc (sizeof (struct OperationContext)); |
1392 | opc->c = master; | ||
1393 | opc->data = msg; | ||
1394 | opc->type = OP_LINK_CONTROLLERS; | ||
1395 | opc->id = master->operation_counter++; | ||
1396 | opc->state = OPC_STATE_INIT; | ||
1397 | msg->operation_id = GNUNET_htonll (opc->id); | ||
1398 | opc->op = GNUNET_TESTBED_operation_create_ (opc, &opstart_link_controllers, | ||
1399 | &oprelease_link_controllers); | ||
1400 | GNUNET_TESTBED_operation_queue_insert_ (master->opq_peer_create, opc->op); | ||
1401 | return opc->op; | ||
1351 | } | 1402 | } |
1352 | 1403 | ||
1353 | 1404 | ||
@@ -1395,23 +1446,25 @@ GNUNET_TESTBED_compress_config_ (const char *config, size_t size, | |||
1395 | * @param is_subordinate GNUNET_YES if the slave should be started (and stopped) | 1446 | * @param is_subordinate GNUNET_YES if the slave should be started (and stopped) |
1396 | * by the master controller; GNUNET_NO if we are just | 1447 | * by the master controller; GNUNET_NO if we are just |
1397 | * allowed to use the slave via TCP/IP | 1448 | * allowed to use the slave via TCP/IP |
1449 | * @return the operation handle | ||
1398 | */ | 1450 | */ |
1399 | void | 1451 | struct GNUNET_TESTBED_Operation * |
1400 | GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master, | 1452 | GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master, |
1401 | struct GNUNET_TESTBED_Host *delegated_host, | 1453 | struct GNUNET_TESTBED_Host *delegated_host, |
1402 | struct GNUNET_TESTBED_Host *slave_host, | 1454 | struct GNUNET_TESTBED_Host *slave_host, |
1403 | const struct GNUNET_CONFIGURATION_Handle *slave_cfg, | 1455 | const struct GNUNET_CONFIGURATION_Handle *slave_cfg, |
1404 | int is_subordinate) | 1456 | int is_subordinate) |
1405 | { | 1457 | { |
1458 | struct GNUNET_TESTBED_Operation *op; | ||
1406 | char *config; | 1459 | char *config; |
1407 | char *cconfig; | 1460 | char *cconfig; |
1408 | size_t cc_size; | 1461 | size_t cc_size; |
1409 | size_t config_size; | 1462 | size_t config_size; |
1410 | 1463 | ||
1411 | GNUNET_assert (GNUNET_YES == | 1464 | GNUNET_assert (GNUNET_YES == |
1412 | GNUNET_TESTBED_is_host_registered_ (delegated_host, master)); | 1465 | GNUNET_TESTBED_is_host_registered_ (delegated_host, master)); |
1413 | if ((NULL != slave_host) && (0 != GNUNET_TESTBED_host_get_id_ (slave_host))) | 1466 | if ((NULL != slave_host) && (0 != GNUNET_TESTBED_host_get_id_ (slave_host))) |
1414 | GNUNET_assert (GNUNET_YES == | 1467 | GNUNET_assert (GNUNET_YES == |
1415 | GNUNET_TESTBED_is_host_registered_ (slave_host, master)); | 1468 | GNUNET_TESTBED_is_host_registered_ (slave_host, master)); |
1416 | config = GNUNET_CONFIGURATION_serialize (slave_cfg, &config_size); | 1469 | config = GNUNET_CONFIGURATION_serialize (slave_cfg, &config_size); |
1417 | cc_size = GNUNET_TESTBED_compress_config_ (config, config_size, &cconfig); | 1470 | cc_size = GNUNET_TESTBED_compress_config_ (config, config_size, &cconfig); |
@@ -1419,10 +1472,11 @@ GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master, | |||
1419 | GNUNET_assert ((UINT16_MAX - | 1472 | GNUNET_assert ((UINT16_MAX - |
1420 | sizeof (struct GNUNET_TESTBED_ControllerLinkMessage)) | 1473 | sizeof (struct GNUNET_TESTBED_ControllerLinkMessage)) |
1421 | >= cc_size); /* Configuration doesn't fit in 1 message */ | 1474 | >= cc_size); /* Configuration doesn't fit in 1 message */ |
1422 | GNUNET_TESTBED_controller_link_2 (master, delegated_host, slave_host, | 1475 | op = GNUNET_TESTBED_controller_link_2 (master, delegated_host, slave_host, |
1423 | (const char *) cconfig, | 1476 | (const char *) cconfig, |
1424 | cc_size, config_size, is_subordinate); | 1477 | cc_size, config_size, is_subordinate); |
1425 | GNUNET_free (cconfig); | 1478 | GNUNET_free (cconfig); |
1479 | return op; | ||
1426 | } | 1480 | } |
1427 | 1481 | ||
1428 | 1482 | ||
@@ -1495,9 +1549,6 @@ GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, | |||
1495 | void | 1549 | void |
1496 | GNUNET_TESTBED_operation_cancel (struct GNUNET_TESTBED_Operation *operation) | 1550 | GNUNET_TESTBED_operation_cancel (struct GNUNET_TESTBED_Operation *operation) |
1497 | { | 1551 | { |
1498 | GNUNET_CONTAINER_DLL_remove (operation->controller->op_head, | ||
1499 | operation->controller->op_tail, | ||
1500 | operation); | ||
1501 | GNUNET_TESTBED_operation_done (operation); | 1552 | GNUNET_TESTBED_operation_done (operation); |
1502 | } | 1553 | } |
1503 | 1554 | ||
@@ -1522,6 +1573,7 @@ GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation) | |||
1522 | case OP_PEER_STOP: | 1573 | case OP_PEER_STOP: |
1523 | case OP_PEER_INFO: | 1574 | case OP_PEER_INFO: |
1524 | case OP_OVERLAY_CONNECT: | 1575 | case OP_OVERLAY_CONNECT: |
1576 | case OP_LINK_CONTROLLERS: | ||
1525 | GNUNET_TESTBED_operation_release_ (operation); | 1577 | GNUNET_TESTBED_operation_release_ (operation); |
1526 | return; | 1578 | return; |
1527 | default: | 1579 | default: |
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h index a8cb383fa..625f3d1f6 100644 --- a/src/testbed/testbed_api.h +++ b/src/testbed/testbed_api.h | |||
@@ -66,7 +66,12 @@ enum OperationType | |||
66 | /** | 66 | /** |
67 | * Forwarded operation | 67 | * Forwarded operation |
68 | */ | 68 | */ |
69 | OP_FORWARDED | 69 | OP_FORWARDED, |
70 | |||
71 | /** | ||
72 | * Link controllers operation | ||
73 | */ | ||
74 | OP_LINK_CONTROLLERS, | ||
70 | 75 | ||
71 | }; | 76 | }; |
72 | 77 | ||
@@ -260,16 +265,6 @@ struct GNUNET_TESTBED_Controller | |||
260 | struct GNUNET_TESTBED_HostRegistrationHandle *rh; | 265 | struct GNUNET_TESTBED_HostRegistrationHandle *rh; |
261 | 266 | ||
262 | /** | 267 | /** |
263 | * The head of the operation queue (FIXME: Remove, use ocq) | ||
264 | */ | ||
265 | struct GNUNET_TESTBED_Operation *op_head; | ||
266 | |||
267 | /** | ||
268 | * The tail of the operation queue (FIXME: Remove, use ocq) | ||
269 | */ | ||
270 | struct GNUNET_TESTBED_Operation *op_tail; | ||
271 | |||
272 | /** | ||
273 | * The head of the opeartion context queue | 268 | * The head of the opeartion context queue |
274 | */ | 269 | */ |
275 | struct OperationContext *ocq_head; | 270 | struct OperationContext *ocq_head; |
diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c index 380190578..51ef66bec 100644 --- a/src/testbed/testbed_api_peers.c +++ b/src/testbed/testbed_api_peers.c | |||
@@ -69,10 +69,8 @@ opstart_peer_create (void *cls) | |||
69 | msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (data->peer->host)); | 69 | msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (data->peer->host)); |
70 | msg->peer_id = htonl (data->peer->unique_id); | 70 | msg->peer_id = htonl (data->peer->unique_id); |
71 | msg->config_size = htonl (c_size); | 71 | msg->config_size = htonl (c_size); |
72 | GNUNET_CONTAINER_DLL_insert_tail (opc->c->ocq_head, | 72 | GNUNET_CONTAINER_DLL_insert_tail (opc->c->ocq_head, opc->c->ocq_tail, opc); |
73 | opc->c->ocq_tail, opc); | 73 | GNUNET_TESTBED_queue_message_ (opc->c, &msg->header); |
74 | GNUNET_TESTBED_queue_message_ (opc->c, | ||
75 | (struct GNUNET_MessageHeader *) msg); | ||
76 | }; | 74 | }; |
77 | 75 | ||
78 | 76 | ||