towards handling suboperations during overlay connect
[oweals/gnunet.git] / src / testbed / gnunet-service-testbed.c
index 1bd22958e9042679e35154359a599a5df7b83f09..05d296fee451ef07d68dd7175a5608ce56a30b8c 100644 (file)
@@ -180,8 +180,7 @@ struct Slave
   struct GNUNET_TESTBED_Controller *controller;
 
   /**
-   * The configuration of the slave. Will be NULL for slave which we didn't
-   * directly start
+   * The configuration of the slave. Cannot be NULL
    */
   struct GNUNET_CONFIGURATION_Handle *cfg;
 
@@ -1546,7 +1545,7 @@ handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client,
           GNUNET_TESTBED_controller_connect (cfg, host_list[slave->host_id],
                                              master_context->event_mask,
                                              &slave_event_callback, slave);
-      GNUNET_CONFIGURATION_destroy (cfg);
+      slave->cfg = cfg;
       if (NULL != slave->controller)
         send_operation_success_msg (client, GNUNET_ntohll (msg->operation_id));
       else
@@ -2474,23 +2473,31 @@ handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
     if ((peer2_host_id >= slave_list_size)
        || (NULL ==slave_list[peer2_host_id]))
     {
-      /* Peer2's host is located above us or lateral to us.. 
-         FIXME: should try to ask for the configuration of peer2's host by
-         sending a reply asking for its configuration */
-      GNUNET_break (0);
-      GNUNET_SERVER_client_drop (client);
+      struct GNUNET_TESTBED_NeedControllerConfig *reply;
+
       GNUNET_free (occ);
-      GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+      reply = GNUNET_malloc (sizeof (struct
+                                     GNUNET_TESTBED_NeedControllerConfig)); 
+      reply->header.size = htons (sizeof (struct
+                                          GNUNET_TESTBED_NeedControllerConfig));
+      reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_NEEDCONTROLLERCONFIG);
+      reply->controller_host_id = msg->peer2_host_id;
+      reply->operation_id = msg->operation_id;
+      queue_message (client, &reply->header);      
+      GNUNET_SERVER_receive_done (client, GNUNET_OK);
       return;
     }
-    occ->peer2_controller = slave_list[peer2_host_id]->controller;
-    if (NULL == occ->peer2_controller)
+    else
     {
-      GNUNET_break (0);
-      GNUNET_SERVER_client_drop (client);
-      GNUNET_free (occ);
-      GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
-      return;
+      occ->peer2_controller = slave_list[peer2_host_id]->controller;
+      if (NULL == occ->peer2_controller)
+      {
+        GNUNET_break (0);       /* What's going on? */
+        GNUNET_SERVER_client_drop (client);
+        GNUNET_free (occ);
+        GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+        return;
+      }
     }
   }
   else