aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-08-11 13:04:52 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-08-11 13:04:52 +0000
commit055b09ed1535ff02bb02503aaa88d1d02b9d366b (patch)
treeba4c34d277ba7a67a244c6f50ed6712e95644c92
parent526fd6adbac1b3ef92edf457e035d6388921fd26 (diff)
forward operation msg cancel
-rw-r--r--src/testbed/testbed_api.c20
-rw-r--r--src/testbed/testbed_api.h14
2 files changed, 32 insertions, 2 deletions
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index 62f16d3003..597b7f348e 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -751,7 +751,9 @@ GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller,
/**
* Sends the given message as an operation. The given callback is called when a
- * reply for the operation is available
+ * reply for the operation is available. Call
+ * GNUNET_TESTBED_forward_operation_msg_cancel_() to cleanup the returned
+ * operation context if the cc hasn't been called
*
* @param controller the controller to which the message has to be sent
* @param operation_id the operation id of the message
@@ -778,6 +780,7 @@ GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller
data->cc = cc;
data->cc_cls = cc_cls;
opc = GNUNET_malloc (sizeof (struct OperationContext));
+ opc->c = controller;
opc->type = OP_FORWARDED;
opc->data = data;
opc->id = operation_id;
@@ -792,6 +795,21 @@ GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller
/**
+ * Function to cancel an operation created by simply forwarding an operation
+ * message.
+ *
+ * @param opc the operation context from GNUNET_TESTBED_forward_operation_msg_()
+ */
+void
+GNUNET_TESTBED_forward_operation_msg_cancel_ (struct OperationContext *opc)
+{
+ GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
+ GNUNET_free (opc->data);
+ GNUNET_free (opc);
+}
+
+
+/**
* Handle for controller process
*/
struct GNUNET_TESTBED_ControllerProc
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h
index d12d9aa965..a8cb383fa5 100644
--- a/src/testbed/testbed_api.h
+++ b/src/testbed/testbed_api.h
@@ -356,7 +356,9 @@ GNUNET_TESTBED_create_helper_init_msg_ (const char *cname,
/**
* Sends the given message as an operation. The given callback is called when a
- * reply for the operation is available
+ * reply for the operation is available. Call
+ * GNUNET_TESTBED_forward_operation_msg_cancel_() to cleanup the returned
+ * operation context if the cc hasn't been called
*
* @param controller the controller to which the message has to be sent
* @param operation_id the operation id of the message
@@ -374,5 +376,15 @@ GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller
GNUNET_CLIENT_MessageHandler cc,
void *cc_cls);
+/**
+ * Function to cancel an operation created by simply forwarding an operation
+ * message.
+ *
+ * @param opc the operation context from GNUNET_TESTBED_forward_operation_msg_()
+ */
+void
+GNUNET_TESTBED_forward_operation_msg_cancel_ (struct OperationContext *opc);
+
+
#endif
/* end of testbed_api.h */