-ecc sign/verify only
[oweals/gnunet.git] / src / util / client.c
index 73cca2383c197a1843f09b7a3cccea91bd39f81b..81c696a7b679bc7856a81ea4f415272640681d08 100644 (file)
  * connections between clients and service providers.
  */
 #include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_client_lib.h"
 #include "gnunet_protocols.h"
-#include "gnunet_server_lib.h"
-#include "gnunet_scheduler_lib.h"
+#include "gnunet_util_lib.h"
 
 
 /**
@@ -239,6 +236,11 @@ struct GNUNET_CLIENT_Connection
    */
   int in_receive;
 
+  /**
+   * Is this the first message we are sending to the service?
+   */
+  int first_message;
+
   /**
    * How often have we tried to connect?
    */
@@ -422,6 +424,7 @@ GNUNET_CLIENT_connect (const char *service_name,
     return NULL;
   connection = do_connect (service_name, cfg, 0);
   client = GNUNET_malloc (sizeof (struct GNUNET_CLIENT_Connection));
+  client->first_message = GNUNET_YES;
   client->attempts = 1;
   client->connection = connection;
   client->service_name = GNUNET_strdup (service_name);
@@ -944,6 +947,7 @@ client_delayed_retry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   th->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
   th->client->connection =
       do_connect (th->client->service_name, th->client->cfg, th->client->attempts++);
+  th->client->first_message = GNUNET_YES;
   if (NULL == th->client->connection)
   {
     /* could happen if we're out of sockets */
@@ -955,9 +959,9 @@ client_delayed_retry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                                   (th->client->back_off, 2),
                                   GNUNET_TIME_UNIT_SECONDS);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Transmission failed %u times, trying again in %llums.\n",
+         "Transmission failed %u times, trying again in %s.\n",
          MAX_ATTEMPTS - th->attempts_left,
-         (unsigned long long) delay.rel_value);
+         GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
     th->reconnect_task =
         GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th);
     return;
@@ -1028,9 +1032,9 @@ client_notify (void *cls, size_t size, void *buf)
                                   (client->back_off, 2),
                                   GNUNET_TIME_UNIT_SECONDS);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Transmission failed %u times, trying again in %llums.\n",
+         "Transmission failed %u times, trying again in %s.\n",
          MAX_ATTEMPTS - th->attempts_left,
-         (unsigned long long) delay.rel_value);
+         GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
     client->th = th;
     th->reconnect_task =
         GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th);
@@ -1083,7 +1087,9 @@ GNUNET_CLIENT_notify_transmit_ready (struct GNUNET_CLIENT_Connection *client,
   th->client = client;
   th->size = size;
   th->timeout = GNUNET_TIME_relative_to_absolute (timeout);
-  th->auto_retry = auto_retry;
+  /* always auto-retry on first message to service */
+  th->auto_retry = (GNUNET_YES == client->first_message) ? GNUNET_YES : auto_retry;
+  client->first_message = GNUNET_NO;
   th->notify = notify;
   th->notify_cls = notify_cls;
   th->attempts_left = MAX_ATTEMPTS;