[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24184 - in gnunet/src: include testbed
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24184 - in gnunet/src: include testbed |
Date: |
Thu, 4 Oct 2012 16:02:44 +0200 |
Author: harsha
Date: 2012-10-04 16:02:44 +0200 (Thu, 04 Oct 2012)
New Revision: 24184
Modified:
gnunet/src/include/gnunet_testbed_service.h
gnunet/src/testbed/test_testbed_api_3peers_3controllers.c
gnunet/src/testbed/test_testbed_api_controllerlink.c
gnunet/src/testbed/testbed_api.c
Log:
added operation closure to GNUNET_TESTBED_controller_link()
Modified: gnunet/src/include/gnunet_testbed_service.h
===================================================================
--- gnunet/src/include/gnunet_testbed_service.h 2012-10-04 13:54:33 UTC (rev
24183)
+++ gnunet/src/include/gnunet_testbed_service.h 2012-10-04 14:02:44 UTC (rev
24184)
@@ -543,28 +543,37 @@
* master controller is asked to start a peer at the delegated controller the
* request will be routed towards slave controller (if a route exists). The
* slave controller will then route it to the delegated controller. The
- * configuration of the slave controller is given and to be used to either
- * create the slave controller or to connect to an existing slave controller
- * process. 'is_subordinate' specifies if the given slave controller should be
- * started and managed by the master controller, or if the slave already has a
- * master and this is just a secondary master that is also allowed to use the
- * existing slave.
+ * configuration of the delegated controller is given and is used to either
+ * create the delegated controller or to connect to an existing controller.
Note
+ * that while starting the delegated controller the configuration will be
+ * modified to accommodate available free ports. the 'is_subordinate'
specifies
+ * if the given delegated controller should be started and managed by the slave
+ * controller, or if the delegated controller already has a master and the
slave
+ * controller connects to it as a non master controller. The success or failure
+ * of this operation will be signalled through the
+ * GNUNET_TESTBED_ControllerCallback() with an event of type
+ * GNUNET_TESTBED_ET_OPERATION_FINISHED
*
+ * @param op_cls the operation closure for the event which is generated to
+ * signal success or failure of this operation
* @param master handle to the master controller who creates the association
* @param delegated_host requests to which host should be delegated; cannot be
NULL
* @param slave_host which host is used to run the slave controller; use NULL
to
* make the master controller connect to the delegated host
* @param slave_cfg configuration to use for the slave controller
* @param is_subordinate GNUNET_YES if the controller at delegated_host should
- * be started by the master controller; GNUNET_NO if we are just
- * allowed to use the slave via TCP/IP
+ * be started by the slave controller; GNUNET_NO if the slave
+ * controller has to connect to the already started delegated
+ * controller via TCP/IP
* @return the operation handle
*/
struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master,
+GNUNET_TESTBED_controller_link (void *op_cls,
+ struct GNUNET_TESTBED_Controller *master,
struct GNUNET_TESTBED_Host *delegated_host,
struct GNUNET_TESTBED_Host *slave_host,
- const struct GNUNET_CONFIGURATION_Handle
*slave_cfg,
+ const struct GNUNET_CONFIGURATION_Handle
+ *slave_cfg,
int is_subordinate);
@@ -572,6 +581,8 @@
* Same as the GNUNET_TESTBED_controller_link, however expects configuration in
* serialized and compressed
*
+ * @param op_cls the operation closure for the event which is generated to
+ * signal success or failure of this operation
* @param master handle to the master controller who creates the association
* @param delegated_host requests to which host should be delegated; cannot be
NULL
* @param slave_host which host is used to run the slave controller; use NULL
to
@@ -580,12 +591,14 @@
* @param sxcfg_size the size sxcfg
* @param scfg_size the size of uncompressed serialized configuration
* @param is_subordinate GNUNET_YES if the controller at delegated_host should
- * be started by the master controller; GNUNET_NO if we are just
- * allowed to use the slave via TCP/IP
+ * be started by the slave controller; GNUNET_NO if the slave
+ * controller has to connect to the already started delegated
+ * controller via TCP/IP
* @return the operation handle
*/
struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_controller_link_2 (struct GNUNET_TESTBED_Controller *master,
+GNUNET_TESTBED_controller_link_2 (void *op_cls,
+ struct GNUNET_TESTBED_Controller *master,
struct GNUNET_TESTBED_Host *delegated_host,
struct GNUNET_TESTBED_Host *slave_host,
const char *sxcfg,
Modified: gnunet/src/testbed/test_testbed_api_3peers_3controllers.c
===================================================================
--- gnunet/src/testbed/test_testbed_api_3peers_3controllers.c 2012-10-04
13:54:33 UTC (rev 24183)
+++ gnunet/src/testbed/test_testbed_api_3peers_3controllers.c 2012-10-04
14:02:44 UTC (rev 24184)
@@ -509,7 +509,7 @@
GNUNET_TESTBED_operation_done (common_operation);
result = CONTROLLER_CFG_ACQUIRED;
common_operation =
- GNUNET_TESTBED_controller_link (controller1, neighbour2, neighbour1,
+ GNUNET_TESTBED_controller_link (NULL, controller1, neighbour2,
neighbour1,
cfg2, GNUNET_NO);
break;
case CONTROLLER_CFG_ACQUIRED:
@@ -534,7 +534,7 @@
peer1.operation = NULL;
result = PEER1_STARTED;
common_operation =
- GNUNET_TESTBED_controller_link (controller1, neighbour1, NULL, cfg,
+ GNUNET_TESTBED_controller_link (NULL, controller1, neighbour1, NULL,
cfg,
GNUNET_YES);
break;
case PEER2_CREATED:
@@ -545,7 +545,7 @@
result = PEER2_STARTED;
GNUNET_assert (NULL == common_operation);
common_operation =
- GNUNET_TESTBED_controller_link (controller1, neighbour2, NULL, cfg,
+ GNUNET_TESTBED_controller_link (NULL, controller1, neighbour2, NULL,
cfg,
GNUNET_YES);
GNUNET_assert (NULL != common_operation);
break;
Modified: gnunet/src/testbed/test_testbed_api_controllerlink.c
===================================================================
--- gnunet/src/testbed/test_testbed_api_controllerlink.c 2012-10-04
13:54:33 UTC (rev 24183)
+++ gnunet/src/testbed/test_testbed_api_controllerlink.c 2012-10-04
14:02:44 UTC (rev 24184)
@@ -400,7 +400,7 @@
result = SLAVE1_LINK_SUCCESS;
GNUNET_assert (NULL != slave2);
GNUNET_assert (NULL != slave);
- op = GNUNET_TESTBED_controller_link (mc, slave2, slave, cfg, GNUNET_YES);
+ op = GNUNET_TESTBED_controller_link (NULL, mc, slave2, slave, cfg,
GNUNET_YES);
GNUNET_assert (NULL != op);
break;
case SLAVE1_LINK_SUCCESS:
@@ -479,7 +479,7 @@
cfg3 = GNUNET_CONFIGURATION_dup
(event->details.operation_finished.generic);
GNUNET_TESTBED_operation_done (op);
result = SLAVE3_GET_CONFIG_SUCCESS;
- op = GNUNET_TESTBED_controller_link (mc, slave3, slave, cfg3, GNUNET_NO);
+ op = GNUNET_TESTBED_controller_link (NULL, mc, slave3, slave, cfg3,
GNUNET_NO);
break;
case SLAVE3_GET_CONFIG_SUCCESS:
result = SLAVE3_LINK_SUCCESS;
@@ -520,7 +520,7 @@
GNUNET_assert (NULL != mc);
result = SLAVE2_REGISTERED;
GNUNET_assert (NULL != cfg);
- op = GNUNET_TESTBED_controller_link (mc, slave, NULL, cfg, GNUNET_YES);
+ op = GNUNET_TESTBED_controller_link (NULL, mc, slave, NULL, cfg,
GNUNET_YES);
GNUNET_assert (NULL != op);
break;
case SLAVE2_PEER_DESTROY_SUCCESS:
@@ -528,7 +528,7 @@
GNUNET_assert (NULL != mc);
GNUNET_assert (NULL == op);
result = SLAVE3_REGISTERED;
- op = GNUNET_TESTBED_controller_link (mc, slave3, NULL, cfg, GNUNET_YES);
+ op = GNUNET_TESTBED_controller_link (NULL, mc, slave3, NULL, cfg,
GNUNET_YES);
GNUNET_assert (NULL != op);
break;
default:
Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c 2012-10-04 13:54:33 UTC (rev 24183)
+++ gnunet/src/testbed/testbed_api.c 2012-10-04 14:02:44 UTC (rev 24184)
@@ -75,6 +75,59 @@
/**
+ * Handle for controller process
+ */
+struct GNUNET_TESTBED_ControllerProc
+{
+ /**
+ * The process handle
+ */
+ struct GNUNET_HELPER_Handle *helper;
+
+ /**
+ * The host where the helper is run
+ */
+ struct GNUNET_TESTBED_Host *host;
+
+ /**
+ * The controller error callback
+ */
+ GNUNET_TESTBED_ControllerStatusCallback cb;
+
+ /**
+ * The closure for the above callback
+ */
+ void *cls;
+
+ /**
+ * The send handle for the helper
+ */
+ struct GNUNET_HELPER_SendHandle *shandle;
+
+ /**
+ * The message corresponding to send handle
+ */
+ struct GNUNET_MessageHeader *msg;
+
+ /**
+ * The port number for ssh; used for helpers starting ssh
+ */
+ char *port;
+
+ /**
+ * The ssh destination string; used for helpers starting ssh
+ */
+ char *dst;
+
+ /**
+ * The configuration of the running testbed service
+ */
+ struct GNUNET_CONFIGURATION_Handle *cfg;
+
+};
+
+
+/**
* The message queue for sending messages to the controller service
*/
struct MessageQueue
@@ -200,6 +253,24 @@
/**
+ * Context data for controller link operations
+ */
+struct ControllerLinkData
+{
+ /**
+ * The controller link message
+ */
+ struct GNUNET_TESTBED_ControllerLinkMessage *msg;
+
+ /**
+ * The operation closure
+ */
+ void *op_cls;
+
+};
+
+
+/**
* Returns the operation context with the given id if found in the Operation
* context queues of the controller
*
@@ -324,6 +395,11 @@
LOG_DEBUG ("Operation not found\n");
return GNUNET_YES;
}
+ event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
+ event.details.operation_finished.operation = opc->op;
+ event.details.operation_finished.op_cls = NULL;
+ event.details.operation_finished.emsg = NULL;
+ event.details.operation_finished.generic = NULL;
switch (opc->type)
{
case OP_FORWARDED:
@@ -344,15 +420,19 @@
}
break;
case OP_LINK_CONTROLLERS:
+ {
+ struct ControllerLinkData *data;
+
+ data = opc->data;
+ GNUNET_assert (NULL != data);
+ event.details.operation_finished.op_cls = data->op_cls;
+ GNUNET_free (data);
+ opc->data = NULL;
+ }
break;
default:
GNUNET_assert (0);
- }
- event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
- event.details.operation_finished.operation = opc->op;
- event.details.operation_finished.op_cls = NULL;
- event.details.operation_finished.emsg = NULL;
- event.details.operation_finished.generic = NULL;
+ }
GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
opc->state = OPC_STATE_FINISHED;
if (0 != (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED)))
@@ -1032,59 +1112,6 @@
/**
- * Handle for controller process
- */
-struct GNUNET_TESTBED_ControllerProc
-{
- /**
- * The process handle
- */
- struct GNUNET_HELPER_Handle *helper;
-
- /**
- * The host where the helper is run
- */
- struct GNUNET_TESTBED_Host *host;
-
- /**
- * The controller error callback
- */
- GNUNET_TESTBED_ControllerStatusCallback cb;
-
- /**
- * The closure for the above callback
- */
- void *cls;
-
- /**
- * The send handle for the helper
- */
- struct GNUNET_HELPER_SendHandle *shandle;
-
- /**
- * The message corresponding to send handle
- */
- struct GNUNET_MessageHeader *msg;
-
- /**
- * The port number for ssh; used for helpers starting ssh
- */
- char *port;
-
- /**
- * The ssh destination string; used for helpers starting ssh
- */
- char *dst;
-
- /**
- * The configuration of the running testbed service
- */
- struct GNUNET_CONFIGURATION_Handle *cfg;
-
-};
-
-
-/**
* Functions with this signature are called whenever a
* complete message is received by the tokenizer.
*
@@ -1186,11 +1213,13 @@
opstart_link_controllers (void *cls)
{
struct OperationContext *opc = cls;
+ struct ControllerLinkData *data;
struct GNUNET_TESTBED_ControllerLinkMessage *msg;
GNUNET_assert (NULL != opc->data);
- msg = opc->data;
- opc->data = NULL;
+ data = opc->data;
+ msg = data->msg;
+ data->msg = NULL;
opc->state = OPC_STATE_STARTED;
GNUNET_CONTAINER_DLL_insert_tail (opc->c->ocq_head, opc->c->ocq_tail, opc);
GNUNET_TESTBED_queue_message_ (opc->c, &msg->header);
@@ -1206,11 +1235,21 @@
oprelease_link_controllers (void *cls)
{
struct OperationContext *opc = cls;
+ struct ControllerLinkData *data;
- if (OPC_STATE_INIT == opc->state)
- GNUNET_free (opc->data);
- if (OPC_STATE_STARTED == opc->state)
+ data = opc->data;
+ switch (opc->state)
+ {
+ case OPC_STATE_INIT:
+ GNUNET_free (data->msg);
+ break;
+ case OPC_STATE_STARTED:
GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
+ break;
+ case OPC_STATE_FINISHED:
+ break;
+ }
+ GNUNET_free_non_null (data);
GNUNET_free (opc);
}
@@ -1660,19 +1699,24 @@
* Same as the GNUNET_TESTBED_controller_link, however expects configuration in
* serialized and compressed
*
+ * @param op_cls the operation closure for the event which is generated to
+ * signal success or failure of this operation
* @param master handle to the master controller who creates the association
* @param delegated_host requests to which host should be delegated; cannot be
NULL
* @param slave_host which host is used to run the slave controller; use NULL
to
* make the master controller connect to the delegated host
* @param sxcfg serialized and compressed configuration
- * @param sxcfg_size the size scfg
+ * @param sxcfg_size the size sxcfg
* @param scfg_size the size of uncompressed serialized configuration
* @param is_subordinate GNUNET_YES if the controller at delegated_host should
- * be started by the master controller; GNUNET_NO if we are just
- * allowed to use the slave via TCP/IP
+ * be started by the slave controller; GNUNET_NO if the slave
+ * controller has to connect to the already started delegated
+ * controller via TCP/IP
+ * @return the operation handle
*/
struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_controller_link_2 (struct GNUNET_TESTBED_Controller *master,
+GNUNET_TESTBED_controller_link_2 (void *op_cls,
+ struct GNUNET_TESTBED_Controller *master,
struct GNUNET_TESTBED_Host *delegated_host,
struct GNUNET_TESTBED_Host *slave_host,
const char *sxcfg, size_t sxcfg_size,
@@ -1680,6 +1724,7 @@
{
struct OperationContext *opc;
struct GNUNET_TESTBED_ControllerLinkMessage *msg;
+ struct ControllerLinkData *data;
uint16_t msg_size;
GNUNET_assert (GNUNET_YES ==
@@ -1698,9 +1743,12 @@
msg->config_size = htons ((uint16_t) scfg_size);
msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0;
memcpy (&msg[1], sxcfg, sxcfg_size);
+ data = GNUNET_malloc (sizeof (struct ControllerLinkData));
+ data->msg = msg;
+ data->op_cls = op_cls;
opc = GNUNET_malloc (sizeof (struct OperationContext));
opc->c = master;
- opc->data = msg;
+ opc->data = data;
opc->type = OP_LINK_CONTROLLERS;
opc->id = master->operation_counter++;
opc->state = OPC_STATE_INIT;
@@ -1744,24 +1792,33 @@
* master controller is asked to start a peer at the delegated controller the
* request will be routed towards slave controller (if a route exists). The
* slave controller will then route it to the delegated controller. The
- * configuration of the slave controller is given and to be used to either
- * create the slave controller or to connect to an existing slave controller
- * process. 'is_subordinate' specifies if the given slave controller should be
- * started and managed by the master controller, or if the slave already has a
- * master and this is just a secondary master that is also allowed to use the
- * existing slave.
+ * configuration of the delegated controller is given and is used to either
+ * create the delegated controller or to connect to an existing controller.
Note
+ * that while starting the delegated controller the configuration will be
+ * modified to accommodate available free ports. the 'is_subordinate'
specifies
+ * if the given delegated controller should be started and managed by the slave
+ * controller, or if the delegated controller already has a master and the
slave
+ * controller connects to it as a non master controller. The success or failure
+ * of this operation will be signalled through the
+ * GNUNET_TESTBED_ControllerCallback() with an event of type
+ * GNUNET_TESTBED_ET_OPERATION_FINISHED
*
+ * @param op_cls the operation closure for the event which is generated to
+ * signal success or failure of this operation
* @param master handle to the master controller who creates the association
- * @param delegated_host requests to which host should be delegated
- * @param slave_host which host is used to run the slave controller
+ * @param delegated_host requests to which host should be delegated; cannot be
NULL
+ * @param slave_host which host is used to run the slave controller; use NULL
to
+ * make the master controller connect to the delegated host
* @param slave_cfg configuration to use for the slave controller
- * @param is_subordinate GNUNET_YES if the slave should be started (and
stopped)
- * by the master controller; GNUNET_NO if we are just
- * allowed to use the slave via TCP/IP
+ * @param is_subordinate GNUNET_YES if the controller at delegated_host should
+ * be started by the slave controller; GNUNET_NO if the slave
+ * controller has to connect to the already started delegated
+ * controller via TCP/IP
* @return the operation handle
*/
struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master,
+GNUNET_TESTBED_controller_link (void *op_cls,
+ struct GNUNET_TESTBED_Controller *master,
struct GNUNET_TESTBED_Host *delegated_host,
struct GNUNET_TESTBED_Host *slave_host,
const struct GNUNET_CONFIGURATION_Handle
@@ -1784,9 +1841,9 @@
/* Configuration doesn't fit in 1 message */
GNUNET_assert ((UINT16_MAX -
sizeof (struct GNUNET_TESTBED_ControllerLinkMessage)) >=
cc_size);
- op = GNUNET_TESTBED_controller_link_2 (master, delegated_host, slave_host,
- (const char *) cconfig, cc_size,
- config_size, is_subordinate);
+ op = GNUNET_TESTBED_controller_link_2 (op_cls, master, delegated_host,
+ slave_host, (const char *) cconfig,
+ cc_size, config_size, is_subordinate);
GNUNET_free (cconfig);
return op;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24184 - in gnunet/src: include testbed,
gnunet <=