gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r26101 - gnunet/src/testbed
Date: Thu, 14 Feb 2013 13:33:43 +0100

Author: harsha
Date: 2013-02-14 13:33:43 +0100 (Thu, 14 Feb 2013)
New Revision: 26101

Modified:
   gnunet/src/testbed/testbed_api.c
   gnunet/src/testbed/testbed_api.h
   gnunet/src/testbed/testbed_api_hosts.c
   gnunet/src/testbed/testbed_api_hosts.h
   gnunet/src/testbed/testbed_api_peers.c
Log:
move parallel overlay connect operation queue from controller handle to host 
handle

Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c    2013-02-14 12:10:02 UTC (rev 26100)
+++ gnunet/src/testbed/testbed_api.c    2013-02-14 12:33:43 UTC (rev 26101)
@@ -1322,27 +1322,6 @@
 
 
 /**
- * Initializes the operation queue for parallel overlay connects
- *
- * @param c the controller handle
- * @param npoc the number of parallel overlay connects - the queue size
- */
-static void
-GNUNET_TESTBED_set_num_parallel_overlay_connects_ (struct
-                                                   GNUNET_TESTBED_Controller 
*c,
-                                                   unsigned int npoc)
-{
-  fprintf (stderr, "%d", npoc);
-  GNUNET_free_non_null (c->tslots);
-  c->tslots_filled = 0;
-  c->num_parallel_connects = npoc;
-  c->tslots = GNUNET_malloc (npoc * sizeof (struct TimeSlot));
-  GNUNET_TESTBED_operation_queue_reset_max_active_
-      (c->opq_parallel_overlay_connect_operations, npoc);
-}
-
-
-/**
  * Function to copy NULL terminated list of arguments
  *
  * @param argv the NULL terminated list of arguments. Cannot be NULL.
@@ -1718,10 +1697,6 @@
   controller->opq_parallel_topology_config_operations =
       GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
                                               
max_parallel_topology_config_operations);
-  controller->opq_parallel_overlay_connect_operations =
-      GNUNET_TESTBED_operation_queue_create_ (0);
-  GNUNET_TESTBED_set_num_parallel_overlay_connects_ (controller, 1);
-  controller->poc_sd = GNUNET_TESTBED_SD_init_ (10);
   controller_hostname = GNUNET_TESTBED_host_get_hostname (host);
   if (NULL == controller_hostname)
     controller_hostname = "127.0.0.1";
@@ -1812,10 +1787,6 @@
       (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_TESTBED_SD_destroy_ (controller->poc_sd);
-  GNUNET_free_non_null (controller->tslots);
   GNUNET_free (controller);
 }
 
@@ -2430,169 +2401,4 @@
 }
 
 
-/**
- * Returns a timing slot which will be exclusively locked
- *
- * @param c the controller handle
- * @param key a pointer which is associated to the returned slot; should not be
- *          NULL. It serves as a key to determine the correct owner of the slot
- * @return the time slot index in the array of time slots in the controller
- *           handle
- */
-unsigned int
-GNUNET_TESTBED_get_tslot_ (struct GNUNET_TESTBED_Controller *c, void *key)
-{
-  unsigned int slot;
-
-  GNUNET_assert (NULL != c->tslots);
-  GNUNET_assert (NULL != key);
-  for (slot = 0; slot < c->num_parallel_connects; slot++)
-    if (NULL == c->tslots[slot].key)
-    {
-      c->tslots[slot].key = key;
-      return slot;
-    }
-  GNUNET_assert (0);            /* We should always find a free tslot */
-}
-
-
-/**
- * Decides whether any change in the number of parallel overlay connects is
- * necessary to adapt to the load on the system
- *
- * @param c the controller handle
- */
-static void
-decide_npoc (struct GNUNET_TESTBED_Controller *c)
-{
-  struct GNUNET_TIME_Relative avg;
-  int sd;
-  unsigned int slot;
-  unsigned int nvals;
-
-  if (c->tslots_filled != c->num_parallel_connects)
-    return;
-  avg = GNUNET_TIME_UNIT_ZERO;
-  nvals = 0;
-  for (slot = 0; slot < c->num_parallel_connects; slot++)
-  {
-    avg = GNUNET_TIME_relative_add (avg, c->tslots[slot].time);
-    nvals += c->tslots[slot].nvals;
-  }
-  GNUNET_assert (nvals >= c->num_parallel_connects);
-  avg = GNUNET_TIME_relative_divide (avg, nvals);
-  GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value != avg.rel_value);
-  sd = GNUNET_TESTBED_SD_deviation_factor_ (c->poc_sd, (unsigned int) 
avg.rel_value);
-  if ( (sd <= 5) ||
-       (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
-                                      c->num_parallel_connects)) )
-    GNUNET_TESTBED_SD_add_data_ (c->poc_sd, (unsigned int) avg.rel_value);
-  if (GNUNET_SYSERR == sd)
-  {
-    GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c,
-                                                       
c->num_parallel_connects);
-    return;
-  }
-  GNUNET_assert (0 <= sd);
-  if (0 == sd)
-  {
-    GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c,
-                                                       c->num_parallel_connects
-                                                       * 2);
-    return;
-  }
-  if (1 == sd)
-  {
-    GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c,
-                                                       c->num_parallel_connects
-                                                       + 1);
-    return;
-  }
-  if (1 == c->num_parallel_connects)
-  {
-    GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c, 1);
-    return;
-  }
-  if (2 == sd)
-  {
-    GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c,
-                                                       c->num_parallel_connects
-                                                       - 1);
-    return;
-  }
-  GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c,
-                                                     c->num_parallel_connects /
-                                                     2);
-}
-
-
-/**
- * Releases a time slot thus making it available for be used again
- *
- * @param c the controller handle
- * @param index the index of the the time slot
- * @param key the key to prove ownership of the timeslot
- * @return GNUNET_YES if the time slot is successfully removed; GNUNET_NO if 
the
- *           time slot cannot be removed - this could be because of the index
- *           greater than existing number of time slots or `key' being 
different
- */
-int
-GNUNET_TESTBED_release_time_slot_ (struct GNUNET_TESTBED_Controller *c,
-                                   unsigned int index, void *key)
-{
-  struct TimeSlot *slot;
-
-  GNUNET_assert (NULL != key);
-  if (index >= c->num_parallel_connects)
-    return GNUNET_NO;
-  slot = &c->tslots[index];
-  if (key != slot->key)
-    return GNUNET_NO;
-  slot->key = NULL;
-  return GNUNET_YES;
-}
-
-
-/**
- * Function to update a time slot
- *
- * @param c the controller handle
- * @param index the index of the time slot to update
- * @param key the key to identify ownership of the slot
- * @param time the new time
- * @param failed should this reading be treated as coming from a fail event
- */
-void
-GNUNET_TESTBED_update_time_slot_ (struct GNUNET_TESTBED_Controller *c,
-                                  unsigned int index, void *key,
-                                  struct GNUNET_TIME_Relative time, int failed)
-{
-  struct TimeSlot *slot;
-
-  if (GNUNET_YES == failed)
-  {
-    if (1 == c->num_parallel_connects)
-    {
-      GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c, 1);
-      return;
-    }
-    GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c,
-                                                       c->num_parallel_connects
-                                                       - 1);
-  }
-  if (GNUNET_NO == GNUNET_TESTBED_release_time_slot_ (c, index, key))
-    return;
-  slot = &c->tslots[index];
-  slot->nvals++;
-  if (GNUNET_TIME_UNIT_ZERO.rel_value == slot->time.rel_value)
-  {
-    slot->time = time;
-    c->tslots_filled++;
-    decide_npoc (c);
-    return;
-  }
-  slot->time = GNUNET_TIME_relative_add (slot->time, time);
-}
-
-
 /* end of testbed_api.c */

Modified: gnunet/src/testbed/testbed_api.h
===================================================================
--- gnunet/src/testbed/testbed_api.h    2013-02-14 12:10:02 UTC (rev 26100)
+++ gnunet/src/testbed/testbed_api.h    2013-02-14 12:33:43 UTC (rev 26101)
@@ -178,34 +178,6 @@
 
 
 /**
- * Opaque handle for SD calculations
- */
-struct SDHandle;
-
-
-/**
- * A slot to record time taken by an overlay connect operation
- */
-struct TimeSlot
-{
-  /**
-   * A key to identify this timeslot
-   */
-  void *key;
-
-  /**
-   * Time
-   */
-  struct GNUNET_TIME_Relative time;
-
-  /**
-   * Number of timing values accumulated
-   */
-  unsigned int nvals;
-};
-
-
-/**
  * Handle to interact with a GNUnet testbed controller.  Each
  * controller has at least one master handle which is created when the
  * controller is created; this master handle interacts with the
@@ -298,23 +270,6 @@
   struct OperationQueue *opq_parallel_topology_config_operations;
 
   /**
-   * Operation queue for simultaneous overlay connect operations
-   */
-  struct OperationQueue *opq_parallel_overlay_connect_operations;
-
-  /**
-   * An array of timing slots; size should be equal to the current number of 
parallel
-   * overlay connects
-   */
-  struct TimeSlot *tslots;
-
-  /**
-   * Handle for SD calculations amount parallel overlay connect operation 
finish
-   * times
-   */
-  struct SDHandle *poc_sd;
-
-  /**
    * The controller event mask
    */
   uint64_t event_mask;
@@ -330,16 +285,6 @@
   int aux_host;
 
   /**
-   * The number of parallel overlay connects we do currently
-   */
-  unsigned int num_parallel_connects;
-
-  /**
-   * Counter to indicate when all the available time slots are filled
-   */
-  unsigned int tslots_filled;
-
-  /**
    * The operation id counter. use current value and increment
    */
   uint32_t operation_counter;
@@ -541,50 +486,7 @@
                                  *slave_cfg, int is_subordinate);
 
 
-/**
- * Returns a timing slot which will be exclusively locked
- *
- * @param c the controller handle
- * @param key a pointer which is associated to the returned slot; should not be
- *          NULL. It serves as a key to determine the correct owner of the slot
- * @return the time slot index in the array of time slots in the controller
- *           handle
- */
-unsigned int
-GNUNET_TESTBED_get_tslot_ (struct GNUNET_TESTBED_Controller *c, void *key);
 
 
-/**
- * Function to update a time slot
- *
- * @param c the controller handle
- * @param index the index of the time slot to update
- * @param key the key to identify ownership of the slot
- * @param time the new time
- * @param failed should this reading be treated as coming from a fail event
- */
-void
-GNUNET_TESTBED_update_time_slot_ (struct GNUNET_TESTBED_Controller *c,
-                                  unsigned int index, void *key,
-                                  struct GNUNET_TIME_Relative time, int 
failed);
-
-
-/**
- * Releases a time slot thus making it available for be used again
- *
- * @param c the controller handle
- * @param index the index of the the time slot
- * @param key the key to prove ownership of the timeslot
- * @return GNUNET_YES if the time slot is successfully removed; GNUNET_NO if 
the
- *           time slot cannot be removed - this could be because of the index
- *           greater than existing number of time slots or `key' being 
different
- */
-int
-GNUNET_TESTBED_release_time_slot_ (struct GNUNET_TESTBED_Controller *c,
-                                   unsigned int index, void *key);
-
-
-
-
 #endif
 /* end of testbed_api.h */

Modified: gnunet/src/testbed/testbed_api_hosts.c
===================================================================
--- gnunet/src/testbed/testbed_api_hosts.c      2013-02-14 12:10:02 UTC (rev 
26100)
+++ gnunet/src/testbed/testbed_api_hosts.c      2013-02-14 12:33:43 UTC (rev 
26101)
@@ -33,6 +33,8 @@
 
 #include "testbed_api.h"
 #include "testbed_api_hosts.h"
+#include "testbed_api_operations.h"
+#include "testbed_api_sd.h"
 
 /**
  * Generic logging shorthand
@@ -69,6 +71,28 @@
 
 
 /**
+ * A slot to record time taken by an overlay connect operation
+ */
+struct TimeSlot
+{
+  /**
+   * A key to identify this timeslot
+   */
+  void *key;
+
+  /**
+   * Time
+   */
+  struct GNUNET_TIME_Relative time;
+
+  /**
+   * Number of timing values accumulated
+   */
+  unsigned int nvals;
+};
+
+
+/**
  * Opaque handle to a host running experiments managed by the testing 
framework.
  * The master process must be able to SSH to this host without password (via
  * ssh-agent).
@@ -107,6 +131,34 @@
   struct RegisteredController *rc_tail;
 
   /**
+   * Operation queue for simultaneous overlay connect operations target at this
+   * host
+   */
+  struct OperationQueue *opq_parallel_overlay_connect_operations;
+
+  /**
+   * An array of timing slots; size should be equal to the current number of 
parallel
+   * overlay connects
+   */
+  struct TimeSlot *tslots;
+
+  /**
+   * Handle for SD calculations amount parallel overlay connect operation 
finish
+   * times
+   */
+  struct SDHandle *poc_sd;
+
+  /**
+   * The number of parallel overlay connects we do currently
+   */
+  unsigned int num_parallel_connects;
+
+  /**
+   * Counter to indicate when all the available time slots are filled
+   */
+  unsigned int tslots_filled;
+
+  /**
    * Global ID we use to refer to a host on the network
    */
   uint32_t id;
@@ -241,7 +293,11 @@
   host->hostname = (NULL != hostname) ? GNUNET_strdup (hostname) : NULL;
   host->username = (NULL != username) ? GNUNET_strdup (username) : NULL;
   host->id = id;
-  host->port = (0 == port) ? 22 : port;
+  host->port = (0 == port) ? 22 : port;  
+  host->opq_parallel_overlay_connect_operations =
+      GNUNET_TESTBED_operation_queue_create_ (0);
+  GNUNET_TESTBED_set_num_parallel_overlay_connects_ (host, 1);
+  host->poc_sd = GNUNET_TESTBED_SD_init_ (10);
   new_size = host_list_size;
   while (id >= new_size)
     new_size += HOST_LIST_GROW_STEP;
@@ -389,6 +445,10 @@
   }
   GNUNET_free_non_null ((char *) host->username);
   GNUNET_free_non_null ((char *) host->hostname);
+  GNUNET_TESTBED_operation_queue_destroy_
+      (host->opq_parallel_overlay_connect_operations);
+  GNUNET_TESTBED_SD_destroy_ (host->poc_sd);
+  GNUNET_free_non_null (host->tslots);
   GNUNET_free (host);
   while (host_list_size >= HOST_LIST_GROW_STEP)
   {
@@ -661,4 +721,207 @@
   GNUNET_free (handle);
 }
 
+
+/**
+ * Initializes the operation queue for parallel overlay connects
+ *
+ * @param h the host handle
+ * @param npoc the number of parallel overlay connects - the queue size
+ */
+void
+GNUNET_TESTBED_set_num_parallel_overlay_connects_ (struct
+                                                   GNUNET_TESTBED_Host *h,
+                                                   unsigned int npoc)
+{
+  fprintf (stderr, "%d", npoc);
+  GNUNET_free_non_null (h->tslots);
+  h->tslots_filled = 0;
+  h->num_parallel_connects = npoc;
+  h->tslots = GNUNET_malloc (npoc * sizeof (struct TimeSlot));
+  GNUNET_TESTBED_operation_queue_reset_max_active_
+      (h->opq_parallel_overlay_connect_operations, npoc);
+}
+
+
+/**
+ * Returns a timing slot which will be exclusively locked
+ *
+ * @param h the host handle
+ * @param key a pointer which is associated to the returned slot; should not be
+ *          NULL. It serves as a key to determine the correct owner of the slot
+ * @return the time slot index in the array of time slots in the controller
+ *           handle
+ */
+unsigned int
+GNUNET_TESTBED_get_tslot_ (struct GNUNET_TESTBED_Host *h, void *key)
+{
+  unsigned int slot;
+
+  GNUNET_assert (NULL != h->tslots);
+  GNUNET_assert (NULL != key);
+  for (slot = 0; slot < h->num_parallel_connects; slot++)
+    if (NULL == h->tslots[slot].key)
+    {
+      h->tslots[slot].key = key;
+      return slot;
+    }
+  GNUNET_assert (0);            /* We should always find a free tslot */
+}
+
+
+/**
+ * Decides whether any change in the number of parallel overlay connects is
+ * necessary to adapt to the load on the system
+ *
+ * @param h the host handle
+ */
+static void
+decide_npoc (struct GNUNET_TESTBED_Host *h)
+{
+  struct GNUNET_TIME_Relative avg;
+  int sd;
+  unsigned int slot;
+  unsigned int nvals;
+
+  if (h->tslots_filled != h->num_parallel_connects)
+    return;
+  avg = GNUNET_TIME_UNIT_ZERO;
+  nvals = 0;
+  for (slot = 0; slot < h->num_parallel_connects; slot++)
+  {
+    avg = GNUNET_TIME_relative_add (avg, h->tslots[slot].time);
+    nvals += h->tslots[slot].nvals;
+  }
+  GNUNET_assert (nvals >= h->num_parallel_connects);
+  avg = GNUNET_TIME_relative_divide (avg, nvals);
+  GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value != avg.rel_value);
+  sd = GNUNET_TESTBED_SD_deviation_factor_ (h->poc_sd, (unsigned int) 
avg.rel_value);
+  if ( (sd <= 5) ||
+       (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+                                      h->num_parallel_connects)) )
+    GNUNET_TESTBED_SD_add_data_ (h->poc_sd, (unsigned int) avg.rel_value);
+  if (GNUNET_SYSERR == sd)
+  {
+    GNUNET_TESTBED_set_num_parallel_overlay_connects_ (h,
+                                                       
h->num_parallel_connects);
+    return;
+  }
+  GNUNET_assert (0 <= sd);
+  if (0 == sd)
+  {
+    GNUNET_TESTBED_set_num_parallel_overlay_connects_ (h,
+                                                       h->num_parallel_connects
+                                                       * 2);
+    return;
+  }
+  if (1 == sd)
+  {
+    GNUNET_TESTBED_set_num_parallel_overlay_connects_ (h,
+                                                       h->num_parallel_connects
+                                                       + 1);
+    return;
+  }
+  if (1 == h->num_parallel_connects)
+  {
+    GNUNET_TESTBED_set_num_parallel_overlay_connects_ (h, 1);
+    return;
+  }
+  if (2 == sd)
+  {
+    GNUNET_TESTBED_set_num_parallel_overlay_connects_ (h,
+                                                       h->num_parallel_connects
+                                                       - 1);
+    return;
+  }
+  GNUNET_TESTBED_set_num_parallel_overlay_connects_ (h,
+                                                     h->num_parallel_connects /
+                                                     2);
+}
+
+
+/**
+ * Releases a time slot thus making it available for be used again
+ *
+ * @param h the host handle
+ * @param index the index of the the time slot
+ * @param key the key to prove ownership of the timeslot
+ * @return GNUNET_YES if the time slot is successfully removed; GNUNET_NO if 
the
+ *           time slot cannot be removed - this could be because of the index
+ *           greater than existing number of time slots or `key' being 
different
+ */
+int
+GNUNET_TESTBED_release_time_slot_ (struct GNUNET_TESTBED_Host *h,
+                                   unsigned int index, void *key)
+{
+  struct TimeSlot *slot;
+
+  GNUNET_assert (NULL != key);
+  if (index >= h->num_parallel_connects)
+    return GNUNET_NO;
+  slot = &h->tslots[index];
+  if (key != slot->key)
+    return GNUNET_NO;
+  slot->key = NULL;
+  return GNUNET_YES;
+}
+
+
+/**
+ * Function to update a time slot
+ *
+ * @param h the host handle
+ * @param index the index of the time slot to update
+ * @param key the key to identify ownership of the slot
+ * @param time the new time
+ * @param failed should this reading be treated as coming from a fail event
+ */
+void
+GNUNET_TESTBED_update_time_slot_ (struct GNUNET_TESTBED_Host *h,
+                                  unsigned int index, void *key,
+                                  struct GNUNET_TIME_Relative time, int failed)
+{
+  struct TimeSlot *slot;
+
+  if (GNUNET_YES == failed)
+  {
+    if (1 == h->num_parallel_connects)
+    {
+      GNUNET_TESTBED_set_num_parallel_overlay_connects_ (h, 1);
+      return;
+    }
+    GNUNET_TESTBED_set_num_parallel_overlay_connects_ (h,
+                                                       h->num_parallel_connects
+                                                       - 1);
+  }
+  if (GNUNET_NO == GNUNET_TESTBED_release_time_slot_ (h, index, key))
+    return;
+  slot = &h->tslots[index];
+  slot->nvals++;
+  if (GNUNET_TIME_UNIT_ZERO.rel_value == slot->time.rel_value)
+  {
+    slot->time = time;
+    h->tslots_filled++;
+    decide_npoc (h);
+    return;
+  }
+  slot->time = GNUNET_TIME_relative_add (slot->time, time);
+}
+
+
+/**
+ * Queues the given operation in the queue for parallel overlay connects of the
+ * given host
+ *
+ * @param h the host handle
+ * @param op the operation to queue in the given host's parally overlay connect
+ *          queue 
+ */
+void
+GNUNET_TESTBED_host_queue_oc (struct GNUNET_TESTBED_Host *h, 
+                              struct GNUNET_TESTBED_Operation *op)
+{  
+  GNUNET_TESTBED_operation_queue_insert_
+      (h->opq_parallel_overlay_connect_operations, op);
+}
+
 /* end of testbed_api_hosts.c */

Modified: gnunet/src/testbed/testbed_api_hosts.h
===================================================================
--- gnunet/src/testbed/testbed_api_hosts.h      2013-02-14 12:10:02 UTC (rev 
26100)
+++ gnunet/src/testbed/testbed_api_hosts.h      2013-02-14 12:33:43 UTC (rev 
26101)
@@ -87,49 +87,6 @@
 
 
 /**
- * Opaque wrapper around GNUNET_HELPER_Handle
- */
-struct GNUNET_TESTBED_HelperHandle;
-
-
-/* /\** */
-/*  * Run a given helper process at the given host.  Communication */
-/*  * with the helper will be via GNUnet messages on stdin/stdout. */
-/*  * Runs the process via 'ssh' at the specified host, or locally. */
-/*  * Essentially an SSH-wrapper around the 'gnunet_helper_lib.h' API. */
-/*  *  */
-/*  * @param controller_ip the ip address of the controller. Will be set as 
TRUSTED */
-/*  *          host when starting testbed controller at host */
-/*  * @param host host to use, use "NULL" for localhost */
-/*  * @param binary_argv binary name and command-line arguments to give to the 
*/
-/*  *          binary */
-/*  * @param cfg template configuration to use for the remote controller; the 
*/
-/*  *          remote controller will be started with a slightly modified */
-/*  *          configuration (port numbers, unix domain sockets and service 
home */
-/*  *          values are changed as per TESTING library on the remote host) */
-/*  * @param cb the callback to run when helper process dies; cannot be NULL */
-/*  * @param cb_cls the closure for the above callback */
-/*  * @return handle to terminate the command, NULL on error */
-/*  *\/ */
-/* struct GNUNET_TESTBED_HelperHandle * */
-/* GNUNET_TESTBED_host_run_ (const char *controller_ip, */
-/*                       const struct GNUNET_TESTBED_Host *host, */
-/*                       const struct GNUNET_CONFIGURATION_Handle *cfg, */
-/*                       GNUNET_HELPER_ExceptionCallback cb, */
-/*                       void *cb_cls); */
-
-
-
-/* /\** */
-/*  * Stops a helper in the HelperHandle using GNUNET_HELPER_stop */
-/*  * */
-/*  * @param handle the handle returned from GNUNET_TESTBED_host_start_ */
-/*  *\/ */
-/* void */
-/* GNUNET_TESTBED_host_stop_ (struct GNUNET_TESTBED_HelperHandle *handle); */
-
-
-/**
  * Marks a host as registered with a controller
  *
  * @param host the host to mark
@@ -154,6 +111,72 @@
                                     *controller);
 
 
+/**
+ * (re)sets the operation queue for parallel overlay connects
+ *
+ * @param h the host handle
+ * @param npoc the number of parallel overlay connects - the queue size
+ */
+void
+GNUNET_TESTBED_set_num_parallel_overlay_connects_ (struct
+                                                   GNUNET_TESTBED_Host *h,
+                                                   unsigned int npoc);
 
+
+/**
+ * Releases a time slot thus making it available for be used again
+ *
+ * @param h the host handle
+ * @param index the index of the the time slot
+ * @param key the key to prove ownership of the timeslot
+ * @return GNUNET_YES if the time slot is successfully removed; GNUNET_NO if 
the
+ *           time slot cannot be removed - this could be because of the index
+ *           greater than existing number of time slots or `key' being 
different
+ */
+int
+GNUNET_TESTBED_release_time_slot_ (struct GNUNET_TESTBED_Host *h,
+                                   unsigned int index, void *key);
+
+
+/**
+ * Function to update a time slot
+ *
+ * @param h the host handle
+ * @param index the index of the time slot to update
+ * @param key the key to identify ownership of the slot
+ * @param time the new time
+ * @param failed should this reading be treated as coming from a fail event
+ */
+void
+GNUNET_TESTBED_update_time_slot_ (struct GNUNET_TESTBED_Host *h,
+                                  unsigned int index, void *key,
+                                  struct GNUNET_TIME_Relative time, int 
failed);
+
+
+/**
+ * Returns a timing slot which will be exclusively locked
+ *
+ * @param h the host handle
+ * @param key a pointer which is associated to the returned slot; should not be
+ *          NULL. It serves as a key to determine the correct owner of the slot
+ * @return the time slot index in the array of time slots in the controller
+ *           handle
+ */
+unsigned int
+GNUNET_TESTBED_get_tslot_ (struct GNUNET_TESTBED_Host *h, void *key);
+
+
+/**
+ * Queues the given operation in the queue for parallel overlay connects of the
+ * given host
+ *
+ * @param h the host handle
+ * @param op the operation to queue in the given host's parally overlay connect
+ *          queue 
+ */
+void
+GNUNET_TESTBED_host_queue_oc (struct GNUNET_TESTBED_Host *h, 
+                              struct GNUNET_TESTBED_Operation *op);
+
 #endif
 /* end of testbed_api_hosts.h */

Modified: gnunet/src/testbed/testbed_api_peers.c
===================================================================
--- gnunet/src/testbed/testbed_api_peers.c      2013-02-14 12:10:02 UTC (rev 
26100)
+++ gnunet/src/testbed/testbed_api_peers.c      2013-02-14 12:33:43 UTC (rev 
26101)
@@ -340,7 +340,7 @@
   opc->state = OPC_STATE_STARTED;
   data = opc->data;
   GNUNET_assert (NULL != data);
-  data->tslot_index = GNUNET_TESTBED_get_tslot_ (opc->c, data);
+  data->tslot_index = GNUNET_TESTBED_get_tslot_ (data->p1->host, data);
   data->tstart = GNUNET_TIME_absolute_get ();
   msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_OverlayConnectMessage));
   msg->header.size =
@@ -373,13 +373,14 @@
   case OPC_STATE_INIT:
     break;
   case OPC_STATE_STARTED:
-    (void) GNUNET_TESTBED_release_time_slot_ (opc->c, data->tslot_index, data);
+    (void) GNUNET_TESTBED_release_time_slot_ (data->p1->host, 
data->tslot_index,
+                                              data);
     GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
     break;
   case OPC_STATE_FINISHED:
     duration = GNUNET_TIME_absolute_get_duration (data->tstart);
-    GNUNET_TESTBED_update_time_slot_ (opc->c, data->tslot_index, data, 
duration,
-                                      data->failed);
+    GNUNET_TESTBED_update_time_slot_ (data->p1->host, data->tslot_index, data,
+                                      duration, data->failed);
   }
   GNUNET_free (data);
   GNUNET_free (opc);
@@ -693,9 +694,7 @@
   opc->op =
       GNUNET_TESTBED_operation_create_ (opc, &opstart_overlay_connect,
                                         &oprelease_overlay_connect);
-  GNUNET_TESTBED_operation_queue_insert_ (opc->
-                                          
c->opq_parallel_overlay_connect_operations,
-                                          opc->op);
+  GNUNET_TESTBED_host_queue_oc (p1->host, opc->op);
   GNUNET_TESTBED_operation_begin_wait_ (opc->op);
   return opc->op;
 }




reply via email to

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