gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r12999 - gnunet/src/dht
Date: Wed, 15 Sep 2010 15:00:17 +0200

Author: nevans
Date: 2010-09-15 15:00:17 +0200 (Wed, 15 Sep 2010)
New Revision: 12999

Modified:
   gnunet/src/dht/test_dht_multipeer_data.conf
   gnunet/src/dht/test_dht_twopeer.c
   gnunet/src/dht/test_dht_twopeer_data.conf
   gnunet/src/dht/test_dhtlog_data.conf
Log:
add retry attempts to test_dht_twopeer, remove core from defaultservices to 
ensure that the dht gets started before core... Otherwise the test can fail 
because the data being searched for is the other peers public key, which is 
only known once connected.

Modified: gnunet/src/dht/test_dht_multipeer_data.conf
===================================================================
--- gnunet/src/dht/test_dht_multipeer_data.conf 2010-09-15 11:12:59 UTC (rev 
12998)
+++ gnunet/src/dht/test_dht_multipeer_data.conf 2010-09-15 13:00:17 UTC (rev 
12999)
@@ -47,7 +47,7 @@
 DEBUG = NO
 
 [arm]
-DEFAULTSERVICES = core dht
+DEFAULTSERVICES = dht
 ACCEPT_FROM6 = ::1;
 ACCEPT_FROM = 127.0.0.1;
 BINARY = gnunet-service-arm

Modified: gnunet/src/dht/test_dht_twopeer.c
===================================================================
--- gnunet/src/dht/test_dht_twopeer.c   2010-09-15 11:12:59 UTC (rev 12998)
+++ gnunet/src/dht/test_dht_twopeer.c   2010-09-15 13:00:17 UTC (rev 12999)
@@ -30,6 +30,8 @@
 /* DEFINES */
 #define VERBOSE GNUNET_YES
 
+#define MAX_GET_ATTEMPTS 10
+
 #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5)
 
 #define DEFAULT_NUM_PEERS 2
@@ -43,6 +45,10 @@
   struct GNUNET_DHT_Handle *dht_handle;
 
   struct GNUNET_DHT_GetHandle *get_handle;
+
+  unsigned int get_attempts;
+
+  GNUNET_SCHEDULER_TaskIdentifier retry_task;
 };
 
 /* Globals */
@@ -116,11 +122,17 @@
 
   if (pg != NULL)
     GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
+
+  if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK)
+    GNUNET_SCHEDULER_cancel(sched, curr_get_ctx.retry_task);
 }
 
 static void
 end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
 {
+  if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK)
+    GNUNET_SCHEDULER_cancel(sched, curr_get_ctx.retry_task);
+
   if (curr_get_ctx.get_handle != NULL)
   {
     GNUNET_DHT_get_stop(curr_get_ctx.get_handle, &end_badly_cont, NULL);
@@ -152,6 +164,7 @@
                           const void *data)
 {
   struct PeerGetContext *get_context = cls;
+
   if (0 != memcmp(&get_context->peer->hashPubKey, key, sizeof 
(GNUNET_HashCode)))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Key returned is not the same key 
as was searched for!\n");
@@ -160,6 +173,12 @@
     return;
   }
 
+  if (get_context->retry_task != GNUNET_SCHEDULER_NO_TASK)
+    {
+      GNUNET_SCHEDULER_cancel(sched, get_context->retry_task);
+      get_context->retry_task = GNUNET_SCHEDULER_NO_TASK;
+    }
+
   if (get_context->peer == &peer2id)
   {
     get_context->peer = &peer1id;
@@ -174,15 +193,56 @@
     GNUNET_DHT_get_stop(get_context->get_handle, &finish_testing, NULL);
   }
 
+}
 
+static void
+stop_retry_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc);
+
+static void
+get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
+{
+  struct PeerGetContext *get_context = cls;
+
+  if (get_context->get_attempts < MAX_GET_ATTEMPTS)
+    GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Get attempt %u failed, retrying 
request!\n", get_context->get_attempts);
+  else
+    {
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Too many attempts failed, ending 
test!\n", get_context->get_attempts);
+      GNUNET_SCHEDULER_cancel(sched, die_task);
+      GNUNET_SCHEDULER_add_now(sched, &end_badly, "key mismatch in get 
response!\n");
+      return;
+    }
+  get_context->get_attempts++;
+  get_context->retry_task = GNUNET_SCHEDULER_add_delayed(sched,
+                                                         
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10),
+                                                          &stop_retry_get, 
get_context);
+  get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle, 
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5),
+                                                 0, 
&get_context->peer->hashPubKey, &get_result_iterator, get_context, NULL, NULL);
 }
 
 static void
+stop_retry_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
+{
+  struct PeerGetContext *get_context = cls;
+  get_context->retry_task = GNUNET_SCHEDULER_NO_TASK;
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Get attempt %u failed, canceling 
request!\n", get_context->get_attempts);
+  //if (get_context->get_sent == GNUNET_YES)
+  GNUNET_DHT_get_stop(get_context->get_handle, &get_stop_finished, 
get_context);
+  //else
+  //  GNUNET_SCHEDULER_add_now(sched, &get_stop_finished, get_context);
+}
+
+static void
 do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
 {
   struct PeerGetContext *get_context = cls;
 
-  get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle, 
GNUNET_TIME_relative_get_forever(), 0, &get_context->peer->hashPubKey, 
&get_result_iterator, get_context, NULL, NULL);
+  get_context->retry_task = GNUNET_SCHEDULER_add_delayed(sched,
+                                                         
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10),
+                                                          &stop_retry_get, 
get_context);
+
+  get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle, 
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5),
+                                                 0, 
&get_context->peer->hashPubKey, &get_result_iterator, get_context, NULL, NULL);
 }
 
 

Modified: gnunet/src/dht/test_dht_twopeer_data.conf
===================================================================
--- gnunet/src/dht/test_dht_twopeer_data.conf   2010-09-15 11:12:59 UTC (rev 
12998)
+++ gnunet/src/dht/test_dht_twopeer_data.conf   2010-09-15 13:00:17 UTC (rev 
12999)
@@ -25,7 +25,7 @@
 PORT = 12092
 
 [arm]
-DEFAULTSERVICES = core dht
+DEFAULTSERVICES = dht
 PORT = 12366
 DEBUG = NO
 

Modified: gnunet/src/dht/test_dhtlog_data.conf
===================================================================
--- gnunet/src/dht/test_dhtlog_data.conf        2010-09-15 11:12:59 UTC (rev 
12998)
+++ gnunet/src/dht/test_dhtlog_data.conf        2010-09-15 13:00:17 UTC (rev 
12999)
@@ -17,7 +17,7 @@
 PORT = 12092
 
 [arm]
-DEFAULTSERVICES = core dht
+DEFAULTSERVICES = dht
 PORT = 12366
 DEBUG = NO
 




reply via email to

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