- fix error messages
[oweals/gnunet.git] / src / transport / transport_api.c
index 8d921acdcb3eb0a806b443fdb04c0eef7cf8d818..292aca5f0eadf69a0b7787b84c8558dfb14adff4 100644 (file)
@@ -477,6 +477,7 @@ neighbour_delete (void *cls,
   return GNUNET_YES;
 }
 
+static int reconnecting;
 
 /**
  * Function we use for handling incoming messages.
@@ -503,10 +504,15 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
   uint32_t bytes_physical;
 
   GNUNET_assert (NULL != h->client);
+  if (GNUNET_YES == reconnecting)
+  {
+    return;
+  }
   if (NULL == msg)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Error receiving from transport service, disconnecting temporarily.\n");
+    reconnecting = GNUNET_YES;
     disconnect_and_schedule_reconnect (h);
     return;
   }
@@ -603,8 +609,9 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
     okm = (const struct SendOkMessage *) msg;
     bytes_msg = ntohl (okm->bytes_msg);
     bytes_physical = ntohl (okm->bytes_physical);
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message, transmission %s.\n",
-         "SEND_OK", ntohl (okm->success) == GNUNET_OK ? "succeeded" : "failed");
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Receiving SEND_OK message, transmission %s.\n",
+         ntohl (okm->success) == GNUNET_OK ? "succeeded" : "failed");
 
     n = neighbour_find (h, &okm->peer);
     if (NULL == n)
@@ -612,7 +619,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
 
     if (bytes_physical >= bytes_msg)
     {
-        LOG (GNUNET_ERROR_TYPE_DEBUG, "Overhead for %u byte message: %u \n",
+        LOG (GNUNET_ERROR_TYPE_DEBUG,
+             "Overhead for %u byte message: %u\n",
             bytes_msg, bytes_physical - bytes_msg);
       n->traffic_overhead += bytes_physical - bytes_msg;
     }
@@ -1003,7 +1011,9 @@ reconnect (void *cls,
   GNUNET_assert (NULL == h->client);
   GNUNET_assert (NULL == h->control_head);
   GNUNET_assert (NULL == h->control_tail);
+  reconnecting = GNUNET_NO;
   h->client = GNUNET_CLIENT_connect ("transport", h->cfg);
+
   GNUNET_assert (NULL != h->client);
   schedule_control_transmit (h, sizeof (struct StartMessage), &send_start, h);
 }
@@ -1030,6 +1040,8 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h)
   {
     GNUNET_CLIENT_disconnect (h->client);
     h->client = NULL;
+/*    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "Client disconnect done \n");*/
   }
   /* Forget about all neighbours that we used to be connected to */
   GNUNET_CONTAINER_multipeermap_iterate (h->neighbours,