From 7671f5631189a466fe35ebaeeffb8312ab696794 Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Wed, 6 Oct 2010 09:55:35 +0000 Subject: [PATCH] test case fix, dht bugfix --- src/dht/gnunet-service-dht.c | 15 +++++++++++---- src/dht/test_dht_tools.sh | 6 +++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 8dbb11525..d722f3335 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c @@ -2505,11 +2505,18 @@ handle_dht_find_peer (void *cls, recent_hash = GNUNET_malloc(sizeof(GNUNET_HashCode)); memcpy(recent_hash, &message_context->key, sizeof(GNUNET_HashCode)); - GNUNET_CONTAINER_multihashmap_put (recent_find_peer_requests, + if (GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_put (recent_find_peer_requests, &message_context->key, NULL, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); - GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), - &remove_recent_find_peer, recent_hash); + GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) + { + /* Only add a task if there wasn't one for this key already! */ + GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), + &remove_recent_find_peer, recent_hash); + } + else + { + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received duplicate find peer request too soon!\n"); + } /* Simplistic find_peer functionality, always return our hello */ hello_size = ntohs(my_hello->size); diff --git a/src/dht/test_dht_tools.sh b/src/dht/test_dht_tools.sh index b22084ebb..68c0613a4 100755 --- a/src/dht/test_dht_tools.sh +++ b/src/dht/test_dht_tools.sh @@ -42,7 +42,7 @@ echo "PASS" sleep 1 echo -n "TEST: Testing put..." -if ! $putexe -k testkey -d testdata -T 8 > $out ; then +if ! $putexe -k testkey -d testdata -t 8 > $out ; then echo "FAIL: error running $putexe" echo "Command output was:" cat $out @@ -53,10 +53,10 @@ echo "PASS" sleep 1 echo -n "TEST: Testing get..." -echo "Result 0, type 0:" > $checkout +echo "Result 0, type 8:" > $checkout echo "testdata" >> $checkout -if ! $getexe -k testkey -T 8 > $out ; then +if ! $getexe -k testkey -T 5 -t 8 > $out ; then echo "FAIL: error running $putexe" echo "Command output was:" cat $out -- 2.25.1