gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r24264 - gnunet/src/testbed
Date: Thu, 11 Oct 2012 15:34:18 +0200

Author: harsha
Date: 2012-10-11 15:34:18 +0200 (Thu, 11 Oct 2012)
New Revision: 24264

Modified:
   gnunet/src/testbed/gnunet-service-testbed.c
   gnunet/src/testbed/test_testbed_api_3peers_3controllers.c
   gnunet/src/testbed/testbed_api.c
   gnunet/src/testbed/testbed_api.h
Log:
working overlay connect with implicit suboperations

Modified: gnunet/src/testbed/gnunet-service-testbed.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed.c 2012-10-11 11:39:05 UTC (rev 
24263)
+++ gnunet/src/testbed/gnunet-service-testbed.c 2012-10-11 13:34:18 UTC (rev 
24264)
@@ -569,6 +569,11 @@
   struct GNUNET_MessageHeader *orig_msg;
 
   /**
+   * The host registration handle while registered hosts in this context
+   */
+  struct GNUNET_TESTBED_HostRegistrationHandle *rhandle;
+
+  /**
    * The id of the operation which created this context information
    */
   uint64_t operation_id;
@@ -584,6 +589,11 @@
     FOCC_INIT = 0,
 
     /**
+     * State where we attempt to register peer2's controller with peer1's 
controller
+     */
+    FOCC_REGISTER,
+
+    /**
      * State where we attempt to get peer2's controller configuration
      */
     FOCC_GET_CFG,
@@ -663,7 +673,7 @@
 static struct MessageQueue *mq_tail;
 
 /**
- * Array of host list
+ * Array of hosts
  */
 static struct GNUNET_TESTBED_Host **host_list;
 
@@ -1236,7 +1246,8 @@
 {
   if (NULL != focc->sub_op)
     GNUNET_TESTBED_operation_done (focc->sub_op);
-  GNUNET_SERVER_client_drop (focc->client);
+  if (NULL != focc->client)
+    GNUNET_SERVER_client_drop (focc->client);
   GNUNET_free_non_null (focc->orig_msg);
   GNUNET_free (focc);
 }
@@ -1259,8 +1270,9 @@
 
   /* We currently only get here when doing overlay connect operations and that
      too while trying out sub operations */
-  GNUNET_assert (GNUNET_TESTBED_ET_OPERATION_FINISHED != event->type);
+  GNUNET_assert (GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type);
   focc = event->details.operation_finished.op_cls;
+  LOG_DEBUG ("Operation successful\n");
   if (NULL != event->details.operation_finished.emsg)
   {
     GNUNET_asprintf (&emsg, "Failure executing suboperation: %s",
@@ -1286,6 +1298,7 @@
     GNUNET_TESTBED_operation_done (old_op);
     break;
   case FOCC_LINK:
+    LOG_DEBUG ("OL: Linking controllers successfull\n");
     GNUNET_TESTBED_operation_done (focc->sub_op);
     focc->sub_op = NULL;
     focc->state = FOCC_OL_CONNECT;
@@ -1671,7 +1684,7 @@
     {
       LOG (GNUNET_ERROR_TYPE_WARNING, "Host %u already connected\n",
            delegated_host_id);
-      GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+      GNUNET_SERVER_receive_done (client, GNUNET_OK);
       return;
     }
     config = GNUNET_malloc (config_size);
@@ -2588,6 +2601,43 @@
 
 
 /**
+ * This callback is a part of overlay connect operation. This will be run when
+ * the registration operation of peer2's controller is completed at peer1's
+ * controller
+ *
+ * @param cls the ForwardedOverlayConnectContext
+ * @param emsg the error message in case of any failure; NULL if host
+ *          registration is successfull.
+ */
+static void
+focc_reg_completion_cc (void *cls, const char *emsg)
+{
+  struct ForwardedOverlayConnectContext *focc = cls;
+  
+  GNUNET_assert (FOCC_REGISTER == focc->state);
+  focc->rhandle = NULL;
+  GNUNET_assert (NULL == focc->sub_op);
+  LOG_DEBUG ("Registering peer2's host successful\n");
+  if ((focc->peer2_host_id < slave_list_size) /* Check if we have the needed 
config */
+      && (NULL != slave_list[focc->peer2_host_id]))
+  {
+    focc->state = FOCC_LINK;
+    focc->sub_op = 
+        GNUNET_TESTBED_controller_link_ (focc,
+                                         focc->gateway,
+                                         focc->peer2_host_id,
+                                         
peer_list[focc->peer1]->details.remote.remote_host_id,
+                                         slave_list[focc->peer2_host_id]->cfg,
+                                         GNUNET_NO);
+    return;
+  }
+  focc->state = FOCC_GET_CFG;
+  focc->sub_op = GNUNET_TESTBED_get_slave_config_ (focc, focc->gateway2,
+                                                   focc->peer2_host_id);
+}
+
+
+/**
  * Callback to be called when forwarded overlay connection operation has a 
reply
  * from the sub-controller successfull. We have to relay the reply msg back to
  * the client
@@ -2619,10 +2669,12 @@
       forwarded_operation_reply_relay (cls, msg);
       return;
     }
-    GNUNET_assert (NULL == focc->sub_op);
-    focc->state = FOCC_GET_CFG;
-    focc->sub_op = GNUNET_TESTBED_get_slave_config_ (focc, focc->gateway2,
-                                                     focc->peer2_host_id);
+    LOG_DEBUG ("Registering peer2's host\n");
+    focc->state = FOCC_REGISTER;
+    focc->rhandle =
+        GNUNET_TESTBED_register_host (focc->gateway,
+                                      host_list[focc->peer2_host_id],
+                                      focc_reg_completion_cc, focc);
     break;
   default:
     GNUNET_assert (0);
@@ -3200,7 +3252,7 @@
       GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
                                     &shutdown_task, NULL);
   LOG_DEBUG ("Testbed startup complete\n");
-  event_mask = GNUNET_TESTBED_ET_OPERATION_FINISHED;
+  event_mask = 1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED;
 }
 
 

Modified: gnunet/src/testbed/test_testbed_api_3peers_3controllers.c
===================================================================
--- gnunet/src/testbed/test_testbed_api_3peers_3controllers.c   2012-10-11 
11:39:05 UTC (rev 24263)
+++ gnunet/src/testbed/test_testbed_api_3peers_3controllers.c   2012-10-11 
13:34:18 UTC (rev 24264)
@@ -215,16 +215,6 @@
   PEERS_1_2_CONNECTED,
 
   /**
-   * Configuration of C has been acquired
-   */
-  CONTROLLER_CFG_ACQUIRED,
-
-  /**
-   * Linking controller B to C laterally
-   */
-  CONTROLLERS_LATERALLY_LINKED,
-
-  /**
    * peer2 and peer3 are connected
    */
   PEERS_2_3_CONNECTED,
@@ -347,8 +337,18 @@
     result = PEERS_1_2_CONNECTED;
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n");
     common_operation = 
-       GNUNET_TESTBED_get_slave_config (NULL, controller1, neighbour2);
+         GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer2.peer,
+                                         peer3.peer);
     break;
+  case PEERS_1_2_CONNECTED:
+    GNUNET_assert (NULL != common_operation);
+    GNUNET_TESTBED_operation_done (common_operation);
+    common_operation = NULL;
+    result = PEERS_2_3_CONNECTED;
+    delayed_connect_task =
+          GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (3),
+                                        &do_delayed_connect, NULL);
+    break;
   case PEERS_2_3_CONNECTED:
     GNUNET_assert (NULL == peer1.operation);
     GNUNET_assert (NULL == peer2.operation);
@@ -361,14 +361,6 @@
     peer2.operation = GNUNET_TESTBED_peer_stop (peer2.peer, NULL, NULL);
     peer3.operation = GNUNET_TESTBED_peer_stop (peer3.peer, NULL, NULL);
     break;
-  case CONTROLLERS_LATERALLY_LINKED:
-    GNUNET_TESTBED_operation_done (common_operation);
-    common_operation = NULL;
-    result = PEERS_2_3_CONNECTED;
-    delayed_connect_task =
-       GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (3),
-                                     &do_delayed_connect, NULL);
-    break;
   default:
     GNUNET_assert (0);
   }
@@ -502,24 +494,6 @@
                                       &peer_create_cb, NULL);
       GNUNET_assert (NULL != peer3.operation);
       break;
-    case PEERS_1_2_CONNECTED:
-      GNUNET_assert (NULL != event->details.operation_finished.generic);
-      cfg2 = 
-         GNUNET_CONFIGURATION_dup (event->details.operation_finished.generic);
-      GNUNET_TESTBED_operation_done (common_operation);
-      result = CONTROLLER_CFG_ACQUIRED;
-      common_operation =
-         GNUNET_TESTBED_controller_link (NULL, controller1, neighbour2, 
neighbour1,
-                                         cfg2, GNUNET_NO);
-      break;
-    case CONTROLLER_CFG_ACQUIRED:
-      GNUNET_assert (NULL == event->details.operation_finished.generic);
-      GNUNET_TESTBED_operation_done (common_operation);
-      result = CONTROLLERS_LATERALLY_LINKED;
-      common_operation =
-         GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer2.peer,
-                                         peer3.peer);      
-      break;
     default:
       GNUNET_assert (0);
     }
@@ -608,10 +582,10 @@
       GNUNET_assert ((event->details.peer_connect.peer1 == peer1.peer) &&
                     (event->details.peer_connect.peer2 == peer2.peer));
       break;
-    case CONTROLLERS_LATERALLY_LINKED:
+    case PEERS_1_2_CONNECTED: 
       GNUNET_assert (NULL != common_operation);
       GNUNET_assert ((event->details.peer_connect.peer1 == peer2.peer) &&
-                    (event->details.peer_connect.peer2 == peer3.peer));
+                    (event->details.peer_connect.peer2 == peer3.peer));      
       break;
     default:
       GNUNET_assert (0);

Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c    2012-10-11 11:39:05 UTC (rev 24263)
+++ gnunet/src/testbed/testbed_api.c    2012-10-11 13:34:18 UTC (rev 24264)
@@ -240,11 +240,6 @@
 struct GetSlaveConfigData
 {
   /**
-   * The operation closure
-   */
-  void *op_cls;
-
-  /**
    * The id of the slave controller
    */
   uint32_t slave_id;
@@ -262,11 +257,6 @@
    */
   struct GNUNET_TESTBED_ControllerLinkMessage *msg;
 
-  /**
-   * The operation closure
-   */
-  void *op_cls;
-
 };
 
 
@@ -397,7 +387,7 @@
   }
   event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
   event.details.operation_finished.operation = opc->op;
-  event.details.operation_finished.op_cls = NULL;
+  event.details.operation_finished.op_cls = opc->op_cls;
   event.details.operation_finished.emsg = NULL;
   event.details.operation_finished.generic = NULL;
   switch (opc->type)
@@ -425,7 +415,6 @@
       
       data = opc->data;
       GNUNET_assert (NULL != data);      
-      event.details.operation_finished.op_cls = data->op_cls;
       GNUNET_free (data);
       opc->data = NULL;
     }
@@ -440,6 +429,8 @@
     if (NULL != c->cc)
       c->cc (c->cc_cls, &event);
   }
+  else
+    LOG_DEBUG ("Not calling callback\n");
   return GNUNET_YES;
 }
 
@@ -758,7 +749,7 @@
   {
     event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
     event.details.operation_finished.operation = opc->op;
-    event.details.operation_finished.op_cls = NULL;
+    event.details.operation_finished.op_cls = opc->op_cls;
     event.details.operation_finished.emsg = emsg;
     event.details.operation_finished.generic = NULL;
     c->cc (c->cc_cls, &event);
@@ -846,7 +837,6 @@
                     const struct GNUNET_TESTBED_SlaveConfiguration * msg)
 {
   struct OperationContext *opc;
-  void *op_cls;
   uint64_t op_id;
   struct GNUNET_TESTBED_EventInformation event;  
 
@@ -860,8 +850,7 @@
   {
     GNUNET_break (0);
     return GNUNET_YES;
-  }  
-  op_cls = ((struct GetSlaveConfigData *) opc->data)->op_cls;
+  }
   GNUNET_free (opc->data);
   opc->data = NULL;
   opc->state = OPC_STATE_FINISHED;
@@ -873,7 +862,7 @@
     event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;   
     event.details.operation_finished.generic = opc->data;
     event.details.operation_finished.operation = opc->op;
-    event.details.operation_finished.op_cls = op_cls;
+    event.details.operation_finished.op_cls = opc->op_cls;
     event.details.operation_finished.emsg = NULL;
     c->cc (c->cc_cls, &event);
   }
@@ -1860,13 +1849,13 @@
   memcpy (&msg[1], sxcfg, sxcfg_size);
   data = GNUNET_malloc (sizeof (struct ControllerLinkData));
   data->msg = msg;
-  data->op_cls = op_cls;
   opc = GNUNET_malloc (sizeof (struct OperationContext));
   opc->c = master;
   opc->data = data;
   opc->type = OP_LINK_CONTROLLERS;
   opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
   opc->state = OPC_STATE_INIT;
+  opc->op_cls = op_cls;
   msg->operation_id = GNUNET_htonll (opc->id);
   opc->op =
       GNUNET_TESTBED_operation_create_ (opc, &opstart_link_controllers,
@@ -2078,13 +2067,13 @@
 
   data = GNUNET_malloc (sizeof (struct GetSlaveConfigData));
   data->slave_id = slave_host_id;
-  data->op_cls = op_cls;
   opc = GNUNET_malloc (sizeof (struct OperationContext));
   opc->state = OPC_STATE_INIT;
   opc->c = master;
   opc->id = GNUNET_TESTBED_get_next_op_id (master);
   opc->type = OP_GET_SLAVE_CONFIG;
   opc->data = data;
+  opc->op_cls = op_cls;
   opc->op =
       GNUNET_TESTBED_operation_create_ (opc, &opstart_get_slave_config,
                                         &oprelease_get_slave_config);

Modified: gnunet/src/testbed/testbed_api.h
===================================================================
--- gnunet/src/testbed/testbed_api.h    2012-10-11 11:39:05 UTC (rev 24263)
+++ gnunet/src/testbed/testbed_api.h    2012-10-11 13:34:18 UTC (rev 24264)
@@ -182,6 +182,11 @@
   struct GNUNET_TESTBED_Operation *op;
 
   /**
+   * The operation closure
+   */
+  void *op_cls;
+
+  /**
    * Data relevant to the operation
    */
   void *data;




reply via email to

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