gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r8638 - in GNUnet/src/applications/dv_dht: module tools


From: gnunet
Subject: [GNUnet-SVN] r8638 - in GNUnet/src/applications/dv_dht: module tools
Date: Tue, 7 Jul 2009 16:41:14 -0600

Author: nevans
Date: 2009-07-07 16:41:14 -0600 (Tue, 07 Jul 2009)
New Revision: 8638

Modified:
   GNUnet/src/applications/dv_dht/module/routing.c
   GNUnet/src/applications/dv_dht/module/table.c
   GNUnet/src/applications/dv_dht/module/table.h
   GNUnet/src/applications/dv_dht/tools/dv_dht_driver.c
   GNUnet/src/applications/dv_dht/tools/dv_dht_driver_new.c
Log:
dv changes

Modified: GNUnet/src/applications/dv_dht/module/routing.c
===================================================================
--- GNUnet/src/applications/dv_dht/module/routing.c     2009-07-07 22:40:35 UTC 
(rev 8637)
+++ GNUnet/src/applications/dv_dht/module/routing.c     2009-07-07 22:41:14 UTC 
(rev 8638)
@@ -361,28 +361,34 @@
       result->hop_count = htonl (ntohl (result->hop_count) + 1);
 #endif
     }
-  if ((cls == NULL) || (ntohs (result->header.type) != 
GNUNET_P2P_PROTO_DHT_RESULT))
+  if ((cls == NULL)
+      || (ntohs (result->header.type) != GNUNET_P2P_PROTO_DHT_RESULT))
     {
 #if DEBUG_ROUTING
 
-      if ((cls != NULL) && (ntohs (result->header.type) != 
GNUNET_P2P_PROTO_DHT_RESULT))
-      {
-        dhtqueryuid_ptr = cls;
-        dhtqueryuid = *dhtqueryuid_ptr;
-        GNUNET_GE_LOG (coreAPI->ectx,
-               GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-               GNUNET_GE_BULK,
-               _("cls not null and type is wrong! Got dhtqueryuid of %llu"), 
dhtqueryuid);
-        GNUNET_GE_LOG (coreAPI->ectx,
-               GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-               GNUNET_GE_BULK,
-               _("got header type of %d or %d, wanted %d"), ntohs 
(result->header.type), result->header.type, GNUNET_P2P_PROTO_DHT_RESULT);
+      if ((cls != NULL)
+          && (ntohs (result->header.type) != GNUNET_P2P_PROTO_DHT_RESULT))
+        {
+          dhtqueryuid_ptr = cls;
+          dhtqueryuid = *dhtqueryuid_ptr;
+          GNUNET_GE_LOG (coreAPI->ectx,
+                         GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER
+                         | GNUNET_GE_BULK,
+                         _
+                         ("cls not null and type is wrong! Got dhtqueryuid of 
%llu"),
+                         dhtqueryuid);
+          GNUNET_GE_LOG (coreAPI->ectx,
+                         GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER
+                         | GNUNET_GE_BULK,
+                         _("got header type of %d or %d, wanted %d"),
+                         ntohs (result->header.type), result->header.type,
+                         GNUNET_P2P_PROTO_DHT_RESULT);
 
-      }
+        }
       else
-      {
-        dhtqueryuid = 0;
-      }
+        {
+          dhtqueryuid = 0;
+        }
 #endif
       result = GNUNET_malloc (sizeof (DV_DHT_MESSAGE) + size);
       result->header.size = htons (sizeof (DV_DHT_MESSAGE) + size);
@@ -686,7 +692,9 @@
 
 #if DEBUG_ROUTING
   queryuid = ntohl (get->queryuid);
-  total = dstore->get (&get->key, ntohl (get->type), &route_result, (void 
*)&queryuid);
+  total =
+    dstore->get (&get->key, ntohl (get->type), &route_result,
+                 (void *) &queryuid);
 #else
   total = dstore->get (&get->key, ntohl (get->type), &route_result, NULL);
 #endif
@@ -838,7 +846,7 @@
   GNUNET_free (aput);
 
   store = 0;
-  if (GNUNET_YES == GNUNET_DV_DHT_am_closest_peer(&put->key))
+  if (GNUNET_YES == GNUNET_DV_DHT_am_closest_peer (&put->key))
     store = 1;
 
   if (store != 0)

Modified: GNUnet/src/applications/dv_dht/module/table.c
===================================================================
--- GNUnet/src/applications/dv_dht/module/table.c       2009-07-07 22:40:35 UTC 
(rev 8637)
+++ GNUnet/src/applications/dv_dht/module/table.c       2009-07-07 22:41:14 UTC 
(rev 8638)
@@ -386,15 +386,15 @@
 
   bucket = get_bit_distance (target, have);
   /*d = bucket * 32;
-  d = exp2 (d / (sizeof (GNUNET_HashCode) * 8));
-  I can't understand this code.  Why multiply bucket by 32?
-  I say if we want a scaled value, assume we have a bucket
-  for each bit.  Obviously we can't get to 2^512, but this
-  will appropriately tell us whether one loc is closer than
-  another.  I also don't get why we want 2^(d/512)!!  Say we
-  should be in bucket 5 (5 matching bits), then we get 1
-  as a retrun value, just as if we have 15 matching bits!!!
-  15 matching should be closer than 5!!!!!!!*/
+     d = exp2 (d / (sizeof (GNUNET_HashCode) * 8));
+     I can't understand this code.  Why multiply bucket by 32?
+     I say if we want a scaled value, assume we have a bucket
+     for each bit.  Obviously we can't get to 2^512, but this
+     will appropriately tell us whether one loc is closer than
+     another.  I also don't get why we want 2^(d/512)!!  Say we
+     should be in bucket 5 (5 matching bits), then we get 1
+     as a retrun value, just as if we have 15 matching bits!!!
+     15 matching should be closer than 5!!!!!!! */
   d = exp2 (bucket);
   if (d > ((unsigned int) -1))
     return -1;
@@ -592,29 +592,29 @@
 
   find_closest_peer (&closest, target);
   GNUNET_GE_LOG (coreAPI->ectx,
-                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                     GNUNET_GE_BULK,
-                     "closest peer\n");
+                 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                 GNUNET_GE_BULK, "closest peer\n");
   printPeerBits (&closest);
   GNUNET_GE_LOG (coreAPI->ectx,
-                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                     GNUNET_GE_BULK,
-                     "me\n");
+                 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                 GNUNET_GE_BULK, "me\n");
   printPeerBits (coreAPI->my_identity);
   GNUNET_GE_LOG (coreAPI->ectx,
-                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                     GNUNET_GE_BULK,
-                     "key\n");
+                 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                 GNUNET_GE_BULK, "key\n");
   printKeyBits (target);
   GNUNET_GE_LOG (coreAPI->ectx,
-                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                     GNUNET_GE_BULK,
-                     "closest peer inverse distance is %u, mine is %u\n",
-                     inverse_distance(target, &closest.hashPubKey), 
inverse_distance(target, &coreAPI->my_identity->hashPubKey));
-  if (inverse_distance(target, &coreAPI->my_identity->hashPubKey) >= 
inverse_distance(target, &closest.hashPubKey))
-  {
-    return GNUNET_YES;
-  }
+                 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                 GNUNET_GE_BULK,
+                 "closest peer inverse distance is %u, mine is %u\n",
+                 inverse_distance (target, &closest.hashPubKey),
+                 inverse_distance (target,
+                                   &coreAPI->my_identity->hashPubKey));
+  if (inverse_distance (target, &coreAPI->my_identity->hashPubKey) >=
+      inverse_distance (target, &closest.hashPubKey))
+    {
+      return GNUNET_YES;
+    }
   return GNUNET_NO;
 }
 

Modified: GNUnet/src/applications/dv_dht/module/table.h
===================================================================
--- GNUnet/src/applications/dv_dht/module/table.h       2009-07-07 22:40:35 UTC 
(rev 8637)
+++ GNUnet/src/applications/dv_dht/module/table.h       2009-07-07 22:41:14 UTC 
(rev 8638)
@@ -76,7 +76,6 @@
  * Return GNUNET_YES if node location is closest, GNUNET_NO
  * otherwise.
  */
-int
-GNUNET_DV_DHT_am_closest_peer (const GNUNET_HashCode * target);
+int GNUNET_DV_DHT_am_closest_peer (const GNUNET_HashCode * target);
 
 #endif

Modified: GNUnet/src/applications/dv_dht/tools/dv_dht_driver.c
===================================================================
--- GNUnet/src/applications/dv_dht/tools/dv_dht_driver.c        2009-07-07 
22:40:35 UTC (rev 8637)
+++ GNUnet/src/applications/dv_dht/tools/dv_dht_driver.c        2009-07-07 
22:41:14 UTC (rev 8638)
@@ -37,7 +37,7 @@
 
 struct GNUNET_DV_DHT_keys
 {
-  struct GNUNET_DV_DHT_keys * next;
+  struct GNUNET_DV_DHT_keys *next;
   char data[8];
   GNUNET_HashCode key;
 };
@@ -109,15 +109,15 @@
                  unsigned int type,
                  unsigned int size, const char *data, void *cls)
 {
-struct GNUNET_DV_DHT_keys *keys = cls;
-int match = 0;
+  struct GNUNET_DV_DHT_keys *keys = cls;
+  int match = 0;
 
-while (keys != NULL)
-{
-    if (0 == memcmp (keys->data, data, size))
-      match = 1;
-    keys = keys->next;
-}
+  while (keys != NULL)
+    {
+      if (0 == memcmp (keys->data, data, size))
+        match = 1;
+      keys = keys->next;
+    }
 #if 0
   fprintf (stderr, "Got %u %u `%.*s' (want `%.*s')\n", type, size, size, data,
            sizeof (expect), expect);
@@ -128,11 +128,11 @@
     return GNUNET_SYSERR;
 #endif
   if (match == 1)
-  {
-    found++;
-    new_found++;
-    return GNUNET_OK;
-  }
+    {
+      found++;
+      new_found++;
+      return GNUNET_OK;
+    }
   else
     return GNUNET_SYSERR;
 }
@@ -186,128 +186,134 @@
     }
   else
     {
-      ret = sqlapi->insert_trial (&trialuid, num_peers, topology, put_items, 
get_requests, 1);
+      ret =
+        sqlapi->insert_trial (&trialuid, num_peers, topology, put_items,
+                              get_requests, 1);
     }
 
   if (ret != GNUNET_OK)
     return GNUNET_SYSERR;
-  printf ("Starting %u peers for trial %llu...\n", (unsigned int) num_peers, 
trialuid);
+  printf ("Starting %u peers for trial %llu...\n", (unsigned int) num_peers,
+          trialuid);
   peers = GNUNET_REMOTE_start_daemons (cfg, num_peers);
   if (peers == NULL)
-  {
-    GNUNET_GC_free (cfg);
-    return -1;
-  }
+    {
+      GNUNET_GC_free (cfg);
+      return -1;
+    }
   pos = peers;
   for (i = 0; i < num_peers; i++)
-  {
-    peer_array[i] = pos;
-    pos = pos->next;
-  }
+    {
+      peer_array[i] = pos;
+      pos = pos->next;
+    }
 
   for (i = 0; i < put_items; i++)
-  {
-    key_pos = GNUNET_malloc(sizeof(struct GNUNET_DV_DHT_keys));
-    for (l = 0; l < 8; l++)
     {
-      key_pos->data[l] = rand();
+      key_pos = GNUNET_malloc (sizeof (struct GNUNET_DV_DHT_keys));
+      for (l = 0; l < 8; l++)
+        {
+          key_pos->data[l] = rand ();
+        }
+      GNUNET_hash (key_pos->data, 8, &key_pos->key);
+      if (keys == NULL)
+        {
+          keys = key_pos;
+          key_pos->next = NULL;
+        }
+      else
+        {
+          key_pos->next = keys;
+          keys = key_pos;
+        }
     }
-    GNUNET_hash (key_pos->data, 8, &key_pos->key);
-    if (keys == NULL)
-    {
-      keys = key_pos;
-      key_pos->next = NULL;
-    }
-    else
-    {
-      key_pos->next = keys;
-      keys = key_pos;
-    }
-  }
   sleep (30);
   found = 0;
 
   for (r = 0; r < settle_time; r++)
-  {
-    fprintf (stderr, "After %d minutes\n", r);
-    for (i = 0; i < num_peers; i++)
     {
+      fprintf (stderr, "After %d minutes\n", r);
+      for (i = 0; i < num_peers; i++)
+        {
+          if (GNUNET_shutdown_test () == GNUNET_YES)
+            break;
+          fprintf (stderr, "Peer %d: ", i);
+          sock =
+            GNUNET_client_connection_create (NULL, peer_array[i]->config);
+          GNUNET_STATS_get_statistics (NULL, sock, &getPeers, NULL);
+          GNUNET_thread_sleep (2 * GNUNET_CRON_SECONDS);
+          GNUNET_client_connection_destroy (sock);
+        }
       if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
-      fprintf (stderr, "Peer %d: ", i);
-      sock =
-        GNUNET_client_connection_create (NULL, peer_array[i]->config);
-      GNUNET_STATS_get_statistics (NULL, sock, &getPeers, NULL);
-      GNUNET_thread_sleep (2 * GNUNET_CRON_SECONDS);
-      GNUNET_client_connection_destroy (sock);
+      sleep (60);
     }
-    if (GNUNET_shutdown_test () == GNUNET_YES)
-      break;
-    sleep (60);
-  }
 
   key_pos = keys;
   key_count = 0;
-  while(key_pos != NULL)
-  {
-    random_peer = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, num_peers);
-    fprintf(stdout, "Inserting key %d at peer %d\n", key_count, random_peer);
-    CHECK (GNUNET_OK == GNUNET_DV_DHT_put (peer_array[random_peer]->config,
-                                         ectx,
-                                         &key_pos->key,
-                                         
GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
-                                         sizeof (key_pos->data), 
key_pos->data));
+  while (key_pos != NULL)
+    {
+      random_peer = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, num_peers);
+      fprintf (stdout, "Inserting key %d at peer %d\n", key_count,
+               random_peer);
+      CHECK (GNUNET_OK ==
+             GNUNET_DV_DHT_put (peer_array[random_peer]->config, ectx,
+                                &key_pos->key,
+                                GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
+                                sizeof (key_pos->data), key_pos->data));
 
-    key_pos = key_pos->next;
-    key_count++;
-  }
-  fprintf(stdout, "Inserted %d items\n", key_count);
+      key_pos = key_pos->next;
+      key_count++;
+    }
+  fprintf (stdout, "Inserted %d items\n", key_count);
   key_pos = keys;
   key_count = 0;
-  for (i = 0; i < get_requests; i ++)
-  {
-    random_peer = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, num_peers);
-    dctx = GNUNET_DV_DHT_context_create (peer_array[random_peer]->config, ectx,
-                                         &result_callback, keys);
-    fprintf(stdout, "Searching for key %d from peer %d\n", key_count, 
random_peer);
-    get1 = GNUNET_DV_DHT_get_start (dctx,
-                                    GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
-                                    &key_pos->key);
-    GNUNET_GE_ASSERT (NULL, get1 != NULL);
-    for (k = 0; k < DEFAULT_NUM_ROUNDS; k++)
+  for (i = 0; i < get_requests; i++)
     {
-      if (GNUNET_shutdown_test () == GNUNET_YES)
-        break;
-      if (9 == (k % 10))
+      random_peer = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, num_peers);
+      dctx =
+        GNUNET_DV_DHT_context_create (peer_array[random_peer]->config, ectx,
+                                      &result_callback, keys);
+      fprintf (stdout, "Searching for key %d from peer %d\n", key_count,
+               random_peer);
+      get1 =
+        GNUNET_DV_DHT_get_start (dctx,
+                                 GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
+                                 &key_pos->key);
+      GNUNET_GE_ASSERT (NULL, get1 != NULL);
+      for (k = 0; k < DEFAULT_NUM_ROUNDS; k++)
         {
-          printf (".");
+          if (GNUNET_shutdown_test () == GNUNET_YES)
+            break;
+          if (9 == (k % 10))
+            {
+              printf (".");
+              fflush (stdout);
+            }
           fflush (stdout);
+          GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
+          if (last < found)
+            break;
         }
-      fflush (stdout);
-      GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
-      if (last < found)
-        break;
+      GNUNET_DV_DHT_get_stop (dctx, get1);
+      if (k == DEFAULT_NUM_ROUNDS)
+        {
+          printf ("?");
+          fflush (stdout);
+        }
+      GNUNET_DV_DHT_context_destroy (dctx);
+      if (key_pos->next != NULL)
+        {
+          key_pos = key_pos->next;
+          key_count++;
+        }
+      else
+        {
+          key_pos = keys;
+          key_count = 0;
+        }
     }
-    GNUNET_DV_DHT_get_stop (dctx, get1);
-    if (k == DEFAULT_NUM_ROUNDS)
-    {
-      printf ("?");
-      fflush (stdout);
-    }
-    GNUNET_DV_DHT_context_destroy(dctx);
-    if (key_pos->next != NULL)
-    {
-      key_pos = key_pos->next;
-      key_count++;
-    }
-    else
-    {
-      key_pos = keys;
-      key_count = 0;
-    }
-  }
-  printf ("Found %u out of %llu attempts.\n", found,
-            get_requests);
+  printf ("Found %u out of %llu attempts.\n", found, get_requests);
 
 FAILURE:
   pos = peers;
@@ -318,12 +324,12 @@
     }
 
   key_pos = keys;
-  while(key_pos != NULL)
-  {
-    temp_key_pos = key_pos->next;
-    GNUNET_free(key_pos);
-    key_pos = temp_key_pos;
-  }
+  while (key_pos != NULL)
+    {
+      temp_key_pos = key_pos->next;
+      GNUNET_free (key_pos);
+      key_pos = temp_key_pos;
+    }
 
   ret = sqlapi->update_trial (trialuid);
   return ret;
@@ -379,23 +385,17 @@
   GNUNET_GC_get_configuration_value_number (cfg,
                                             "MULTIPLE_SERVER_TESTING",
                                             "SETTLE_TIME",
-                                            0,
-                                            -1,
-                                            0, &settle_time);
+                                            0, -1, 0, &settle_time);
 
   GNUNET_GC_get_configuration_value_number (cfg,
                                             "MULTIPLE_SERVER_TESTING",
                                             "PUT_ITEMS",
-                                            1,
-                                            -1,
-                                            100, &put_items);
+                                            1, -1, 100, &put_items);
 
   GNUNET_GC_get_configuration_value_number (cfg,
                                             "MULTIPLE_SERVER_TESTING",
                                             "GET_REQUESTS",
-                                            1,
-                                            -1,
-                                            100, &get_requests);
+                                            1, -1, 100, &get_requests);
 
   GNUNET_GC_get_configuration_value_number (cfg,
                                             "MULTIPLE_SERVER_TESTING",

Modified: GNUnet/src/applications/dv_dht/tools/dv_dht_driver_new.c
===================================================================
--- GNUnet/src/applications/dv_dht/tools/dv_dht_driver_new.c    2009-07-07 
22:40:35 UTC (rev 8637)
+++ GNUnet/src/applications/dv_dht/tools/dv_dht_driver_new.c    2009-07-07 
22:41:14 UTC (rev 8638)
@@ -127,13 +127,13 @@
       (type != GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING))
     return GNUNET_SYSERR;
   else
-  {
-    GNUNET_mutex_lock(lock);
-    found++;
-    new_found++;
-    GNUNET_mutex_unlock(lock);
-    return GNUNET_OK;
-  }
+    {
+      GNUNET_mutex_lock (lock);
+      found++;
+      new_found++;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_OK;
+    }
 }
 
 static int
@@ -187,111 +187,120 @@
     }
   else
     {
-      ret = sqlapi->insert_trial (&trialuid, num_peers, topology, put_items, 
get_requests, concurrent_requests);
+      ret =
+        sqlapi->insert_trial (&trialuid, num_peers, topology, put_items,
+                              get_requests, concurrent_requests);
     }
 
   if (ret != GNUNET_OK)
     return GNUNET_SYSERR;
-  printf ("Starting %u peers for trial %llu...\n", (unsigned int) num_peers, 
trialuid);
+  printf ("Starting %u peers for trial %llu...\n", (unsigned int) num_peers,
+          trialuid);
   peers = GNUNET_REMOTE_start_daemons (cfg, num_peers);
   if (peers == NULL)
-  {
-    GNUNET_GC_free (cfg);
-    return -1;
-  }
+    {
+      GNUNET_GC_free (cfg);
+      return -1;
+    }
   pos = peers;
   for (i = 0; i < num_peers; i++)
-  {
-    peer_array[i] = pos;
-    pos = pos->next;
-  }
+    {
+      peer_array[i] = pos;
+      pos = pos->next;
+    }
 
   for (i = 0; i < put_items; i++)
-  {
-    for (l = 0; l < 8; l++)
     {
-      keys[i].data[l] = rand();
+      for (l = 0; l < 8; l++)
+        {
+          keys[i].data[l] = rand ();
+        }
+      GNUNET_hash (keys[i].data, 8, &keys[i].key);
     }
-    GNUNET_hash (keys[i].data, 8, &keys[i].key);
-  }
   sleep (30);
   found = 0;
 
   for (r = 0; r < settle_time; r++)
-  {
-    fprintf (stderr, "After %d minutes\n", r);
-    for (i = 0; i < num_peers; i++)
     {
+      fprintf (stderr, "After %d minutes\n", r);
+      for (i = 0; i < num_peers; i++)
+        {
+          if (GNUNET_shutdown_test () == GNUNET_YES)
+            break;
+          fprintf (stderr, "Peer %d: ", i);
+          sock =
+            GNUNET_client_connection_create (NULL, peer_array[i]->config);
+          GNUNET_STATS_get_statistics (NULL, sock, &getPeers, NULL);
+          GNUNET_thread_sleep (2 * GNUNET_CRON_SECONDS);
+          GNUNET_client_connection_destroy (sock);
+        }
       if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
-      fprintf (stderr, "Peer %d: ", i);
-      sock =
-        GNUNET_client_connection_create (NULL, peer_array[i]->config);
-      GNUNET_STATS_get_statistics (NULL, sock, &getPeers, NULL);
-      GNUNET_thread_sleep (2 * GNUNET_CRON_SECONDS);
-      GNUNET_client_connection_destroy (sock);
+      sleep (60);
     }
-    if (GNUNET_shutdown_test () == GNUNET_YES)
-      break;
-    sleep (60);
-  }
 
   for (i = 0; i < put_items; i++)
-  {
-    random_peer = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, num_peers);
-    //random_key = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, put_items);
-    fprintf(stdout, "Inserting key %d at peer %d\n", i, random_peer);
-    CHECK (GNUNET_OK == GNUNET_DV_DHT_put (peer_array[random_peer]->config,
-                                         ectx,
-                                         &keys[i].key,
-                                         
GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
-                                         sizeof (keys[i].data), keys[i].data));
-    GNUNET_thread_sleep (100 * GNUNET_CRON_MILLISECONDS);
-  }
-  fprintf(stdout, "Inserted %llu items\n", put_items);
-
-  for (i = 0; i < get_requests / concurrent_requests; i ++)
-  {
-    new_found = 0;
-    for (j = 0; j < concurrent_requests; j++)
     {
-      random_peers[j] = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 
num_peers);
-      random_key = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, put_items);
-      /*random_key = (i + 1) * (j + 1) - 1;*/
-      dctx[j] = GNUNET_DV_DHT_context_create 
(peer_array[random_peers[j]]->config, ectx,
-                                         &result_callback, &keys[random_key]);
-      fprintf(stdout, "Searching for key %d from peer %d\n", random_key, 
random_peers[j]);
-      gets[j] = GNUNET_DV_DHT_get_start (dctx[j],
-                                        
GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
-                                        &keys[random_key].key);
-      GNUNET_GE_ASSERT (NULL, gets[j] != NULL);
+      random_peer = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, num_peers);
+      //random_key = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, put_items);
+      fprintf (stdout, "Inserting key %d at peer %d\n", i, random_peer);
+      CHECK (GNUNET_OK == GNUNET_DV_DHT_put (peer_array[random_peer]->config,
+                                             ectx,
+                                             &keys[i].key,
+                                             
GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
+                                             sizeof (keys[i].data),
+                                             keys[i].data));
+      GNUNET_thread_sleep (100 * GNUNET_CRON_MILLISECONDS);
     }
+  fprintf (stdout, "Inserted %llu items\n", put_items);
 
-    for (k = 0; k < DEFAULT_NUM_ROUNDS; k++)
+  for (i = 0; i < get_requests / concurrent_requests; i++)
     {
-      if (GNUNET_shutdown_test () == GNUNET_YES)
-        break;
-      if (9 == (k % 10))
+      new_found = 0;
+      for (j = 0; j < concurrent_requests; j++)
         {
-          printf (".");
+          random_peers[j] =
+            GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, num_peers);
+          random_key =
+            GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, put_items);
+          /*random_key = (i + 1) * (j + 1) - 1; */
+          dctx[j] =
+            GNUNET_DV_DHT_context_create (peer_array[random_peers[j]]->config,
+                                          ectx, &result_callback,
+                                          &keys[random_key]);
+          fprintf (stdout, "Searching for key %d from peer %d\n", random_key,
+                   random_peers[j]);
+          gets[j] =
+            GNUNET_DV_DHT_get_start (dctx[j],
+                                     GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
+                                     &keys[random_key].key);
+          GNUNET_GE_ASSERT (NULL, gets[j] != NULL);
+        }
+
+      for (k = 0; k < DEFAULT_NUM_ROUNDS; k++)
+        {
+          if (GNUNET_shutdown_test () == GNUNET_YES)
+            break;
+          if (9 == (k % 10))
+            {
+              printf (".");
+              fflush (stdout);
+            }
           fflush (stdout);
+          GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
         }
-      fflush (stdout);
-      GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
-    }
 
-    for (j = 0; j < concurrent_requests; j++)
-    {
-      GNUNET_DV_DHT_get_stop (dctx[j], gets[j]);
-      GNUNET_DV_DHT_context_destroy(dctx[j]);
+      for (j = 0; j < concurrent_requests; j++)
+        {
+          GNUNET_DV_DHT_get_stop (dctx[j], gets[j]);
+          GNUNET_DV_DHT_context_destroy (dctx[j]);
+        }
+      printf ("Found %u out of %llu attempts.\n", new_found,
+              concurrent_requests);
+
     }
-    printf ("Found %u out of %llu attempts.\n", new_found,
-            concurrent_requests);
+  printf ("Found %u out of %llu attempts.\n", found, get_requests);
 
-  }
-  printf ("Found %u out of %llu attempts.\n", found,
-            get_requests);
-
 FAILURE:
   pos = peers;
   while (pos != NULL)
@@ -318,7 +327,7 @@
 
   ectx = NULL;
   cfg = GNUNET_GC_create ();
-  lock = GNUNET_mutex_create(GNUNET_YES);
+  lock = GNUNET_mutex_create (GNUNET_YES);
   ret =
     GNUNET_init (argc, argv, "dvdhtdriver", &configFile,
                  gnunetDHTDriverOptions, &ectx, &driverConfig);
@@ -355,30 +364,22 @@
   GNUNET_GC_get_configuration_value_number (cfg,
                                             "MULTIPLE_SERVER_TESTING",
                                             "SETTLE_TIME",
-                                            0,
-                                            -1,
-                                            0, &settle_time);
+                                            0, -1, 0, &settle_time);
 
   GNUNET_GC_get_configuration_value_number (cfg,
                                             "MULTIPLE_SERVER_TESTING",
                                             "CONCURRENT_REQUESTS",
-                                            1,
-                                            -1,
-                                            5, &concurrent_requests);
+                                            1, -1, 5, &concurrent_requests);
 
   GNUNET_GC_get_configuration_value_number (cfg,
                                             "MULTIPLE_SERVER_TESTING",
                                             "PUT_ITEMS",
-                                            1,
-                                            -1,
-                                            100, &put_items);
+                                            1, -1, 100, &put_items);
 
   GNUNET_GC_get_configuration_value_number (cfg,
                                             "MULTIPLE_SERVER_TESTING",
                                             "GET_REQUESTS",
-                                            1,
-                                            -1,
-                                            100, &get_requests);
+                                            1, -1, 100, &get_requests);
 
   GNUNET_GC_get_configuration_value_number (cfg,
                                             "MULTIPLE_SERVER_TESTING",
@@ -416,10 +417,12 @@
   if (done != NULL)
     done ();
 
-  fprintf(stdout, "# Inserts: %llu\n# Gets: %llu\nSettle time: %llu\n# Nodes: 
%llu\n# Concurrent: %llu\n# Wait time: %d\n# Successful: %d\n",
-          put_items, get_requests, settle_time, num_peers, 
concurrent_requests, DEFAULT_NUM_ROUNDS, found);
+  fprintf (stdout,
+           "# Inserts: %llu\n# Gets: %llu\nSettle time: %llu\n# Nodes: %llu\n# 
Concurrent: %llu\n# Wait time: %d\n# Successful: %d\n",
+           put_items, get_requests, settle_time, num_peers,
+           concurrent_requests, DEFAULT_NUM_ROUNDS, found);
   GNUNET_plugin_unload (plugin);
-  GNUNET_mutex_destroy(lock);
+  GNUNET_mutex_destroy (lock);
   return ret;
 }
 





reply via email to

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