gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r13813 - gnunet/src/dht
Date: Fri, 26 Nov 2010 15:46:44 +0100

Author: nevans
Date: 2010-11-26 15:46:44 +0100 (Fri, 26 Nov 2010)
New Revision: 13813

Modified:
   gnunet/src/dht/gnunet-service-dht.c
Log:
restrict replies to one per request (use block library)

Modified: gnunet/src/dht/gnunet-service-dht.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht.c 2010-11-26 13:00:30 UTC (rev 13812)
+++ gnunet/src/dht/gnunet-service-dht.c 2010-11-26 14:46:44 UTC (rev 13813)
@@ -1964,7 +1964,34 @@
   return GNUNET_NO;
 }
 
+
 /**
+ * Task used to remove forwarding entries, either
+ * after timeout, when full, or on shutdown.
+ *
+ * @param cls the entry to remove
+ * @param tc context, reason, etc.
+ */
+static void
+remove_forward_entry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct DHTRouteSource *source_info = cls;
+  struct DHTQueryRecord *record;
+  source_info = GNUNET_CONTAINER_heap_remove_node(forward_list.minHeap, 
source_info->hnode);
+  record = source_info->record;
+  GNUNET_CONTAINER_DLL_remove(record->head, record->tail, source_info);
+
+  if (record->head == NULL) /* No more entries in DLL */
+    {
+      GNUNET_assert(GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove 
(forward_list.hashmap, &record->key, record));
+      GNUNET_free(record);
+    }
+  if (source_info->find_peers_responded != NULL)
+    GNUNET_CONTAINER_bloomfilter_free(source_info->find_peers_responded);
+  GNUNET_free(source_info);
+}
+
+/**
  * Main function that handles whether or not to route a result
  * message to other peers, or to send to our local client.
  *
@@ -2117,7 +2144,13 @@
                                                msg_ctx->peer, &pos->source);
                 }
 #endif
-              forward_result_message(msg, peer_info, msg_ctx);
+              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
             {
@@ -3353,34 +3386,7 @@
   */
 }
 
-
 /**
- * Task used to remove forwarding entries, either
- * after timeout, when full, or on shutdown.
- *
- * @param cls the entry to remove
- * @param tc context, reason, etc.
- */
-static void
-remove_forward_entry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  struct DHTRouteSource *source_info = cls;
-  struct DHTQueryRecord *record;
-  source_info = GNUNET_CONTAINER_heap_remove_node(forward_list.minHeap, 
source_info->hnode);
-  record = source_info->record;
-  GNUNET_CONTAINER_DLL_remove(record->head, record->tail, source_info);
-
-  if (record->head == NULL) /* No more entries in DLL */
-    {
-      GNUNET_assert(GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove 
(forward_list.hashmap, &record->key, record));
-      GNUNET_free(record);
-    }
-  if (source_info->find_peers_responded != NULL)
-    GNUNET_CONTAINER_bloomfilter_free(source_info->find_peers_responded);
-  GNUNET_free(source_info);
-}
-
-/**
  * Remember this routing request so that if a reply is
  * received we can either forward it to the correct peer
  * or return the result locally.




reply via email to

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