- fix error messages
[oweals/gnunet.git] / src / transport / transport_api.c
index 6737ef6508b8989e9d4fe98d2283961316f1f9da..292aca5f0eadf69a0b7787b84c8558dfb14adff4 100644 (file)
@@ -477,11 +477,12 @@ neighbour_delete (void *cls,
   return GNUNET_YES;
 }
 
+static int reconnecting;
 
 /**
  * Function we use for handling incoming messages.
  *
- * @param cls closure (struct GNUNET_TRANSPORT_Handle *)
+ * @param cls closure, a `struct GNUNET_TRANSPORT_Handle *`
  * @param msg message received, NULL on timeout or fatal error
  */
 static void
@@ -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;
     }
@@ -714,9 +722,9 @@ timeout_request_due_to_congestion (void *cls,
  * Transmit message(s) to service.
  *
  * @param cls handle to transport
- * @param size number of bytes available in buf
+ * @param size number of bytes available in @a buf
  * @param buf where to copy the message
- * @return number of bytes copied to buf
+ * @return number of bytes copied to @a buf
  */
 static size_t
 transport_notify_ready (void *cls, size_t size, void *buf)
@@ -746,7 +754,8 @@ transport_notify_ready (void *cls, size_t size, void *buf)
   {
     GNUNET_CONTAINER_DLL_remove (h->control_head, h->control_tail, th);
     nret = th->notify (th->notify_cls, size, &cbuf[ret]);
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "Added %u bytes of control message at %u\n",
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Added %u bytes of control message at %u\n",
          nret, ret);
     GNUNET_free (th);
     ret += nret;
@@ -913,7 +922,7 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h)
  * @param h handle to the transport service
  * @param size number of bytes to be transmitted
  * @param notify function to call to get the content
- * @param notify_cls closure for notify
+ * @param notify_cls closure for @a notify
  * @return a `struct GNUNET_TRANSPORT_TransmitHandle`
  */
 static struct GNUNET_TRANSPORT_TransmitHandle *
@@ -940,9 +949,9 @@ schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h, size_t size,
  * Transmit START message to service.
  *
  * @param cls unused
- * @param size number of bytes available in buf
+ * @param size number of bytes available in @a buf
  * @param buf where to copy the message
- * @return number of bytes copied to buf
+ * @return number of bytes copied to @a buf
  */
 static size_t
 send_start (void *cls, size_t size, void *buf)
@@ -1002,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);
 }
@@ -1029,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,
@@ -1384,7 +1397,7 @@ GNUNET_TRANSPORT_offer_hello_cancel (struct GNUNET_TRANSPORT_OfferHelloHandle *o
  */
 int
 GNUNET_TRANSPORT_check_peer_connected (struct GNUNET_TRANSPORT_Handle *handle,
-                                           const struct GNUNET_PeerIdentity *peer)
+                                       const struct GNUNET_PeerIdentity *peer)
 {
   if (GNUNET_YES ==
       GNUNET_CONTAINER_multipeermap_contains (handle->neighbours,
@@ -1397,7 +1410,7 @@ GNUNET_TRANSPORT_check_peer_connected (struct GNUNET_TRANSPORT_Handle *handle,
 /**
  * Task to call the HelloUpdateCallback of the GetHelloHandle
  *
- * @param cls the GetHelloHandle
+ * @param cls the `struct GNUNET_TRANSPORT_GetHelloHandle`
  * @param tc the scheduler task context
  */
 static void
@@ -1517,7 +1530,7 @@ GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
 /**
  * Disconnect from the transport service.
  *
- * @param handle handle to the service as returned from GNUNET_TRANSPORT_connect
+ * @param handle handle to the service as returned from #GNUNET_TRANSPORT_connect()
  */
 void
 GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle)