[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r26192 - gnunet/src/testbed
From: |
gnunet |
Subject: |
[GNUnet-SVN] r26192 - gnunet/src/testbed |
Date: |
Fri, 22 Feb 2013 15:53:28 +0100 |
Author: harsha
Date: 2013-02-22 15:53:28 +0100 (Fri, 22 Feb 2013)
New Revision: 26192
Modified:
gnunet/src/testbed/gnunet-service-testbed.c
gnunet/src/testbed/gnunet-service-testbed.h
gnunet/src/testbed/gnunet-service-testbed_oc.c
gnunet/src/testbed/testbed_api.c
Log:
Use a sub operation while forwarding controller link operations. This helps to
propagate the change in a host's configuration along the controller tree's
branch back to root.
Modified: gnunet/src/testbed/gnunet-service-testbed.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed.c 2013-02-22 14:37:06 UTC (rev
26191)
+++ gnunet/src/testbed/gnunet-service-testbed.c 2013-02-22 14:53:28 UTC (rev
26192)
@@ -727,27 +727,6 @@
/**
- * Callback to be called when forwarded link controllers operation is
- * successfull. We have to relay the reply msg back to the client
- *
- * @param cls the LCFContext
- * @param msg the message to relay
- */
-static void
-lcf_forwarded_operation_reply_relay (void *cls,
- const struct GNUNET_MessageHeader *msg)
-{
- struct LCFContext *lcf = cls;
-
- GNUNET_assert (NULL != lcf->fopc);
- GST_forwarded_operation_reply_relay (lcf->fopc, msg);
- lcf->fopc = NULL;
- GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id);
- lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
-}
-
-
-/**
* Task to free resources when forwarded link controllers has been timedout
*
* @param cls the LCFContext
@@ -758,19 +737,12 @@
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct LCFContext *lcf = cls;
- struct ForwardedOperationContext *fopc = lcf->fopc;
- GNUNET_assert (NULL != lcf->fopc);
- lcf->fopc->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ lcf->timeout_task = GNUNET_SCHEDULER_NO_TASK;
// GST_forwarded_operation_timeout (lcf->fopc, tc);
- GNUNET_TESTBED_forward_operation_msg_cancel_ (fopc->opc);
LOG (GNUNET_ERROR_TYPE_WARNING,
- "A forwarded operation as part of controller linking has timed out\n");
- send_controller_link_response (fopc->client, fopc->operation_id, NULL,
"Timeout");
- GNUNET_SERVER_client_drop (fopc->client);
- GNUNET_CONTAINER_DLL_remove (fopcq_head, fopcq_tail, fopc);
- GNUNET_free (fopc);
- lcf->fopc = NULL;
+ "A forwarded controller link operation has timed out\n");
+ send_controller_link_response (lcf->client, lcf->operation_id, NULL,
"Timeout");
GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id);
lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
}
@@ -821,26 +793,24 @@
}
break;
case SLAVE_HOST_REGISTERED:
- lcf->fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext));
- lcf->fopc->client = lcf->client;
- lcf->fopc->operation_id = lcf->operation_id;
- lcf->fopc->type = OP_LINK_CONTROLLERS;
- lcf->fopc->opc =
- GNUNET_TESTBED_forward_operation_msg_ (lcf->gateway->controller,
- lcf->operation_id,
- &lcf->msg->header,
-
&lcf_forwarded_operation_reply_relay,
- lcf);
- lcf->fopc->timeout_task =
+ lcf->op = GNUNET_TESTBED_controller_link (lcf,
+ lcf->gateway->controller,
+
GST_host_list[lcf->delegated_host_id],
+
GST_host_list[lcf->slave_host_id],
+ NULL,
+ lcf->is_subordinate);
+ lcf->timeout_task =
GNUNET_SCHEDULER_add_delayed (GST_timeout,
&lcf_forwarded_operation_timeout,
lcf);
- GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, lcf->fopc);
lcf->state = FINISHED;
break;
case FINISHED:
lcfq = lcfq_head;
GNUNET_assert (lcfq->lcf == lcf);
- GNUNET_free (lcf->msg);
+ GNUNET_assert (NULL != lcf->cfg);
+ GNUNET_CONFIGURATION_destroy (lcf->cfg);
+ GNUNET_SERVER_client_drop (lcf->client);
+ GNUNET_TESTBED_operation_done (lcf->op);
GNUNET_free (lcf);
GNUNET_CONTAINER_DLL_remove (lcfq_head, lcfq_tail, lcfq);
GNUNET_free (lcfq);
@@ -862,35 +832,62 @@
const struct GNUNET_TESTBED_EventInformation *event)
{
struct RegisteredHostContext *rhc;
+ struct LCFContext *lcf;
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_TESTBED_Operation *old_op;
- /* We currently only get here when working on RegisteredHostContexts */
+ /* We currently only get here when working on RegisteredHostContexts and
+ LCFContexts */
GNUNET_assert (GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type);
rhc = event->details.operation_finished.op_cls;
- GNUNET_assert (rhc->sub_op == event->details.operation_finished.operation);
- switch (rhc->state)
+ if (CLOSURE_TYPE_RHC == rhc->type)
{
- case RHC_GET_CFG:
- cfg = event->details.operation_finished.generic;
- old_op = rhc->sub_op;
- rhc->state = RHC_LINK;
- rhc->sub_op =
- GNUNET_TESTBED_controller_link (rhc, rhc->gateway->controller,
- rhc->reg_host, rhc->host, cfg,
- GNUNET_NO);
- GNUNET_TESTBED_operation_done (old_op);
- break;
- case RHC_LINK:
- LOG_DEBUG ("OL: Linking controllers successfull\n");
- GNUNET_TESTBED_operation_done (rhc->sub_op);
- rhc->sub_op = NULL;
- rhc->state = RHC_OL_CONNECT;
- GST_process_next_focc (rhc);
- break;
- default:
- GNUNET_assert (0);
+ GNUNET_assert (rhc->sub_op == event->details.operation_finished.operation);
+ switch (rhc->state)
+ {
+ case RHC_GET_CFG:
+ cfg = event->details.operation_finished.generic;
+ old_op = rhc->sub_op;
+ rhc->state = RHC_LINK;
+ rhc->sub_op =
+ GNUNET_TESTBED_controller_link (rhc, rhc->gateway->controller,
+ rhc->reg_host, rhc->host, cfg,
+ GNUNET_NO);
+ GNUNET_TESTBED_operation_done (old_op);
+ break;
+ case RHC_LINK:
+ LOG_DEBUG ("OL: Linking controllers successfull\n");
+ GNUNET_TESTBED_operation_done (rhc->sub_op);
+ rhc->sub_op = NULL;
+ rhc->state = RHC_OL_CONNECT;
+ GST_process_next_focc (rhc);
+ break;
+ default:
+ GNUNET_assert (0);
+ }
+ return;
}
+ lcf = event->details.operation_finished.op_cls;
+ if (CLOSURE_TYPE_LCF == lcf->type)
+ {
+ GNUNET_assert (lcf->op == event->details.operation_finished.operation);
+ GNUNET_assert (FINISHED == lcf->state);
+ GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != lcf->timeout_task);
+ GNUNET_SCHEDULER_cancel (lcf->timeout_task);
+ if (NULL == event->details.operation_finished.emsg)
+ send_controller_link_response (lcf->client, lcf->operation_id,
+ GNUNET_TESTBED_host_get_cfg_
+ (GST_host_list[lcf->delegated_host_id]),
+ NULL);
+ else
+ send_controller_link_response (lcf->client, lcf->operation_id,
+ NULL,
+ event->details.operation_finished.emsg);
+ GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id);
+ lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
+ return;
+ }
+ GNUNET_assert (0);
}
@@ -915,8 +912,6 @@
{
slave->controller_proc = NULL;
GST_slave_list[slave->host_id] = NULL;
- if (NULL != slave->cfg)
- GNUNET_CONFIGURATION_destroy (slave->cfg);
GNUNET_free (slave);
slave = NULL;
LOG (GNUNET_ERROR_TYPE_WARNING, "Unexpected slave shutdown\n");
@@ -930,7 +925,6 @@
if (NULL != slave->controller)
{
send_controller_link_response (lcc->client, lcc->operation_id, cfg, NULL);
- slave->cfg = GNUNET_CONFIGURATION_dup (cfg);
}
else
{
@@ -1235,9 +1229,6 @@
struct LCFContextQueue *lcfq;
struct Route *route;
struct Route *new_route;
- char *config;
- uLongf dest_size;
- size_t config_size;
uint32_t delegated_host_id;
uint32_t slave_host_id;
uint16_t msize;
@@ -1287,53 +1278,22 @@
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
-
+ cfg = GNUNET_TESTBED_extract_config_ (message); /* destroy cfg here or in
lcfcontext */
+ if (NULL == cfg)
+ {
+ GNUNET_break (0); /* Configuration parsing error */
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
if (slave_host_id == GST_context->host_id) /* Link from us */
{
struct Slave *slave;
struct LinkControllersContext *lcc;
- msize -= sizeof (struct GNUNET_TESTBED_ControllerLinkRequest);
- config_size = ntohs (msg->config_size);
- if ((delegated_host_id < GST_slave_list_size) && (NULL !=
GST_slave_list[delegated_host_id])) /* We have already added */
- {
- LOG (GNUNET_ERROR_TYPE_WARNING, "Host %u already connected\n",
- delegated_host_id);
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
- return;
- }
- config = GNUNET_malloc (config_size);
- dest_size = (uLongf) config_size;
- if (Z_OK !=
- uncompress ((Bytef *) config, &dest_size, (const Bytef *) &msg[1],
- (uLong) msize))
- {
- GNUNET_break (0); /* Compression error */
- GNUNET_free (config);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
- }
- if (config_size != dest_size)
- {
- LOG (GNUNET_ERROR_TYPE_WARNING, "Uncompressed config size mismatch\n");
- GNUNET_free (config);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
- }
- cfg = GNUNET_CONFIGURATION_create (); /* Free here or in lcfcontext
*/
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_deserialize (cfg, config, config_size, GNUNET_NO))
- {
- GNUNET_break (0); /* Configuration parsing error */
- GNUNET_free (config);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
- }
- GNUNET_free (config);
if ((delegated_host_id < GST_slave_list_size) &&
(NULL != GST_slave_list[delegated_host_id]))
{
- GNUNET_break (0); /* Configuration parsing error */
+ GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
@@ -1347,7 +1307,6 @@
GNUNET_TESTBED_controller_connect (cfg,
GST_host_list[slave->host_id],
event_mask, &slave_event_callback,
slave);
- slave->cfg = cfg;
if (NULL != slave->controller)
send_controller_link_response (client,
GNUNET_ntohll (msg->operation_id),
@@ -1387,17 +1346,18 @@
}
lcfq = GNUNET_malloc (sizeof (struct LCFContextQueue));
lcfq->lcf = GNUNET_malloc (sizeof (struct LCFContext));
+ lcfq->lcf->type = CLOSURE_TYPE_LCF;
lcfq->lcf->delegated_host_id = delegated_host_id;
lcfq->lcf->slave_host_id = slave_host_id;
route = GST_find_dest_route (slave_host_id);
GNUNET_assert (NULL != route); /* because we add routes carefully */
GNUNET_assert (route->dest < GST_slave_list_size);
GNUNET_assert (NULL != GST_slave_list[route->dest]);
+ lcfq->lcf->cfg = cfg;
+ lcfq->lcf->is_subordinate = msg->is_subordinate;
lcfq->lcf->state = INIT;
lcfq->lcf->operation_id = GNUNET_ntohll (msg->operation_id);
lcfq->lcf->gateway = GST_slave_list[route->dest];
- lcfq->lcf->msg = GNUNET_malloc (msize);
- (void) memcpy (lcfq->lcf->msg, msg, msize);
GNUNET_SERVER_client_keep (client);
lcfq->lcf->client = client;
if (NULL == lcfq_head)
@@ -1969,6 +1929,7 @@
struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg;
struct Slave *slave;
struct GNUNET_TESTBED_SlaveConfiguration *reply;
+ const struct GNUNET_CONFIGURATION_Handle *cfg;
char *config;
char *xconfig;
size_t config_size;
@@ -1988,14 +1949,8 @@
return;
}
slave = GST_slave_list[slave_id];
- if (NULL == slave->cfg)
- {
- GST_send_operation_fail_msg (client, op_id,
- "Configuration not found (slave not started
by me)");
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
- return;
- }
- config = GNUNET_CONFIGURATION_serialize (slave->cfg, &config_size);
+ GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_
(GST_host_list[slave->host_id])));
+ config = GNUNET_CONFIGURATION_serialize (cfg, &config_size);
xconfig_size =
GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig);
GNUNET_free (config);
@@ -2128,7 +2083,9 @@
GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id);
for (lcfq = lcfq_head; NULL != lcfq; lcfq = lcfq_head)
{
- GNUNET_free (lcfq->lcf->msg);
+ GNUNET_SERVER_client_drop (lcfq->lcf->client);
+ GNUNET_assert (NULL != lcfq->lcf->cfg);
+ GNUNET_CONFIGURATION_destroy (lcfq->lcf->cfg);
GNUNET_free (lcfq->lcf);
GNUNET_CONTAINER_DLL_remove (lcfq_head, lcfq_tail, lcfq);
GNUNET_free (lcfq);
@@ -2191,8 +2148,6 @@
reghost_free_iterator,
GST_slave_list[id]);
GNUNET_CONTAINER_multihashmap_destroy (GST_slave_list[id]->reghost_map);
- if (NULL != GST_slave_list[id]->cfg)
- GNUNET_CONFIGURATION_destroy (GST_slave_list[id]->cfg);
if (NULL != GST_slave_list[id]->controller)
GNUNET_TESTBED_controller_disconnect (GST_slave_list[id]->controller);
if (NULL != GST_slave_list[id]->controller_proc)
Modified: gnunet/src/testbed/gnunet-service-testbed.h
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed.h 2013-02-22 14:37:06 UTC (rev
26191)
+++ gnunet/src/testbed/gnunet-service-testbed.h 2013-02-22 14:53:28 UTC (rev
26192)
@@ -186,11 +186,6 @@
struct GNUNET_TESTBED_Controller *controller;
/**
- * The configuration of the slave. Cannot be NULL
- */
- struct GNUNET_CONFIGURATION_Handle *cfg;
-
- /**
* handle to lcc which is associated with this slave startup. Should be set
to
* NULL when the slave has successfully started up
*/
@@ -393,12 +388,34 @@
/**
+ * The type for data structures which commonly arrive at the
slave_event_callback
+ */
+enum ClosureType
+{
+ /**
+ * Type for RegisteredHostContext closures
+ */
+ CLOSURE_TYPE_RHC = 1,
+
+ /**
+ * Type for LinkControllersForwardingContext closures
+ */
+ CLOSURE_TYPE_LCF
+};
+
+
+/**
* This context information will be created for each host that is registered at
* slave controllers during overlay connects.
*/
struct RegisteredHostContext
{
/**
+ * The type of this data structure. Set this to CLOSURE_TYPE_RHC
+ */
+ enum ClosureType type;
+
+ /**
* The host which is being registered
*/
struct GNUNET_TESTBED_Host *reg_host;
@@ -502,16 +519,16 @@
struct LCFContext
{
/**
+ * The type of this data structure. Set this to CLOSURE_TYPE_LCF
+ */
+ enum ClosureType type;
+
+ /**
* The gateway which will pass the link message to delegated host
*/
struct Slave *gateway;
/**
- * The controller link message that has to be forwarded to
- */
- struct GNUNET_TESTBED_ControllerLinkRequest *msg;
-
- /**
* The client which has asked to perform this operation
*/
struct GNUNET_SERVER_Client *client;
@@ -519,12 +536,28 @@
/**
* Handle for operations which are forwarded while linking controllers
*/
- struct ForwardedOperationContext *fopc;
+ struct GNUNET_TESTBED_Operation *op;
/**
+ * The configuration which has to be either used as a template while starting
+ * the delegated controller or for connecting to the delegated controller
+ */
+ struct GNUNET_CONFIGURATION_Handle *cfg;
+
+ /**
+ * The timeout task
+ */
+ GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+
+ /**
* The id of the operation which created this context
*/
uint64_t operation_id;
+
+ /**
+ * should the slave controller start the delegated controller?
+ */
+ int is_subordinate;
/**
* The state of this context
@@ -565,6 +598,7 @@
struct LCFContextQueue *prev;
};
+
/**
* Our configuration
*/
Modified: gnunet/src/testbed/gnunet-service-testbed_oc.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed_oc.c 2013-02-22 14:37:06 UTC
(rev 26191)
+++ gnunet/src/testbed/gnunet-service-testbed_oc.c 2013-02-22 14:53:28 UTC
(rev 26192)
@@ -989,7 +989,7 @@
/**
- * Callback which will be called to after a host registration succeeded or
failed
+ * Callback which will be called after a host registration succeeded or failed
*
* @param cls the RegisteredHostContext
* @param emsg the error message; NULL if host registration is successful
@@ -998,7 +998,7 @@
registeredhost_registration_completion (void *cls, const char *emsg)
{
struct RegisteredHostContext *rhc = cls;
- struct GNUNET_CONFIGURATION_Handle *cfg;
+ const struct GNUNET_CONFIGURATION_Handle *cfg;
uint32_t peer2_host_id;
/* if (NULL != rhc->focc_dll_head) */
@@ -1006,13 +1006,14 @@
peer2_host_id = GNUNET_TESTBED_host_get_id_ (rhc->reg_host);
GNUNET_assert (RHC_INIT == rhc->state);
GNUNET_assert (NULL == rhc->sub_op);
- if ((NULL == rhc->gateway2) || ((peer2_host_id < GST_slave_list_size) /*
Check if we have the needed config */
- && (NULL != GST_slave_list[peer2_host_id])))
+ if ((NULL == rhc->gateway2) || ((peer2_host_id < GST_host_list_size) /*
Check if we have the needed config */
+ && (NULL != GST_host_list[peer2_host_id])))
{
rhc->state = RHC_LINK;
cfg =
(NULL ==
- rhc->gateway2) ? our_config : GST_slave_list[peer2_host_id]->cfg;
+ rhc->gateway2) ? our_config
+ : GNUNET_TESTBED_host_get_cfg_ (GST_host_list[peer2_host_id]);
rhc->sub_op =
GNUNET_TESTBED_controller_link (rhc, rhc->gateway->controller,
rhc->reg_host, rhc->host, cfg,
@@ -1145,6 +1146,7 @@
int skip_focc;
rhc = GNUNET_malloc (sizeof (struct RegisteredHostContext));
+ rhc->type = CLOSURE_TYPE_RHC;
if (NULL != route_to_peer2_host)
rhc->reg_host = GST_host_list[route_to_peer2_host->dest];
else
Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c 2013-02-22 14:37:06 UTC (rev 26191)
+++ gnunet/src/testbed/testbed_api.c 2013-02-22 14:53:28 UTC (rev 26192)
@@ -1581,6 +1581,7 @@
uint32_t slave_host_id;
uint32_t delegated_host_id;
+
GNUNET_assert (GNUNET_YES ==
GNUNET_TESTBED_is_host_registered_ (delegated_host, master));
slave_host_id =
@@ -1591,7 +1592,8 @@
GNUNET_assert (GNUNET_YES ==
GNUNET_TESTBED_is_host_registered_ (slave_host, master));
return GNUNET_TESTBED_controller_link_ (op_cls, master, delegated_host_id,
- slave_host_id, slave_cfg,
+ slave_host_id,
+ GNUNET_TESTBED_host_get_cfg_
(delegated_host),
is_subordinate);
}
@@ -1776,7 +1778,8 @@
* GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONFIGURATION,
* GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION,
* GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST,
- * GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT
+ * GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS,
+ * GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT,
*
* @param msg the message containing compressed configuration
* @return handle to the parsed configuration; NULL upon error while parsing
the message
@@ -1842,6 +1845,16 @@
xdata = (const Bytef *) &imsg[1];
}
break;
+ case GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS:
+ {
+ const struct GNUNET_TESTBED_ControllerLinkRequest *imsg;
+ imsg = (const struct GNUNET_TESTBED_ControllerLinkRequest *) msg;
+ data_len = ntohs (imsg->config_size);
+ xdata_len = ntohs (imsg->header.size) - sizeof (const struct
+ GNUNET_TESTBED_ControllerLinkRequest);
+ xdata = (const Bytef *) &imsg[1];
+ }
+ break;
default:
GNUNET_assert (0);
}
@@ -1849,13 +1862,19 @@
if (Z_OK != (ret = uncompress (data, &data_len, xdata, xdata_len)))
{
GNUNET_free (data);
+ GNUNET_break_op (0);
return NULL;
}
cfg = GNUNET_CONFIGURATION_create ();
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONFIGURATION_deserialize (cfg, (const char *) data,
- (size_t) data_len,
- GNUNET_NO));
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_deserialize (cfg, (const char *) data,
+ (size_t) data_len,
+ GNUNET_NO))
+ {
+ GNUNET_free (data);
+ GNUNET_break_op (0);
+ return NULL;
+ }
GNUNET_free (data);
return cfg;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r26192 - gnunet/src/testbed,
gnunet <=