From: Sree Harsha Totakura Date: Sun, 8 Jul 2012 22:35:24 +0000 (+0000) Subject: -removed static operations and operation queue X-Git-Tag: initial-import-from-subversion-38251~12585 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4735aee3267f34b3066e7e0b0c1e5b6108c6073e;p=oweals%2Fgnunet.git -removed static operations and operation queue --- diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index 2eada0974..621121678 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c @@ -127,91 +127,6 @@ struct ControllerLink }; -/** - * Handle to interact with a GNUnet testbed controller. Each - * controller has at least one master handle which is created when the - * controller is created; this master handle interacts with the - * controller process, destroying it destroys the controller (by - * closing stdin of the controller process). Additionally, - * controllers can interact with each other (in a P2P fashion); those - * links are established via TCP/IP on the controller's service port. - */ -struct GNUNET_TESTBED_Controller -{ - - /** - * The host where the controller is running - */ - struct GNUNET_TESTBED_Host *host; - - /** - * The controller callback - */ - GNUNET_TESTBED_ControllerCallback cc; - - /** - * The closure for controller callback - */ - void *cc_cls; - - /** - * The configuration to use while connecting to controller - */ - struct GNUNET_CONFIGURATION_Handle *cfg; - - /** - * The client connection handle to the controller service - */ - struct GNUNET_CLIENT_Connection *client; - - /** - * The head of the message queue - */ - struct MessageQueue *mq_head; - - /** - * The tail of the message queue - */ - struct MessageQueue *mq_tail; - - /** - * The head of the ControllerLink list - */ - struct ControllerLink *cl_head; - - /** - * The tail of the ControllerLink list - */ - struct ControllerLink *cl_tail; - - /** - * The client transmit handle - */ - struct GNUNET_CLIENT_TransmitHandle *th; - - /** - * The host registration handle; NULL if no current registration requests are - * present - */ - struct GNUNET_TESTBED_HostRegistrationHandle *rh; - - /** - * The controller event mask - */ - uint64_t event_mask; - - /** - * Did we start the receive loop yet? - */ - int in_receive; - - /** - * Did we create the host for this? - */ - int aux_host; -}; - - /** * handle for host registration */ @@ -239,34 +154,6 @@ struct GNUNET_TESTBED_HostRegistrationHandle }; -/** - * The global operation id counter - */ -uint64_t GNUNET_TESTBED_operation_id; - -/** - * The head of the operation queue - */ -struct GNUNET_TESTBED_Operation *op_head; - -/** - * The tail of the operation queue - */ -struct GNUNET_TESTBED_Operation *op_tail; - - -/** - * Adds an operation to the queue of operations - * - * @param op the operation to add - */ -void -GNUNET_TESTBED_operation_add (struct GNUNET_TESTBED_Operation *op) -{ - GNUNET_CONTAINER_DLL_insert_tail (op_head, op_tail, op); -} - - /** * Handler for GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message from * controller (testbed service) @@ -342,7 +229,7 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c, op_id = GNUNET_ntohll (msg->operation_id); LOG_DEBUG ("Operation %ul successful\n", op_id); - for (op = op_head; NULL != op; op = op->next) + for (op = c->op_head; NULL != op; op = op->next) { if (op->operation_id == op_id) break; @@ -391,7 +278,7 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c, if (NULL != c->cc) c->cc (c->cc_cls, event); } - GNUNET_CONTAINER_DLL_remove (op_head, op_tail, op); + GNUNET_CONTAINER_DLL_remove (c->op_head, c->op_tail, op); GNUNET_free (op); return GNUNET_YES; } diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h index 53e4607ff..c598d3ec2 100644 --- a/src/testbed/testbed_api.h +++ b/src/testbed/testbed_api.h @@ -40,12 +40,6 @@ enum OperationType }; -/** - * The counter for generating unique operation ids. Use its current value and - * increment it (defined in testbed_api.c) - */ -extern uint64_t GNUNET_TESTBED_operation_id; - /** * Testbed operation structure */ @@ -78,6 +72,118 @@ struct GNUNET_TESTBED_Operation }; +/** + * The message queue for sending messages to the controller service + */ +struct MessageQueue; + + +/** + * Structure for a controller link + */ +struct ControllerLink; + + +/** + * Handle to interact with a GNUnet testbed controller. Each + * controller has at least one master handle which is created when the + * controller is created; this master handle interacts with the + * controller process, destroying it destroys the controller (by + * closing stdin of the controller process). Additionally, + * controllers can interact with each other (in a P2P fashion); those + * links are established via TCP/IP on the controller's service port. + */ +struct GNUNET_TESTBED_Controller +{ + + /** + * The host where the controller is running + */ + struct GNUNET_TESTBED_Host *host; + + /** + * The controller callback + */ + GNUNET_TESTBED_ControllerCallback cc; + + /** + * The closure for controller callback + */ + void *cc_cls; + + /** + * The configuration to use while connecting to controller + */ + struct GNUNET_CONFIGURATION_Handle *cfg; + + /** + * The client connection handle to the controller service + */ + struct GNUNET_CLIENT_Connection *client; + + /** + * The head of the message queue + */ + struct MessageQueue *mq_head; + + /** + * The tail of the message queue + */ + struct MessageQueue *mq_tail; + + /** + * The head of the ControllerLink list + */ + struct ControllerLink *cl_head; + + /** + * The tail of the ControllerLink list + */ + struct ControllerLink *cl_tail; + + /** + * The client transmit handle + */ + struct GNUNET_CLIENT_TransmitHandle *th; + + /** + * The host registration handle; NULL if no current registration requests are + * present + */ + struct GNUNET_TESTBED_HostRegistrationHandle *rh; + + /** + * The head of the operation queue + */ + struct GNUNET_TESTBED_Operation *op_head; + + /** + * The tail of the operation queue + */ + struct GNUNET_TESTBED_Operation *op_tail; + + /** + * The operation id counter. use current value and increment + */ + uint64_t operation_counter; + + /** + * The controller event mask + */ + uint64_t event_mask; + + /** + * Did we start the receive loop yet? + */ + int in_receive; + + /** + * Did we create the host for this? + */ + int aux_host; +}; + + /** * Queues a message in send queue for sending to the service * diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c index 3cd89f2f6..88c97ebf0 100644 --- a/src/testbed/testbed_api_peers.c +++ b/src/testbed/testbed_api_peers.c @@ -235,7 +235,7 @@ GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer) data = GNUNET_malloc (sizeof (struct PeerDestroyData)); data->peer = peer; op = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Operation)); - op->operation_id = GNUNET_TESTBED_operation_id++; + op->operation_id = peer->controller->operation_counter++; op->type = OP_PEER_DESTROY; op->data = data; msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerDestroyMessage)); @@ -243,7 +243,8 @@ GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer) msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER); msg->peer_id = htonl (peer->unique_id); msg->operation_id = GNUNET_htonll (op->operation_id); - GNUNET_TESTBED_operation_add (op); + GNUNET_CONTAINER_DLL_insert_tail (peer->controller->op_head, + peer->controller->op_tail, op); GNUNET_TESTBED_queue_message (peer->controller, (struct GNUNET_MessageHeader *) msg); return op;