gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r22549 - gnunet/src/testbed


From: gnunet
Subject: [GNUnet-SVN] r22549 - gnunet/src/testbed
Date: Mon, 9 Jul 2012 00:25:06 +0200

Author: harsha
Date: 2012-07-09 00:25:06 +0200 (Mon, 09 Jul 2012)
New Revision: 22549

Modified:
   gnunet/src/testbed/gnunet-service-testbed.c
   gnunet/src/testbed/testbed_api.c
   gnunet/src/testbed/testbed_api_peers.c
   gnunet/src/testbed/testbed_api_peers.h
Log:
-client handle operation success

Modified: gnunet/src/testbed/gnunet-service-testbed.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed.c 2012-07-08 21:38:00 UTC (rev 
22548)
+++ gnunet/src/testbed/gnunet-service-testbed.c 2012-07-08 22:25:06 UTC (rev 
22549)
@@ -1176,6 +1176,8 @@
   
   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);

Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c    2012-07-08 21:38:00 UTC (rev 22548)
+++ gnunet/src/testbed/testbed_api.c    2012-07-08 22:25:06 UTC (rev 22549)
@@ -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 @@
 
 
 /**
+ * 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 @@
   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);
   }

Modified: gnunet/src/testbed/testbed_api_peers.c
===================================================================
--- gnunet/src/testbed/testbed_api_peers.c      2012-07-08 21:38:00 UTC (rev 
22548)
+++ gnunet/src/testbed/testbed_api_peers.c      2012-07-08 22:25:06 UTC (rev 
22549)
@@ -30,62 +30,8 @@
 #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.
  * 
  * @param id global peer ID assigned to the peer

Modified: gnunet/src/testbed/testbed_api_peers.h
===================================================================
--- gnunet/src/testbed/testbed_api_peers.h      2012-07-08 21:38:00 UTC (rev 
22548)
+++ gnunet/src/testbed/testbed_api_peers.h      2012-07-08 22:25:06 UTC (rev 
22549)
@@ -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
 };
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]