gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r16907 - gnunet/src/dht


From: gnunet
Subject: [GNUnet-SVN] r16907 - gnunet/src/dht
Date: Fri, 16 Sep 2011 20:26:17 +0200

Author: grothoff
Date: 2011-09-16 20:26:17 +0200 (Fri, 16 Sep 2011)
New Revision: 16907

Modified:
   gnunet/src/dht/dht.h
   gnunet/src/dht/gnunet-service-dht.c
Log:
fixing 1770, towards fixing 1769

Modified: gnunet/src/dht/dht.h
===================================================================
--- gnunet/src/dht/dht.h        2011-09-16 18:14:09 UTC (rev 16906)
+++ gnunet/src/dht/dht.h        2011-09-16 18:26:17 UTC (rev 16907)
@@ -34,7 +34,7 @@
  * Should NEVER be enabled in production and makes the DHT incompatible
  * (since this changes the message format).
  */
-#define HAVE_UID_FOR_TESTING GNUNET_YES
+#define HAVE_UID_FOR_TESTING GNUNET_NO
 
 /**
  * Include a bf for replies? Should not be needed (see Mantis #1769), but if I 
remove

Modified: gnunet/src/dht/gnunet-service-dht.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht.c 2011-09-16 18:14:09 UTC (rev 16906)
+++ gnunet/src/dht/gnunet-service-dht.c 2011-09-16 18:26:17 UTC (rev 16907)
@@ -483,7 +483,7 @@
   struct DHTRouteSource *prev;
 
   /**
-   * UID of the request
+   * UID of the request, 0 if from another peer.
    */
   uint64_t uid;
 
@@ -623,7 +623,7 @@
   GNUNET_HashCode key;
 
   /**
-   * Unique identifier for this request.
+   * Unique identifier for this request, 0 if from another peer.
    */
   uint64_t uid;
 
@@ -1072,12 +1072,16 @@
   }
   result_message->options = htonl (msg_ctx->msg_options);
   result_message->hop_count = htonl (msg_ctx->hop_count + 1);
+#if HAVE_REPLY_BLOOMFILTER
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_CONTAINER_bloomfilter_get_raw_data (msg_ctx->bloom,
                                                             result_message->
                                                             bloomfilter,
                                                             DHT_BLOOM_SIZE));
+#endif
+#if HAVE_UID_FOR_TESTING 
   result_message->unique_id = GNUNET_htonll (msg_ctx->unique_id);
+#endif
   memcpy (&result_message->key, &msg_ctx->key, sizeof (GNUNET_HashCode));
   /* Copy the enc_msg, then the path history as well! */
   memcpy (&result_message[1], msg, ntohs (msg->size));
@@ -1595,7 +1599,9 @@
   route_message->hop_count = htonl (msg_ctx->hop_count + 1);
   route_message->network_size = htonl (msg_ctx->network_size);
   route_message->desired_replication_level = htonl (msg_ctx->replication);
+#if HAVE_UID_FOR_TESTING 
   route_message->unique_id = GNUNET_htonll (msg_ctx->unique_id);
+#endif
   if (msg_ctx->bloom != NULL)
     GNUNET_assert (GNUNET_OK ==
                    GNUNET_CONTAINER_bloomfilter_get_raw_data (msg_ctx->bloom,
@@ -1921,11 +1927,13 @@
                                    NULL);
     }
 #endif
+#if HAVE_REPLY_BLOOMFILTER
     if (msg_ctx->bloom != NULL)
     {
       GNUNET_CONTAINER_bloomfilter_free (msg_ctx->bloom);
       msg_ctx->bloom = NULL;
     }
+#endif
     return 0;
   }
 
@@ -1992,7 +2000,7 @@
         pos = pos->next;
         continue;
       }
-
+#if HAVE_REPLY_BLOOMFILTER
       if (msg_ctx->bloom == NULL)
         msg_ctx->bloom =
             GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE,
@@ -2002,48 +2010,44 @@
       if ((GNUNET_NO ==
            GNUNET_CONTAINER_bloomfilter_test (msg_ctx->bloom,
                                               &peer_info->id.hashPubKey)))
-      {
+       {{{
+#endif
 #if DEBUG_DHT
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "`%s:%s': Forwarding response key %s uid %llu to peer 
%s\n",
-                    my_short_id, "DHT", GNUNET_h2s (&msg_ctx->key),
-                    msg_ctx->unique_id, GNUNET_i2s (&peer_info->id));
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "`%s:%s': Forwarding response key %s uid %llu to peer %s\n",
+                 my_short_id, "DHT", GNUNET_h2s (&msg_ctx->key),
+                 msg_ctx->unique_id, GNUNET_i2s (&peer_info->id));
 #endif
 #if DEBUG_DHT_ROUTING
-        if ((debug_routes_extended) && (dhtlog_handle != NULL))
-        {
-          dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_RESULT,
-                                       msg_ctx->hop_count, GNUNET_NO,
-                                       &my_identity, &msg_ctx->key,
-                                       &msg_ctx->peer, &pos->source);
-        }
+      if ((debug_routes_extended) && (dhtlog_handle != NULL))
+      {
+       dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_RESULT,
+                                    msg_ctx->hop_count, GNUNET_NO,
+                                    &my_identity, &msg_ctx->key,
+                                    &msg_ctx->peer, &pos->source);
+      }
 #endif
-        forward_result_message (msg, peer_info, msg_ctx);
-        /* Try removing forward entries after sending once, only allows ONE 
response per request */
-        if (pos->delete_task != GNUNET_SCHEDULER_NO_TASK)
-        {
-          GNUNET_SCHEDULER_cancel (pos->delete_task);
-          pos->delete_task =
-              GNUNET_SCHEDULER_add_now (&remove_forward_entry, pos);
-        }
+      forward_result_message (msg, peer_info, msg_ctx);
+      /* Try removing forward entries after sending once, only allows ONE 
response per request */
+      if (pos->delete_task != GNUNET_SCHEDULER_NO_TASK)
+      {
+       GNUNET_SCHEDULER_cancel (pos->delete_task);
+       pos->delete_task =
+         GNUNET_SCHEDULER_add_now (&remove_forward_entry, pos);        
       }
-      else
-      {
-#if DEBUG_DHT
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "`%s:%s': NOT Forwarding response (bloom match) key %s uid 
%llu to peer %s\n",
-                    my_short_id, "DHT", GNUNET_h2s (&msg_ctx->key),
-                    msg_ctx->unique_id, GNUNET_i2s (&peer_info->id));
+#if HAVE_REPLY_BLOOMFILTER
+        }}}
 #endif
-      }
     }
     pos = pos->next;
   }
+#if HAVE_REPLY_BLOOMFILTER
   if (msg_ctx->bloom != NULL)
   {
     GNUNET_CONTAINER_bloomfilter_free (msg_ctx->bloom);
     msg_ctx->bloom = NULL;
   }
+#endif
   return 0;
 }
 
@@ -4057,7 +4061,12 @@
     if ((debug_routes_extended) && (dhtlog_handle != NULL))
     {
           /** Log routes that die due to high load! */
-      dhtlog_handle->insert_route (NULL, GNUNET_ntohll (incoming->unique_id),
+      dhtlog_handle->insert_route (NULL, 
+#if HAVE_UID_FOR_TESTING
+                                  GNUNET_ntohll (incoming->unique_id),
+#else
+                                  0,
+#endif
                                    DHTLOG_ROUTE, ntohl (incoming->hop_count),
                                    GNUNET_SYSERR, &my_identity, &incoming->key,
                                    peer, NULL);
@@ -4076,7 +4085,12 @@
     if ((debug_routes_extended) && (dhtlog_handle != NULL))
     {
         /** Log routes that die due to high load! */
-      dhtlog_handle->insert_route (NULL, GNUNET_ntohll (incoming->unique_id),
+      dhtlog_handle->insert_route (NULL, 
+#if HAVE_UID_FOR_TESTING
+                                  GNUNET_ntohll (incoming->unique_id),
+#else
+                                  0,
+#endif
                                    DHTLOG_ROUTE, ntohl (incoming->hop_count),
                                    GNUNET_SYSERR, &my_identity, &incoming->key,
                                    peer, NULL);
@@ -4092,7 +4106,9 @@
   msg_ctx->hop_count = ntohl (incoming->hop_count);
   memcpy (&msg_ctx->key, &incoming->key, sizeof (GNUNET_HashCode));
   msg_ctx->replication = ntohl (incoming->desired_replication_level);
+#if HAVE_UID_FOR_TESTING
   msg_ctx->unique_id = GNUNET_ntohll (incoming->unique_id);
+#endif
   msg_ctx->msg_options = ntohl (incoming->options);
   if (GNUNET_DHT_RO_RECORD_ROUTE ==
       (msg_ctx->msg_options & GNUNET_DHT_RO_RECORD_ROUTE))
@@ -4174,7 +4190,12 @@
     if ((debug_routes_extended) && (dhtlog_handle != NULL))
     {
           /** Log routes that die due to high load! */
-      dhtlog_handle->insert_route (NULL, GNUNET_ntohll (incoming->unique_id),
+      dhtlog_handle->insert_route (NULL, 
+#if HAVE_UID_FOR_TESTING
+                                  GNUNET_ntohll (incoming->unique_id),
+#else
+                                  0,
+#endif
                                    DHTLOG_ROUTE, ntohl (incoming->hop_count),
                                    GNUNET_SYSERR, &my_identity, &incoming->key,
                                    peer, NULL);
@@ -4185,7 +4206,9 @@
 
   memset (&msg_ctx, 0, sizeof (struct DHT_MessageContext));
   memcpy (&msg_ctx.key, &incoming->key, sizeof (GNUNET_HashCode));
+#if HAVE_UID_FOR_TESTING
   msg_ctx.unique_id = GNUNET_ntohll (incoming->unique_id);
+#endif
   msg_ctx.msg_options = ntohl (incoming->options);
   msg_ctx.hop_count = ntohl (incoming->hop_count);
   msg_ctx.peer = *peer;
@@ -4229,10 +4252,12 @@
     }
 #endif
   }
+#if HAVE_REPLY_BLOOMFILTER
   msg_ctx.bloom =
       GNUNET_CONTAINER_bloomfilter_init (incoming->bloomfilter, DHT_BLOOM_SIZE,
                                          DHT_BLOOM_K);
   GNUNET_assert (msg_ctx.bloom != NULL);
+#endif
   route_result_message (enc_msg, &msg_ctx);
   return GNUNET_YES;
 }




reply via email to

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