gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r25670 - gnunet/src/testbed
Date: Tue, 1 Jan 2013 23:44:12 +0100

Author: harsha
Date: 2013-01-01 23:44:12 +0100 (Tue, 01 Jan 2013)
New Revision: 25670

Modified:
   gnunet/src/testbed/standard_deviation.c
   gnunet/src/testbed/test_testbed_api.conf
   gnunet/src/testbed/testbed_api.c
   gnunet/src/testbed/testbed_api.h
   gnunet/src/testbed/testbed_api_peers.c
   gnunet/src/testbed/testbed_api_peers.h
Log:
adaptive parallelism for overlay connect operations based on SD calculations

Modified: gnunet/src/testbed/standard_deviation.c
===================================================================
--- gnunet/src/testbed/standard_deviation.c     2013-01-01 22:43:24 UTC (rev 
25669)
+++ gnunet/src/testbed/standard_deviation.c     2013-01-01 22:44:12 UTC (rev 
25670)
@@ -18,12 +18,41 @@
       Boston, MA 02111-1307, USA.
  */
 
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_common.h>
+#include "platform.h"
+#include "gnunet_util_lib.h"
 
+struct SDEntry
+{
+  /**
+   * DLL next pointer
+   */
+  struct SDEntry *next;
+
+  /**
+   * DLL prev pointer
+   */
+  struct SDEntry *prev;
+  
+  /**
+   * The value to store
+   */
+  unsigned int amount;
+};
+
+
 struct SDHandle
 {
   /**
+   * DLL head for storing entries
+   */
+  struct SDEntry *head;
+  
+  /**
+   * DLL tail for storing entries
+   */
+  struct SDEntry *tail;
+  
+  /**
    * Squared sum of data values
    */
   unsigned long long sqsum;
@@ -36,43 +65,78 @@
   /**
    * The average of data amounts
    */
-  unsigned int avg;
+  float avg;
 
   /**
    * The variance
    */
-  unsigned int vr;
+  double vr;
 
   /**
-   * Number of data values
+   * Number of data values; also the length of DLL containing SDEntries
    */
   unsigned int cnt;
+  
+  /**
+   * max number of entries we can have in the DLL
+   */
+  unsigned int max_cnt;
 };
 
 
 struct SDHandle *
-GNUNET_TESTBED_SD_init ()
+SD_init (unsigned int max_cnt)
 {
-  return GNUNET_malloc (sizeof (struct SDHandle));
+  struct SDHandle *h;
+  
+  GNUNET_assert (1 < max_cnt);
+  h = GNUNET_malloc (sizeof (struct SDHandle));
+  h->max_cnt = max_cnt;
+  return h;
 }
 
 void
-GNUNET_TESTBED_SD_destroy (struct SDHandle *h)
+SD_destroy (struct SDHandle *h)
 {
+  struct SDEntry *entry;
+  
+  while (NULL != (entry = h->head))
+  {
+    GNUNET_CONTAINER_DLL_remove (h->head, h->tail, entry);
+    GNUNET_free (entry);
+  }
   GNUNET_free (h);
 }
 
 void
-GNUNET_TESTBED_SD_add_data (struct SDHandle *h, unsigned int amount)
+SD_add_data (struct SDHandle *h, unsigned int amount)
 {
-  unsigned long sqavg;
+  struct SDEntry *entry;
+  double sqavg;
+  double sqsum_avg;
 
+  entry = NULL;
+  if (h->cnt == h->max_cnt)
+  {
+    entry = h->head;
+    GNUNET_CONTAINER_DLL_remove (h->head, h->tail, entry);
+    h->sum -= entry->amount;
+    h->sqsum -= ((unsigned long) entry->amount) * 
+        ((unsigned long) entry->amount);
+    h->cnt--;
+  }
+  GNUNET_assert (h->cnt < h->max_cnt);
+  if (NULL == entry)
+    entry = GNUNET_malloc (sizeof (struct SDEntry));
+  entry->amount = amount;
+  GNUNET_CONTAINER_DLL_insert_tail (h->head, h->tail, entry);
   h->sum += amount;
   h->cnt++;
+  h->avg = ((float) h->sum) / ((float) h->cnt);
   h->sqsum += ((unsigned long) amount) * ((unsigned long) amount);
-  h->avg = h->sum / h->cnt;
-  sqavg = h->avg * h->avg;
-  h->vr = (h->sqsum / h->cnt) - sqavg;
+  sqsum_avg = ((double) h->sqsum) / ((double) h->cnt);
+  sqavg = ((double) h->avg) * ((double) h->avg);
+  h->vr = sqsum_avg - sqavg;
 }
 
 
@@ -82,23 +146,24 @@
  * @param h the SDhandle
  * @param amount the value for which the deviation is returned
  * @return the deviation from the average; GNUNET_SYSERR if the deviation 
cannot
- *           be calculated
+ *           be calculated; a maximum of 4 is returned for deviations equal to
+ *           or larger than 4
  */
 int
-GNUNET_TESTBED_SD_deviation_factor (struct SDHandle *h, unsigned int amount)
+SD_deviation_factor (struct SDHandle *h, unsigned int amount)
 {
-  unsigned long diff;
+  double diff;
   unsigned int n;
 
   if (h->cnt < 2)
     return GNUNET_SYSERR;
-  if (amount > h->avg)
-    diff = amount - h->avg;
+  if (((float) amount) > h->avg)
+    diff = ((float) amount) - h->avg;
   else
-    diff = h->avg - amount;
+    diff = h->avg - ((float) amount);
   diff *= diff;
   for (n = 1; n < 4; n++)
-    if (diff < (n * n * h->vr))
+    if (diff < (((double) (n * n)) * h->vr))
       break;
   return n;
 }
@@ -107,17 +172,17 @@
 int
 main ()
 {
-  struct SDHandle * h = GNUNET_TESTBED_SD_init ();
+  struct SDHandle * h = SD_init (20);
   
-  GNUNET_TESTBED_SD_add_data (h, 40);
-  GNUNET_TESTBED_SD_add_data (h, 30);
-  GNUNET_TESTBED_SD_add_data (h, 40);
-  GNUNET_TESTBED_SD_add_data (h, 10);
-  GNUNET_TESTBED_SD_add_data (h, 30);
-  printf ("Average: %d\n", h->avg);
-  printf ("Variance: %d\n", h->vr);
-  printf ("Standard Deviation: %d\n", (int) sqrt (h->vr));
-  printf ("Deviation factor: %d\n", GNUNET_TESTBED_SD_deviation (h, 40));
-  GNUNET_TESTBED_SD_destroy (h);
+  SD_add_data (h, 40);
+  SD_add_data (h, 30);
+  SD_add_data (h, 40);
+  SD_add_data (h, 10);
+  SD_add_data (h, 30);
+  printf ("Average: %f\n", h->avg);
+  printf ("Variance: %f\n", h->vr);
+  printf ("Standard Deviation: %f\n", sqrt (h->vr));
+  printf ("Deviation factor: %d\n", SD_deviation_factor (h, 60));
+  SD_destroy (h);
   return 0;
 }

Modified: gnunet/src/testbed/test_testbed_api.conf
===================================================================
--- gnunet/src/testbed/test_testbed_api.conf    2013-01-01 22:43:24 UTC (rev 
25669)
+++ gnunet/src/testbed/test_testbed_api.conf    2013-01-01 22:44:12 UTC (rev 
25670)
@@ -82,3 +82,5 @@
 [consensus]
 AUTOSTART = NO
 
+[gns]
+AUTOSTART = NO
\ No newline at end of file

Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c    2013-01-01 22:43:24 UTC (rev 25669)
+++ gnunet/src/testbed/testbed_api.c    2013-01-01 22:44:12 UTC (rev 25670)
@@ -248,7 +248,168 @@
 };
 
 
+struct SDEntry
+{
+  /**
+   * DLL next pointer
+   */
+  struct SDEntry *next;
+
+  /**
+   * DLL prev pointer
+   */
+  struct SDEntry *prev;
+  
+  /**
+   * The value to store
+   */
+  unsigned int amount;
+};
+
+
+struct SDHandle
+{
+  /**
+   * DLL head for storing entries
+   */
+  struct SDEntry *head;
+  
+  /**
+   * DLL tail for storing entries
+   */
+  struct SDEntry *tail;
+  
+  /**
+   * Squared sum of data values
+   */
+  unsigned long long sqsum;
+
+  /**
+   * Sum of the data values
+   */
+  unsigned long sum;
+
+  /**
+   * The average of data amounts
+   */
+  float avg;
+
+  /**
+   * The variance
+   */
+  double vr;
+
+  /**
+   * Number of data values; also the length of DLL containing SDEntries
+   */
+  unsigned int cnt;
+  
+  /**
+   * max number of entries we can have in the DLL
+   */
+  unsigned int max_cnt;
+};
+
+
 /**
+ * FIXME: doc
+ *
+ * @param 
+ * @return 
+ */
+static struct SDHandle *
+SD_init (unsigned int max_cnt)
+{
+  struct SDHandle *h;
+  
+  GNUNET_assert (1 < max_cnt);
+  h = GNUNET_malloc (sizeof (struct SDHandle));
+  h->max_cnt = max_cnt;
+  return h;
+}
+
+
+/**
+ * FIXME: doc
+ *
+ * @param 
+ * @return 
+ */
+static void
+SD_destroy (struct SDHandle *h)
+{
+  struct SDEntry *entry;
+  
+  while (NULL != (entry = h->head))
+  {
+    GNUNET_CONTAINER_DLL_remove (h->head, h->tail, entry);
+    GNUNET_free (entry);
+  }
+  GNUNET_free (h);
+}
+
+static void
+SD_add_data (struct SDHandle *h, unsigned int amount)
+{
+  struct SDEntry *entry;
+  double sqavg;
+  double sqsum_avg;
+
+  entry = NULL;
+  if (h->cnt == h->max_cnt)
+  {
+    entry = h->head;
+    GNUNET_CONTAINER_DLL_remove (h->head, h->tail, entry);
+    h->sum -= entry->amount;
+    h->sqsum -= ((unsigned long) entry->amount) * 
+        ((unsigned long) entry->amount);
+    h->cnt--;
+  }
+  GNUNET_assert (h->cnt < h->max_cnt);
+  if (NULL == entry)
+    entry = GNUNET_malloc (sizeof (struct SDEntry));
+  entry->amount = amount;
+  GNUNET_CONTAINER_DLL_insert_tail (h->head, h->tail, entry);
+  h->sum += amount;
+  h->cnt++;
+  h->avg = ((float) h->sum) / ((float) h->cnt);
+  h->sqsum += ((unsigned long) amount) * ((unsigned long) amount);
+  sqsum_avg = ((double) h->sqsum) / ((double) h->cnt);
+  sqavg = ((double) h->avg) * ((double) h->avg);
+  h->vr = sqsum_avg - sqavg;
+}
+
+
+/**
+ * Returns the factor by which the given amount differs from the standard 
deviation
+ *
+ * @param h the SDhandle
+ * @param amount the value for which the deviation is returned
+ * @return the deviation from the average; GNUNET_SYSERR if the deviation 
cannot
+ *           be calculated; a maximum of 4 is returned for deviations equal to
+ *           or larger than 4
+ */
+static int
+SD_deviation_factor (struct SDHandle *h, unsigned int amount)
+{
+  double diff;
+  unsigned int n;
+
+  if (h->cnt < 2)
+    return GNUNET_SYSERR;
+  if (((float) amount) > h->avg)
+    diff = ((float) amount) - h->avg;
+  else
+    return 0; //diff = h->avg - ((float) amount);
+  diff *= diff;
+  for (n = 1; n < 4; n++)
+    if (diff < (((double) (n * n)) * h->vr))
+      break;
+  return n;
+}
+
+
+/**
  * Returns the operation context with the given id if found in the Operation
  * context queues of the controller
  *
@@ -604,14 +765,7 @@
   cb_cls = data->cb_cls;
   GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
   opc->state = OPC_STATE_FINISHED;
-  GNUNET_free (data);
-  /* Increase parallel overlay connects */
-  if (c->num_parallel_connects < c->num_parallel_connects_threshold)
-    c->num_parallel_connects *= 2;
-  else
-    c->num_parallel_connects++;
-  GNUNET_TESTBED_operation_queue_reset_max_active_
-      (c->opq_parallel_overlay_connect_operations, c->num_parallel_connects);
+  //GNUNET_free (data);
   if (0 !=
       ((GNUNET_TESTBED_ET_CONNECT | GNUNET_TESTBED_ET_DISCONNECT) &
        c->event_mask))
@@ -739,16 +893,6 @@
     GNUNET_free (data);
     return GNUNET_YES;  /* We do not call controller callback for peer info */
   }
-  if (OP_OVERLAY_CONNECT == opc->type)
-  {
-    /* Decrease the number of parallel overlay connects */
-    c->num_parallel_connects /= 2;
-    c->num_parallel_connects_threshold = c->num_parallel_connects;
-    if (0 == c->num_parallel_connects)
-      c->num_parallel_connects++;
-    GNUNET_TESTBED_operation_queue_reset_max_active_
-        (c->opq_parallel_overlay_connect_operations, c->num_parallel_connects);
-  }
   if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) &&
       (NULL != c->cc))
   {
@@ -1320,6 +1464,27 @@
 
 
 /**
+ * FIXME: doc
+ *
+ * @param 
+ * @return 
+ */
+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.
@@ -1522,7 +1687,6 @@
   unsigned long long max_parallel_operations;
   unsigned long long max_parallel_service_connections;
   unsigned long long max_parallel_topology_config_operations;
-  unsigned long long num_parallel_connects_threshold;
 
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_number (cfg, "testbed",
@@ -1548,11 +1712,6 @@
     GNUNET_break (0);
     return NULL;
   }
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_number (cfg, "testbed",
-                                             
"PARALLEL_OVERLAY_CONNECTS_THRESHOLD",
-                                             &num_parallel_connects_threshold))
-    num_parallel_connects_threshold = 16;
   controller = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Controller));
   controller->cc = cc;
   controller->cc_cls = cc_cls;
@@ -1591,11 +1750,10 @@
   controller->opq_parallel_topology_config_operations=
       GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
                                               
max_parallel_topology_config_operations);
-  controller->num_parallel_connects = 1;
   controller->opq_parallel_overlay_connect_operations=
-      GNUNET_TESTBED_operation_queue_create_
-      (controller->num_parallel_connects);
-  controller->num_parallel_connects_threshold = 
num_parallel_connects_threshold;
+      GNUNET_TESTBED_operation_queue_create_ (0);
+  GNUNET_TESTBED_set_num_parallel_overlay_connects_ (controller, 1);
+  controller->poc_sd = SD_init (10);
   controller_hostname = GNUNET_TESTBED_host_get_hostname (host);
   if (NULL == controller_hostname)
     controller_hostname = "127.0.0.1";
@@ -1688,6 +1846,8 @@
       (controller->opq_parallel_topology_config_operations);
   GNUNET_TESTBED_operation_queue_destroy_
       (controller->opq_parallel_overlay_connect_operations);
+  SD_destroy (controller->poc_sd);
+  GNUNET_free_non_null (controller->tslots);
   GNUNET_free (controller);
 }
 
@@ -2304,4 +2464,118 @@
   return op_id;
 }
 
+
+/**
+ * Returns a timing slot which will be exclusively locked
+ *
+ * @param c the controller handle
+ * @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 */
+}
+
+
+static void
+decide_npoc (struct GNUNET_TESTBED_Controller *c)
+{
+  struct GNUNET_TIME_Relative avg;
+  int sd;
+  unsigned int slot;
+
+  if (c->tslots_filled != c->num_parallel_connects)
+    return;
+  avg = GNUNET_TIME_UNIT_ZERO;
+  for (slot = 0; slot < c->num_parallel_connects; slot++)
+    avg = GNUNET_TIME_relative_add (avg, c->tslots[slot].time);
+  avg = GNUNET_TIME_relative_divide (avg, c->num_parallel_connects);
+  GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value != avg.rel_value);
+  sd = SD_deviation_factor (c->poc_sd, (unsigned int) avg.rel_value);
+  if (GNUNET_SYSERR == sd)
+  {
+    SD_add_data (c->poc_sd, (unsigned int) avg.rel_value);
+    GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c, 
c->num_parallel_connects);
+    return;
+  }
+  GNUNET_assert (0 <= sd);
+  if (sd <= 1)
+  {
+    SD_add_data (c->poc_sd, (unsigned int) avg.rel_value);
+    GNUNET_TESTBED_set_num_parallel_overlay_connects_
+        (c, c->num_parallel_connects * 2);
+    return;
+  }
+  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 / 2);
+}
+
+
+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 time the new time
+ */
+void
+GNUNET_TESTBED_update_time_slot_ (struct GNUNET_TESTBED_Controller *c,
+                                  unsigned int index,
+                                  void *key,
+                                  struct GNUNET_TIME_Relative time)
+{
+  struct GNUNET_TIME_Relative avg;
+  struct TimeSlot *slot;
+
+  if (GNUNET_NO == GNUNET_TESTBED_release_time_slot_ (c, index, key))
+    return;
+  slot = &c->tslots[index];
+  if (GNUNET_TIME_UNIT_ZERO.rel_value == slot->time.rel_value)
+  {
+    slot->time = time;
+    c->tslots_filled++;
+    decide_npoc (c);
+    return;
+  }
+  avg = GNUNET_TIME_relative_add (slot->time, time);
+  avg = GNUNET_TIME_relative_divide (avg, 2);
+  slot->time = avg;
+}
+
+
 /* end of testbed_api.c */

Modified: gnunet/src/testbed/testbed_api.h
===================================================================
--- gnunet/src/testbed/testbed_api.h    2013-01-01 22:43:24 UTC (rev 25669)
+++ gnunet/src/testbed/testbed_api.h    2013-01-01 22:44:12 UTC (rev 25670)
@@ -179,6 +179,30 @@
 
 
 /**
+ * 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;
+  
+};
+
+
+/**
  * 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
@@ -189,7 +213,6 @@
  */
 struct GNUNET_TESTBED_Controller
 {
-
   /**
    * The host where the controller is running
    */
@@ -277,10 +300,22 @@
   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;
-
+  
   /**
    * Did we start the receive loop yet?
    */
@@ -297,9 +332,9 @@
   unsigned int num_parallel_connects;
 
   /**
-   * The threshold for the number of parallel overlay connects we do
+   * Counter to indicate when all the available time slots are filled
    */
-  unsigned int num_parallel_connects_threshold;
+  unsigned int tslots_filled;
 
   /**
    * The operation id counter. use current value and increment
@@ -500,5 +535,24 @@
                                 *slave_cfg,
                                  int is_subordinate);
 
+unsigned int
+GNUNET_TESTBED_get_tslot_ (struct GNUNET_TESTBED_Controller *c, void *key);
+
+
+void
+GNUNET_TESTBED_update_time_slot_ (struct GNUNET_TESTBED_Controller *c,
+                                  unsigned int index,
+                                  void *key,
+                                  struct GNUNET_TIME_Relative time);
+
+
+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_peers.c
===================================================================
--- gnunet/src/testbed/testbed_api_peers.c      2013-01-01 22:43:24 UTC (rev 
25669)
+++ gnunet/src/testbed/testbed_api_peers.c      2013-01-01 22:44:12 UTC (rev 
25670)
@@ -340,6 +340,8 @@
   opc->state = OPC_STATE_STARTED;
   data = opc->data;
   GNUNET_assert (NULL != data);
+  data->tslot_index = GNUNET_TESTBED_get_tslot_ (opc->c, data);
+  data->tstart = GNUNET_TIME_absolute_get ();
   msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_OverlayConnectMessage));
   msg->header.size =
       htons (sizeof (struct GNUNET_TESTBED_OverlayConnectMessage));
@@ -362,12 +364,24 @@
 oprelease_overlay_connect (void *cls)
 {
   struct OperationContext *opc = cls;
+  struct GNUNET_TIME_Relative duration;
+  struct OverlayConnectData *data;
 
-  if (OPC_STATE_STARTED == opc->state)
+  data = opc->data;
+  switch (opc->state)
   {
-    GNUNET_free (opc->data);
+  case OPC_STATE_INIT:
+    break;
+  case OPC_STATE_STARTED:
+    (void) GNUNET_TESTBED_release_time_slot_ (opc->c, 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);    
   }
+  GNUNET_free (data);
   GNUNET_free (opc);
 }
 
@@ -675,7 +689,6 @@
   data->p2 = p2;
   data->cb = cb;
   data->cb_cls = cb_cls;
-  data->state = OCD_INIT;
   opc = GNUNET_malloc (sizeof (struct OperationContext));
   opc->data = data;
   opc->c = p1->controller;

Modified: gnunet/src/testbed/testbed_api_peers.h
===================================================================
--- gnunet/src/testbed/testbed_api_peers.h      2013-01-01 22:43:24 UTC (rev 
25669)
+++ gnunet/src/testbed/testbed_api_peers.h      2013-01-01 22:44:12 UTC (rev 
25670)
@@ -219,32 +219,15 @@
   struct OperationContext *sub_opc;
 
   /**
-   * State information for this context data
+   * The starting time of this operation
    */
-  enum OCDState {
-    
-    /**
-     * The initial state
-     */
-    OCD_INIT,
+  struct GNUNET_TIME_Absolute tstart;
 
-    /**
-     * State where we attempt to acquire peer2's controller's configuration
-     */
-    OCD_CFG_ACQUIRE,
+  /**
+   * The timing slot index for this operation
+   */
+  unsigned int tslot_index;
 
-    /**
-     * State where we link peer1's controller to peer2's controller
-     */
-    OCD_LINK_CONTROLLERS,
-    
-    /**
-     * State where we re-ask controller of peer1 to attempt an overlay connect
-     * between peer1 and peer2
-     */
-    OCD_REATTEMPT_OVERLAY_CONNECT
-  } state;
-
 };
 
 




reply via email to

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