- towards operation queues for open file descriptors
authorSree Harsha Totakura <totakura@in.tum.de>
Fri, 25 Jan 2013 15:11:47 +0000 (15:11 +0000)
committerSree Harsha Totakura <totakura@in.tum.de>
Fri, 25 Jan 2013 15:11:47 +0000 (15:11 +0000)
src/testbed/gnunet-service-testbed.c
src/testbed/gnunet-service-testbed.h
src/testbed/gnunet-service-testbed_oc.c

index a9e77789a41116b17de7182d0a9bfbc13a6be08c..e767413eed369664c30e2df42fbb8e6645e62fb9 100644 (file)
@@ -68,6 +68,11 @@ struct ForwardedOperationContext *fopcq_head;
  */
 struct ForwardedOperationContext *fopcq_tail;
 
+/**
+ * Operation queue for open file descriptors
+ */
+struct OperationQueue *GST_opq_openfds;
+
 /**
  * The size of the host list
  */
@@ -2113,6 +2118,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   GNUNET_CONFIGURATION_destroy (our_config);
   /* Free hello cache */
   GST_cache_clear ();
+  GNUNET_TESTBED_operation_queue_destroy_ (GST_opq_openfds);
+  GST_opq_openfds = NULL;
 }
 
 
@@ -2197,6 +2204,7 @@ testbed_run (void *cls, struct GNUNET_SERVER_Handle *server,
   GNUNET_SERVER_add_handlers (server, message_handlers);
   GNUNET_SERVER_disconnect_notify (server, &client_disconnect_cb, NULL);
   ss_map = GNUNET_CONTAINER_multihashmap_create (5, GNUNET_NO);
+  GST_opq_openfds = GNUNET_TESTBED_operation_queue_create_ (GST_QLEN_OPENFDS);
   shutdown_task_id =
       GNUNET_SCHEDULER_add_delayed_with_priority (GNUNET_TIME_UNIT_FOREVER_REL,
                                                   GNUNET_SCHEDULER_PRIORITY_IDLE,
index 7d399458186bbcecf23b5dbb42221cdfc1da1ae7..b3e9171444038388f25ea8eb8063f83e2370c920 100644 (file)
  */
 #define LIST_GROW_STEP 10
 
+/**
+ * How long should the operation queue for open file descriptors be?
+ */
+#define GST_QLEN_OPENFDS 512
+
 /**
  * Default timeout for operations which may take some time
  */
@@ -605,6 +610,11 @@ extern struct GNUNET_TESTBED_Host **GST_host_list;
  */
 extern struct Slave **GST_slave_list;
 
+/**
+ * Operation queue for open file descriptors
+ */
+extern struct OperationQueue *GST_opq_openfds;
+
 /**
  * The size of the peer list
  */
index b832e255235da13b69f61c6b6ed7eef1263465ae..f5811194b6b91f46f1eba404d348a27c6b1f6367 100644 (file)
@@ -1006,13 +1006,24 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
   uint32_t p2; 
   uint32_t peer2_host_id;
 
+  if (sizeof (struct GNUNET_TESTBED_OverlayConnectMessage)
+      != ntohs (message->size))
+  {
+    GNUNET_break (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
+  }
   msg = (const struct GNUNET_TESTBED_OverlayConnectMessage *) message;
   p1 = ntohl (msg->peer1);
   p2 = ntohl (msg->peer2);
-  peer2_host_id = ntohl (msg->peer2_host_id);
-  GNUNET_assert (p1 < GST_peer_list_size);
-  GNUNET_assert (NULL != GST_peer_list[p1]);
+  if ((p1 >= GST_peer_list_size) || (NULL == GST_peer_list[p1]))
+  {
+    GNUNET_break (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
+  }
   peer = GST_peer_list[p1];
+  peer2_host_id = ntohl (msg->peer2_host_id);
   operation_id = GNUNET_ntohll (msg->operation_id);  
   LOG_DEBUG ("Received overlay connect for peers %u and %u with op id: 0x%llx\n",
             p1, p2, operation_id);