-client handle operation success
authorSree Harsha Totakura <totakura@in.tum.de>
Sun, 8 Jul 2012 22:25:06 +0000 (22:25 +0000)
committerSree Harsha Totakura <totakura@in.tum.de>
Sun, 8 Jul 2012 22:25:06 +0000 (22:25 +0000)
src/testbed/gnunet-service-testbed.c
src/testbed/testbed_api.c
src/testbed/testbed_api_peers.c
src/testbed/testbed_api_peers.h

index b947ee7d62082d8e2591b5f2b7ba8b7ae71fc931..e05e1d71fd005b824300cb3edaae8d78f0cf33f7 100644 (file)
@@ -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);
index b290e748cf547f7ce536c1f643500c89bbccfb91..2eada0974aa790e6c0dcbef06b328cd4820c5628 100644 (file)
@@ -39,6 +39,7 @@
 #include "testbed.h"
 #include "testbed_api.h"
 #include "testbed_api_hosts.h"
+#include "testbed_api_peers.h"
 
 /**
  * Generic logging shorthand
@@ -321,6 +322,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)
  *
@@ -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);
   }
index 2fe8ce26d3494ad9a4537bfaaa1cf7cc36f4397d..3cd89f2f67ec9a3b395ec36268429f0eb0b6ddb0 100644 (file)
 #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.
index 3a9244fc2ca4767b96b42089f76c4e4c2eafb18d..ee5ec3bd98585b3d0f6b4cffd90138c906d11f67 100644 (file)
 #include "gnunet_helper_lib.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;
+
+  //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
 };