gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r10192 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r10192 - gnunet/src/util
Date: Tue, 2 Feb 2010 11:25:43 +0100

Author: grothoff
Date: 2010-02-02 11:25:43 +0100 (Tue, 02 Feb 2010)
New Revision: 10192

Modified:
   gnunet/src/util/client.c
   gnunet/src/util/service.c
Log:
fixing test service running to retry if service is not running

Modified: gnunet/src/util/client.c
===================================================================
--- gnunet/src/util/client.c    2010-02-02 09:33:28 UTC (rev 10191)
+++ gnunet/src/util/client.c    2010-02-02 10:25:43 UTC (rev 10192)
@@ -34,9 +34,8 @@
 #include "gnunet_server_lib.h"
 #include "gnunet_scheduler_lib.h"
 
-#define DEBUG_CLIENT GNUNET_YES
+#define DEBUG_CLIENT GNUNET_NO
 
-
 /**
  * How often do we re-try tranmsitting requests before giving up?
  * Note that if we succeeded transmitting a request but failed to read
@@ -195,6 +194,11 @@
   GNUNET_SCHEDULER_Task test_cb;
 
   /**
+   * Deadline for calling 'test_cb'.
+   */
+  struct GNUNET_TIME_Absolute test_deadline;
+
+  /**
    * If we are re-trying and are delaying to do so,
    * handle to the scheduled task managing the delay.
    */
@@ -322,6 +326,7 @@
   return ret;
 }
 
+
 /**
  * Configure this connection to ignore shutdown signals.
  *
@@ -629,6 +634,7 @@
 static size_t
 write_test (void *cls, size_t size, void *buf)
 {
+  struct GNUNET_CLIENT_Connection *conn = cls;
   struct GNUNET_MessageHeader *msg;
 
   if (size < sizeof (struct GNUNET_MessageHeader))
@@ -637,6 +643,7 @@
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   _("Failure to transmit TEST request.\n"));
 #endif
+      service_test_error (conn->sched, conn->test_cb, conn->test_cb_cls);
       return 0;                 /* client disconnected */
     }
 #if DEBUG_CLIENT
@@ -646,6 +653,10 @@
   msg = (struct GNUNET_MessageHeader *) buf;
   msg->type = htons (GNUNET_MESSAGE_TYPE_TEST);
   msg->size = htons (sizeof (struct GNUNET_MessageHeader));
+  GNUNET_CLIENT_receive (conn, 
+                        &confirm_handler, 
+                        conn, 
+                        GNUNET_TIME_absolute_get_remaining 
(conn->test_deadline));
   return sizeof (struct GNUNET_MessageHeader);
 }
 
@@ -687,20 +698,13 @@
     }
   conn->test_cb = task;
   conn->test_cb_cls = task_cls;
-  
+  conn->test_deadline = GNUNET_TIME_relative_to_absolute (timeout);
 
   if (NULL == GNUNET_CLIENT_notify_transmit_ready (conn,
-                                       sizeof (struct GNUNET_MessageHeader),
-                                       timeout,
-                                       GNUNET_YES,
-                                       &write_test, NULL))  
-  /*      
-  if (NULL ==
-      GNUNET_CONNECTION_notify_transmit_ready (conn->sock,
-                                               sizeof (struct
-                                                       GNUNET_MessageHeader),
-                                               timeout, &write_test, NULL))
-         */
+                                                  sizeof (struct 
GNUNET_MessageHeader),
+                                                  timeout,
+                                                  GNUNET_YES,
+                                                  &write_test, conn))  
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                   _("Failure to transmit request to service `%s'\n"),
@@ -709,7 +713,6 @@
       GNUNET_CLIENT_disconnect (conn);
       return;
     }
-  GNUNET_CLIENT_receive (conn, &confirm_handler, conn, timeout);
 }
 
 
@@ -739,7 +742,6 @@
 {
   struct GNUNET_CLIENT_TransmitHandle *th = cls;
 
-  fprintf (stderr, "cdr running\n");
   th->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
     {
@@ -768,9 +770,8 @@
 
 
 /**
- * Connection notifies us about failure or success of
- * a transmission request.  Either pass it on to our
- * user or, if possible, retry.
+ * Connection notifies us about failure or success of a transmission
+ * request.  Either pass it on to our user or, if possible, retry.
  *
  * @param cls our "struct GNUNET_CLIENT_TransmissionHandle"
  * @param size number of bytes available for transmission
@@ -795,11 +796,6 @@
           (0 == --th->attempts_left) || 
           (delay.value < 1) )
         {
-         fprintf (stderr, "Signaling timeout, reason: %d %d %d %d\n", 
-       (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & GNUNET_SCHEDULER_get_reason 
(th->sock->sched))),
-          (GNUNET_YES != th->auto_retry),
-          (0 == --th->attempts_left) , 
-          (delay.value < 1) );
 #if DEBUG_CLIENT
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                       "Transmission failed %u times, giving up.\n",

Modified: gnunet/src/util/service.c
===================================================================
--- gnunet/src/util/service.c   2010-02-02 09:33:28 UTC (rev 10191)
+++ gnunet/src/util/service.c   2010-02-02 10:25:43 UTC (rev 10192)
@@ -1452,8 +1452,9 @@
 
   GNUNET_CONFIGURATION_destroy (cfg);
   i = 0;
-  while (sctx.addrs[i] != NULL)    
-    GNUNET_free (sctx.addrs[i++]);    
+  if (sctx.addrs != NULL)
+    while (sctx.addrs[i] != NULL)    
+      GNUNET_free (sctx.addrs[i++]);    
   GNUNET_free_non_null (sctx.addrs);
   GNUNET_free_non_null (sctx.addrlens);
   GNUNET_free_non_null (logfile);





reply via email to

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