gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r9890 - in GNUnet/src/applications/dv_dht: module tools
Date: Thu, 24 Dec 2009 00:19:19 +0100

Author: nevans
Date: 2009-12-24 00:19:19 +0100 (Thu, 24 Dec 2009)
New Revision: 9890

Modified:
   GNUnet/src/applications/dv_dht/module/routing.c
   GNUnet/src/applications/dv_dht/module/table.c
   GNUnet/src/applications/dv_dht/tools/dv_dht_twopeer_test.c
Log:
mainly pre-commit, also heap deletion bugfix in table.c

Modified: GNUnet/src/applications/dv_dht/module/routing.c
===================================================================
--- GNUnet/src/applications/dv_dht/module/routing.c     2009-12-23 22:59:43 UTC 
(rev 9889)
+++ GNUnet/src/applications/dv_dht/module/routing.c     2009-12-23 23:19:19 UTC 
(rev 9890)
@@ -424,9 +424,7 @@
 static int
 route_result (const GNUNET_HashCode * key,
               unsigned int type,
-              unsigned int size,
-             const char *data,
-             void *ctx)
+              unsigned int size, const char *data, void *ctx)
 {
   struct RouteResultContext *rrc = ctx;
   DV_DHTQueryRecord *q;
@@ -455,9 +453,11 @@
   result = NULL;
   if (rrc->rmsg != NULL)
     {
-      result = GNUNET_malloc (ntohs(rrc->rmsg->header.size));
-      memcpy (result, rrc->rmsg, ntohs(rrc->rmsg->header.size));
-      GNUNET_GE_ASSERT (NULL, ntohs (result->header.type) == 
GNUNET_P2P_PROTO_DHT_RESULT);
+      result = GNUNET_malloc (ntohs (rrc->rmsg->header.size));
+      memcpy (result, rrc->rmsg, ntohs (rrc->rmsg->header.size));
+      GNUNET_GE_ASSERT (NULL,
+                        ntohs (result->header.type) ==
+                        GNUNET_P2P_PROTO_DHT_RESULT);
       result->hop_count = htonl (ntohl (result->hop_count) + 1);
     }
   else
@@ -472,7 +472,7 @@
       result->key = *key;
       memset (&result->bloomfilter, 0, DV_DHT_BLOOM_SIZE);
 #if DEBUG_ROUTING
-      dhtqueryuid = 0; /* FIXME: why have this? */
+      dhtqueryuid = 0;          /* FIXME: why have this? */
       if ((debug_routes) && (dhtlog != NULL))
         {
           dhtlog->insert_query (&rrc->queryuid, dhtqueryuid, DHTLOG_RESULT,
@@ -636,6 +636,7 @@
 #endif
   GNUNET_bloomfilter_free (bloom);
   GNUNET_free (result);
+
   return GNUNET_OK;
 }
 
@@ -679,9 +680,7 @@
                      GNUNET_GE_DEBUG | GNUNET_GE_ADMIN | GNUNET_GE_USER |
                      GNUNET_GE_BULK,
                      "%s: Size of record hash map %u, size of heap %u. Bad!\n",
-                     &shortID, 
-                    routes_size,
-                     heap_size);
+                     &shortID, routes_size, heap_size);
 #endif
       GNUNET_mutex_unlock (lock);
       return GNUNET_SYSERR;
@@ -713,8 +712,7 @@
                      GNUNET_GE_DEBUG | GNUNET_GE_ADMIN | GNUNET_GE_USER |
                      GNUNET_GE_BULK,
                      "%s: Size of record hash map %u, size of heap %u. Bad!\n",
-                     &shortID, routes_size,
-                     heap_size);
+                     &shortID, routes_size, heap_size);
 #endif
       GNUNET_mutex_unlock (lock);
       return GNUNET_SYSERR;
@@ -872,9 +870,7 @@
 #if DEBUG_ROUTING
   rrc.queryuid = GNUNET_ntohll (get->queryuid);
   rrc.rmsg = NULL;
-  total =
-    dstore->get (&get->key, ntohl (get->type), &route_result,
-                 &rrc);
+  total = dstore->get (&get->key, ntohl (get->type), &route_result, &rrc);
   GNUNET_GE_LOG (coreAPI->ectx,
                  GNUNET_GE_DEBUG | GNUNET_GE_ADMIN | GNUNET_GE_USER |
                  GNUNET_GE_BULK,
@@ -1280,8 +1276,7 @@
   route_result (&result->key,
                 ntohl (result->type),
                 ntohs (result->header.size) - sizeof (DV_DHT_MESSAGE),
-                (const char *) &result[1],
-               &rrc);
+                (const char *) &result[1], &rrc);
   return GNUNET_OK;
 }
 
@@ -1556,7 +1551,8 @@
   rt_size = (unsigned int) rts;
 
   new_records.hashmap = GNUNET_multi_hash_map_create ((unsigned int) rts);
-  new_records.minHeap = GNUNET_CONTAINER_heap_create 
(GNUNET_CONTAINER_HEAP_ORDER_MIN);
+  new_records.minHeap =
+    GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
   memset (&nulldata, 0, sizeof (nulldata));
 
   lock = GNUNET_mutex_create (GNUNET_NO);
@@ -1742,6 +1738,12 @@
 
   coreAPI->service_release (dstore);
   GNUNET_multi_hash_map_destroy (new_records.hashmap);
+
+  while (GNUNET_CONTAINER_heap_get_size (new_records.minHeap) > 0)
+    {
+      GNUNET_CONTAINER_heap_remove_root (new_records.minHeap);
+    }
+
   GNUNET_CONTAINER_heap_destroy (new_records.minHeap);
   return GNUNET_OK;
 }

Modified: GNUnet/src/applications/dv_dht/module/table.c
===================================================================
--- GNUnet/src/applications/dv_dht/module/table.c       2009-12-23 22:59:43 UTC 
(rev 9889)
+++ GNUnet/src/applications/dv_dht/module/table.c       2009-12-23 23:19:19 UTC 
(rev 9890)
@@ -786,17 +786,22 @@
 
   bucket = findBucketFor (peer);
   if (bucket == NULL)
-    return;                     /* peers[i] == self */
+    {
+      return;                   /* peers[i] == self */
+    }
   if (bucket->peers_size >= MAINTAIN_BUCKET_SIZE)
-  {
-    GNUNET_mutex_lock(lock); /* Possible missing lock causing bug 1523? */
-    checkExpiration (bucket);
-    GNUNET_mutex_unlock(lock);
-  }
+    {
+      checkExpiration (bucket);
+    }
   if (bucket->peers_size >= MAINTAIN_BUCKET_SIZE)
-    return;                     /* do not care */
+    {
+      return;                   /* do not care */
+    }
   if (NULL != findPeerEntryInBucket (bucket, peer))
-    return;                     /* already have this peer in buckets */
+    {
+      return;                   /* already have this peer in buckets */
+    }
+
   /* do we know how to contact this peer? */
   /* This may not work with the dv implementation... */
 
@@ -811,7 +816,6 @@
       return;
     }
   /* we are connected (in dv), add to bucket */
-  GNUNET_mutex_lock (lock);
   pi = GNUNET_malloc (sizeof (PeerInfo));
   memset (pi, 0, sizeof (PeerInfo));
   pi->id = *peer;
@@ -822,7 +826,6 @@
   total_peers++;
   if (stats != NULL)
     stats->change (stat_dht_total_peers, 1);
-  GNUNET_mutex_unlock (lock);
 }
 
 static void
@@ -831,9 +834,7 @@
 #if DEBUG_TABLE
   print_entry ("broadcast_dht_discovery_prob");
 #endif
-
   GNUNET_DV_DHT_considerPeer (other);
-
 #if DEBUG_TABLE
   print_exit ("broadcast_dht_discovery_prob");
 #endif

Modified: GNUnet/src/applications/dv_dht/tools/dv_dht_twopeer_test.c
===================================================================
--- GNUnet/src/applications/dv_dht/tools/dv_dht_twopeer_test.c  2009-12-23 
22:59:43 UTC (rev 9889)
+++ GNUnet/src/applications/dv_dht/tools/dv_dht_twopeer_test.c  2009-12-23 
23:19:19 UTC (rev 9890)
@@ -74,7 +74,7 @@
   struct PeerData *pd = cls;
   char expect[8];
 
-#if 0
+#if 1
   fprintf (stderr, "Got %u %u `%.*s'\n", type, size, size, data);
 #endif
   memset (expect, pd->expect_i, sizeof (expect));





reply via email to

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