test case fix, dht bugfix
authorNathan S. Evans <evans@in.tum.de>
Wed, 6 Oct 2010 09:55:35 +0000 (09:55 +0000)
committerNathan S. Evans <evans@in.tum.de>
Wed, 6 Oct 2010 09:55:35 +0000 (09:55 +0000)
src/dht/gnunet-service-dht.c
src/dht/test_dht_tools.sh

index 8dbb11525b96529e370846fe83db14bb1be9b52b..d722f3335713bd4af8957306a9633ec03af283cf 100644 (file)
@@ -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);
index b22084ebbc3e9f23e3cab1527697dc11350ae3ea..68c0613a421806b3e166396ba2fce6d114261abc 100755 (executable)
@@ -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