-bugfixes, code cleanup
[oweals/gnunet.git] / src / dht / dht_api.c
index c9f1caee3c6908117a582a1c86941a4ea9a0a15d..0905486d12cb508ffc3b4e02743b06e1a5f3dfa3 100644 (file)
@@ -401,13 +401,7 @@ try_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   struct GNUNET_DHT_Handle *handle = cls;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting with DHT %p\n", handle);
-  handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
-  if (handle->retry_time.rel_value < GNUNET_CONSTANTS_SERVICE_RETRY.rel_value)
-    handle->retry_time = GNUNET_CONSTANTS_SERVICE_RETRY;
-  else
-    handle->retry_time = GNUNET_TIME_relative_multiply (handle->retry_time, 2);
-  if (handle->retry_time.rel_value > GNUNET_CONSTANTS_SERVICE_TIMEOUT.rel_value)
-    handle->retry_time = GNUNET_CONSTANTS_SERVICE_TIMEOUT;
+  handle->retry_time = GNUNET_TIME_STD_BACKOFF (handle->retry_time);
   handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
   if (GNUNET_YES != try_connect (handle))
   {
@@ -438,8 +432,9 @@ do_disconnect (struct GNUNET_DHT_Handle *handle)
     GNUNET_CLIENT_notify_transmit_ready_cancel (handle->th);
   handle->th = NULL;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Disconnecting from DHT service, will try to reconnect in %llu ms\n",
-              (unsigned long long) handle->retry_time.rel_value);
+              "Disconnecting from DHT service, will try to reconnect in %s\n",
+              GNUNET_STRINGS_relative_time_to_string (handle->retry_time,
+                                                     GNUNET_YES));
   GNUNET_CLIENT_disconnect (handle->client);
   handle->client = NULL;
 
@@ -881,8 +876,8 @@ service_message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
   default:
     GNUNET_break(0);
     LOG (GNUNET_ERROR_TYPE_WARNING,
-         "Unknown DHT message type: %su\n",
-         ntohs (msg->type));
+         "Unknown DHT message type: %hu (%hu) size: %hu\n",
+         ntohs (msg->type), msg->type, msize);
     break;
   }
   if (GNUNET_OK != ret)
@@ -915,7 +910,7 @@ GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
   handle->cfg = cfg;
   handle->uid_gen =
       GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
-  handle->active_requests = GNUNET_CONTAINER_multihashmap_create (ht_len);
+  handle->active_requests = GNUNET_CONTAINER_multihashmap_create (ht_len, GNUNET_NO);
   if (GNUNET_NO == try_connect (handle))
   {
     GNUNET_DHT_disconnect (handle);