multiple operation queues for an operation
[oweals/gnunet.git] / src / testbed / testbed_api.c
index 053d730ffe968992b710028d3d1fe37242c62e23..c55e7373a00bc72ded931b034ce82b07ecb5d558 100644 (file)
@@ -379,7 +379,7 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c,
   uint64_t op_id;
 
   op_id = GNUNET_ntohll (msg->operation_id);
-  LOG_DEBUG ("Operation %ul successful\n", op_id);
+  LOG_DEBUG ("Operation %lu successful\n", op_id);
   if (NULL == (opc = find_opc (c, op_id)))
   {
     LOG_DEBUG ("Operation not found\n");
@@ -724,13 +724,13 @@ handle_op_fail_event (struct GNUNET_TESTBED_Controller *c,
     LOG_DEBUG ("Operation not found\n");
     return GNUNET_YES;
   }
-  GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
   if (OP_FORWARDED == opc->type)
   {
     handle_forwarded_operation_msg (c, opc,
                                    (const struct GNUNET_MessageHeader *) msg);
     return GNUNET_YES;
   }
+  GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
   opc->state = OPC_STATE_FINISHED;
   emsg = GNUNET_TESTBED_parse_error_string_ (msg);
   if (NULL == emsg)
@@ -1566,6 +1566,7 @@ GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle
   unsigned long long max_parallel_operations;
   unsigned long long max_parallel_service_connections;
   unsigned long long max_parallel_topology_config_operations;
+  unsigned long long max_parallel_overlay_connect_operations;
 
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_number (cfg, "testbed",
@@ -1591,6 +1592,14 @@ GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle
     GNUNET_break (0);
     return NULL;
   }
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_number (cfg, "testbed",
+                                             "MAX_PARALLEL_OVERLAY_CONNECT_OPERATIONS",
+                                             &max_parallel_overlay_connect_operations))
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
   controller = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Controller));
   controller->cc = cc;
   controller->cc_cls = cc_cls;
@@ -1628,7 +1637,10 @@ GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle
                                               max_parallel_service_connections);
   controller->opq_parallel_topology_config_operations=
       GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
-                                              max_parallel_service_connections);
+                                              max_parallel_topology_config_operations);
+  controller->opq_parallel_overlay_connect_operations=
+      GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
+                                              max_parallel_overlay_connect_operations);
   controller_hostname = GNUNET_TESTBED_host_get_hostname_ (host);
   if (NULL == controller_hostname)
     controller_hostname = "127.0.0.1";
@@ -1719,6 +1731,8 @@ GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller
       (controller->opq_parallel_service_connections);
   GNUNET_TESTBED_operation_queue_destroy_
       (controller->opq_parallel_topology_config_operations);
+  GNUNET_TESTBED_operation_queue_destroy_
+      (controller->opq_parallel_overlay_connect_operations);
   GNUNET_free (controller);
 }
 
@@ -1870,6 +1884,7 @@ GNUNET_TESTBED_controller_link_2_ (void *op_cls,
                                         &oprelease_link_controllers);
   GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations,
                                           opc->op);
+  GNUNET_TESTBED_operation_begin_wait_ (opc->op);
   return opc->op;
 }
 
@@ -1920,7 +1935,6 @@ GNUNET_TESTBED_controller_link_2 (void *op_cls,
                                             slave_host_id,
                                             sxcfg, sxcfg_size,
                                             scfg_size, is_subordinate);
-  GNUNET_break (0);
 }
 
 
@@ -1956,9 +1970,11 @@ GNUNET_TESTBED_compress_config_ (const char *config, size_t size,
  * @param op_cls the operation closure for the event which is generated to
  *          signal success or failure of this operation
  * @param master handle to the master controller who creates the association
- * @param delegated_host requests to which host should be delegated; cannot be NULL
- * @param slave_host which host is used to run the slave controller; use NULL to
- *          make the master controller connect to the delegated host
+ * @param delegated_host_id id of the host to which requests should be
+ *          delegated; cannot be NULL
+ * @param slave_host_id id of the host which should connect to controller
+ *          running on delegated host ; use NULL to make the master controller
+ *          connect to the delegated host
  * @param slave_cfg configuration to use for the slave controller
  * @param is_subordinate GNUNET_YES if the controller at delegated_host should
  *          be started by the slave controller; GNUNET_NO if the slave
@@ -2038,8 +2054,9 @@ GNUNET_TESTBED_controller_link (void *op_cls,
 
   GNUNET_assert (GNUNET_YES ==
                  GNUNET_TESTBED_is_host_registered_ (delegated_host, master));
-  slave_host_id = (NULL == slave_host) ?
-      0 : GNUNET_TESTBED_host_get_id_ (slave_host);
+  slave_host_id = 
+      GNUNET_TESTBED_host_get_id_ ((NULL != slave_host)
+                                   ? slave_host : master->host);
   delegated_host_id = GNUNET_TESTBED_host_get_id_ (delegated_host);
   if ((NULL != slave_host) && (0 != slave_host_id))
     GNUNET_assert (GNUNET_YES ==
@@ -2060,9 +2077,9 @@ GNUNET_TESTBED_controller_link (void *op_cls,
  *
  * @param op_cls the closure for the operation
  * @param master the handle to master controller
- * @param slave_host the host where the slave controller is running; the handle
- *          to the slave_host should remain valid until this operation is
- *          cancelled or marked as finished
+ * @param slave_host_id id of the host where the slave controller is running to
+ *          the slave_host should remain valid until this operation is cancelled
+ *          or marked as finished
  * @return the operation handle;
  */
 struct GNUNET_TESTBED_Operation *
@@ -2087,6 +2104,7 @@ GNUNET_TESTBED_get_slave_config_ (void *op_cls,
                                         &oprelease_get_slave_config);
   GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations,
                                          opc->op); 
+  GNUNET_TESTBED_operation_begin_wait_ (opc->op);
   return opc->op;
 }
 
@@ -2215,21 +2233,7 @@ GNUNET_TESTBED_operation_cancel (struct GNUNET_TESTBED_Operation *operation)
 void
 GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation)
 {
-  switch (operation->type)
-  {
-  case OP_PEER_CREATE:
-  case OP_PEER_DESTROY:
-  case OP_PEER_START:
-  case OP_PEER_STOP:
-  case OP_PEER_INFO:
-  case OP_OVERLAY_CONNECT:
-  case OP_LINK_CONTROLLERS:
     GNUNET_TESTBED_operation_release_ (operation);
-    return;
-  default:
-    GNUNET_assert (0);
-    break;
-  }
 }