aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorharsha <harsha@140774ce-b5e7-0310-ab8b-a85725594a96>2012-07-08 22:25:06 +0000
committerharsha <harsha@140774ce-b5e7-0310-ab8b-a85725594a96>2012-07-08 22:25:06 +0000
commit3fe57d845697d895f8a031027cb827cc34763bfd (patch)
tree14ef3ce2a8ee45aaeaa55f9879ce59ba168cec2c /src
parent7f4acf09d7dc991cca5de36a69fbf606a6c76587 (diff)
-client handle operation success
git-svn-id: https://gnunet.org/svn/gnunet@22549 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src')
-rw-r--r--src/testbed/gnunet-service-testbed.c2
-rw-r--r--src/testbed/testbed_api.c83
-rw-r--r--src/testbed/testbed_api_peers.c54
-rw-r--r--src/testbed/testbed_api_peers.h53
4 files changed, 137 insertions, 55 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c
index b947ee7d62..e05e1d71fd 100644
--- a/src/testbed/gnunet-service-testbed.c
+++ b/src/testbed/gnunet-service-testbed.c
@@ -1176,6 +1176,8 @@ handle_peer_destroy (void *cls,
msg = (const struct GNUNET_TESTBED_PeerDestroyMessage *) message;
peer_id = ntohl (msg->peer_id);
+ LOG_DEBUG ("Received peer destory on peer: %u and operation id: %ul\n",
+ peer_id, GNUNET_ntohll (msg->operation_id));
if ((peer_list_size <= peer_id) || (NULL == peer_list[peer_id]))
{
GNUNET_break (0);
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index b290e748cf..2eada0974a 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -39,6 +39,7 @@
#include "testbed.h"
#include "testbed_api.h"
#include "testbed_api_hosts.h"
+#include "testbed_api_peers.h"
/**
* Generic logging shorthand
@@ -322,6 +323,81 @@ handle_addhostconfirm (struct GNUNET_TESTBED_Controller *c,
/**
+ * Handler for GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message from
+ * controller (testbed service)
+ *
+ * @param c the controller handler
+ * @param msg message received
+ * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if
+ * not
+ */
+static int
+handle_opsuccess (struct GNUNET_TESTBED_Controller *c,
+ const struct
+ GNUNET_TESTBED_GenericOperationSuccessEventMessage *msg)
+{
+ struct GNUNET_TESTBED_Operation *op;
+ struct GNUNET_TESTBED_EventInformation *event;
+ uint64_t op_id;
+
+ op_id = GNUNET_ntohll (msg->operation_id);
+ LOG_DEBUG ("Operation %ul successful\n", op_id);
+ for (op = op_head; NULL != op; op = op->next)
+ {
+ if (op->operation_id == op_id)
+ break;
+ }
+ if (NULL == op)
+ {
+ LOG_DEBUG ("Operation not found\n");
+ return GNUNET_YES;
+ }
+ event = NULL;
+ if (0 != (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED)))
+ event = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_EventInformation));
+ if (NULL != event)
+ event->type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
+ switch (op->type)
+ {
+ case OP_PEER_DESTROY:
+ {
+ struct PeerDestroyData *data;
+
+ if (NULL != event)
+ {
+ event->details.operation_finished.operation = op;
+ event->details.operation_finished.op_cls = NULL;
+ event->details.operation_finished.emsg = NULL;
+ event->details.operation_finished.pit = GNUNET_TESTBED_PIT_GENERIC;
+ event->details.operation_finished.op_result.generic = NULL;
+ }
+ data = (struct PeerDestroyData *) op->data;
+ if (NULL != data->peer->details)
+ {
+ if (NULL != data->peer->details->cfg)
+ GNUNET_CONFIGURATION_destroy (data->peer->details->cfg);
+ //PEER_DETAILS
+ }
+ GNUNET_free (data->peer);
+ GNUNET_free (data);
+ //PEERDESTROYDATA
+ }
+ break;
+ default:
+ GNUNET_break (0);
+ }
+ if (NULL != event)
+ {
+ if (NULL != c->cc)
+ c->cc (c->cc_cls, event);
+ }
+ GNUNET_CONTAINER_DLL_remove (op_head, op_tail, op);
+ GNUNET_free (op);
+ return GNUNET_YES;
+}
+
+
+/**
* Handler for messages from controller (testbed service)
*
* @param cls the controller handler
@@ -346,8 +422,13 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
case GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM:
status =
handle_addhostconfirm (c, (const struct
- GNUNET_TESTBED_HostConfirmedMessage *) msg);
+ GNUNET_TESTBED_HostConfirmedMessage *) msg);
break;
+ case GNUNET_MESSAGE_TYPE_TESTBED_GENERICOPSUCCESS:
+ status =
+ handle_opsuccess (c, (const struct
+ GNUNET_TESTBED_GenericOperationSuccessEventMessage
+ *) msg);
default:
GNUNET_break (0);
}
diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c
index 2fe8ce26d3..3cd89f2f67 100644
--- a/src/testbed/testbed_api_peers.c
+++ b/src/testbed/testbed_api_peers.c
@@ -30,60 +30,6 @@
#include "testbed.h"
#include "testbed_api_hosts.h"
-/**
- * Details about a peer; kept in a separate struct to avoid bloating
- * memory consumption everywhere...
- */
-struct PeerDetails
-{
- /**
- * Configuration of the peer; NULL if we are not sure what the peer's correct
- * configuration actually is; non-NULL if this peer is controlled by this
- * process.
- */
- struct GNUNET_CONFIGURATION_Handle *cfg;
-
- /**
- * If this process has started this peer's ARM process, this is the handle
- * to the 'gnunet-service-arm' process of the peer.
- */
- struct GNUNET_OS_Process *arm;
-
- // ...
-
-};
-
-
-/**
- * A peer controlled by the testing framework. A peer runs
- * at a particular host.
- */
-struct GNUNET_TESTBED_Peer
-{
- /**
- * Our controller context (not necessarily the controller
- * that is responsible for starting/running the peer!).
- */
- struct GNUNET_TESTBED_Controller *controller;
-
- /**
- * Which host does this peer run on?
- */
- struct GNUNET_TESTBED_Host *host;
-
- /**
- * Globally unique ID of the peer.
- */
- uint32_t unique_id;
-
- /**
- * Internals of the peer for the controlling process; NULL if
- * this process is not controlling this peer.
- */
- struct PeerDetails *details;
-
-};
-
/**
* Lookup a peer by ID.
diff --git a/src/testbed/testbed_api_peers.h b/src/testbed/testbed_api_peers.h
index 3a9244fc2c..ee5ec3bd98 100644
--- a/src/testbed/testbed_api_peers.h
+++ b/src/testbed/testbed_api_peers.h
@@ -31,11 +31,64 @@
/**
+ * Details about a peer; kept in a separate struct to avoid bloating
+ * memory consumption everywhere...
+ */
+struct PeerDetails
+{
+ /**
+ * Configuration of the peer; NULL if we are not sure what the peer's correct
+ * configuration actually is; non-NULL if this peer is controlled by this
+ * process.
+ */
+ struct GNUNET_CONFIGURATION_Handle *cfg;
+
+ //PEER_DETAILS
+};
+
+
+/**
+ * A peer controlled by the testing framework. A peer runs
+ * at a particular host.
+ */
+struct GNUNET_TESTBED_Peer
+{
+ /**
+ * Our controller context (not necessarily the controller
+ * that is responsible for starting/running the peer!).
+ */
+ struct GNUNET_TESTBED_Controller *controller;
+
+ /**
+ * Which host does this peer run on?
+ */
+ struct GNUNET_TESTBED_Host *host;
+
+ /**
+ * Globally unique ID of the peer.
+ */
+ uint32_t unique_id;
+
+ /**
+ * Internals of the peer for the controlling process; NULL if
+ * this process is not controlling this peer.
+ */
+ struct PeerDetails *details;
+
+};
+
+
+/**
* Data for the OperationType OP_PEER_DESTROY;
*/
struct PeerDestroyData
{
+ /**
+ * The peer structure
+ */
struct GNUNET_TESTBED_Peer *peer;
+
+ //PEERDESTROYDATA
};