- fix coverity
[oweals/gnunet.git] / src / transport / transport_api.c
index f1aefc20322fd71633583421584e8089c8b7926e..59f249686f19d8fd621e0d0df9170c38a79de4b4 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2009-2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2009-2013 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -202,92 +202,6 @@ struct GNUNET_TRANSPORT_GetHelloHandle
 };
 
 
-/**
- * Entry in linked list for a try-connect request.
- */
-struct GNUNET_TRANSPORT_TryConnectHandle
-{
-  /**
-   * For the DLL.
-   */
-  struct GNUNET_TRANSPORT_TryConnectHandle *prev;
-
-  /**
-   * For the DLL.
-   */
-  struct GNUNET_TRANSPORT_TryConnectHandle *next;
-
-  /**
-   * Peer we should try to connect to.
-   */
-  struct GNUNET_PeerIdentity pid;
-
-  /**
-   * Transport service handle this request is part of.
-   */
-  struct GNUNET_TRANSPORT_Handle *th;
-
-  /**
-   * Message transmission request to communicate to service.
-   */
-  struct GNUNET_TRANSPORT_TransmitHandle *tth;
-
-  /**
-   * Function to call upon completion (of request transmission).
-   */
-  GNUNET_TRANSPORT_TryConnectCallback cb;
-
-  /**
-   * Closure for @e cb.
-   */
-  void *cb_cls;
-
-};
-
-
-/**
- * Entry in linked list for all try-disconnect requests
- */
-struct GNUNET_TRANSPORT_TryDisconnectHandle
-{
-  /**
-   * For the DLL.
-   */
-  struct GNUNET_TRANSPORT_TryDisconnectHandle *prev;
-
-  /**
-   * For the DLL.
-   */
-  struct GNUNET_TRANSPORT_TryDisconnectHandle *next;
-
-  /**
-   * Peer we should try to connect to.
-   */
-  struct GNUNET_PeerIdentity pid;
-
-  /**
-   * Transport service handle this request is part of.
-   */
-  struct GNUNET_TRANSPORT_Handle *th;
-
-  /**
-   * Message transmission request to communicate to service.
-   */
-  struct GNUNET_TRANSPORT_TransmitHandle *tth;
-
-  /**
-   * Function to call upon completion (of request transmission).
-   */
-  GNUNET_TRANSPORT_TryDisconnectCallback cb;
-
-  /**
-   * Closure for @e cb.
-   */
-  void *cb_cls;
-
-};
-
-
 /**
  * Entry in linked list for all offer-HELLO requests.
  */
@@ -398,26 +312,6 @@ struct GNUNET_TRANSPORT_Handle
    */
   struct GNUNET_TRANSPORT_GetHelloHandle *hwl_tail;
 
-  /**
-   * Linked list of pending try connect requests head
-   */
-  struct GNUNET_TRANSPORT_TryConnectHandle *tc_head;
-
-  /**
-   * Linked list of pending try connect requests tail
-   */
-  struct GNUNET_TRANSPORT_TryConnectHandle *tc_tail;
-
-  /**
-   * Linked list of pending try disconnect requests head
-   */
-  struct GNUNET_TRANSPORT_TryDisconnectHandle *td_head;
-
-  /**
-   * Linked list of pending try connect requests tail
-   */
-  struct GNUNET_TRANSPORT_TryDisconnectHandle *td_tail;
-
   /**
    * Linked list of pending offer HELLO requests head
    */
@@ -507,11 +401,9 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h);
  * A neighbour has not gotten a SEND_OK in a  while. Print a warning.
  *
  * @param cls the `struct Neighbour`
- * @param tc scheduler context
  */
 static void
-do_warn_unready (void *cls,
-                 const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_warn_unready (void *cls)
 {
   struct Neighbour *n = cls;
   struct GNUNET_TIME_Relative delay;
@@ -743,6 +635,8 @@ demultiplexer (void *cls,
     if (size < sizeof (struct ConnectInfoMessage))
     {
       GNUNET_break (0);
+      h->reconnecting = GNUNET_YES;
+      disconnect_and_schedule_reconnect (h);
       break;
     }
     cim = (const struct ConnectInfoMessage *) msg;
@@ -750,6 +644,8 @@ demultiplexer (void *cls,
         sizeof (struct ConnectInfoMessage))
     {
       GNUNET_break (0);
+      h->reconnecting = GNUNET_YES;
+      disconnect_and_schedule_reconnect (h);
       break;
     }
     LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -759,6 +655,8 @@ demultiplexer (void *cls,
     if (NULL != n)
     {
       GNUNET_break (0);
+      h->reconnecting = GNUNET_YES;
+      disconnect_and_schedule_reconnect (h);
       break;
     }
     n = neighbour_add (h,
@@ -777,6 +675,8 @@ demultiplexer (void *cls,
     if (size != sizeof (struct DisconnectInfoMessage))
     {
       GNUNET_break (0);
+      h->reconnecting = GNUNET_YES;
+      disconnect_and_schedule_reconnect (h);
       break;
     }
     dim = (const struct DisconnectInfoMessage *) msg;
@@ -788,6 +688,8 @@ demultiplexer (void *cls,
     if (NULL == n)
     {
       GNUNET_break (0);
+      h->reconnecting = GNUNET_YES;
+      disconnect_and_schedule_reconnect (h);
       break;
     }
     neighbour_delete (h,
@@ -798,28 +700,33 @@ demultiplexer (void *cls,
     if (size != sizeof (struct SendOkMessage))
     {
       GNUNET_break (0);
+      h->reconnecting = GNUNET_YES;
+      disconnect_and_schedule_reconnect (h);
       break;
     }
     okm = (const struct SendOkMessage *) msg;
     bytes_msg = ntohl (okm->bytes_msg);
     bytes_physical = ntohl (okm->bytes_physical);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Receiving SEND_OK message, transmission %s.\n",
+         "Receiving SEND_OK message, transmission to %s %s.\n",
+         GNUNET_i2s (&okm->peer),
          ntohl (okm->success) == GNUNET_OK ? "succeeded" : "failed");
 
     n = neighbour_find (h,
                         &okm->peer);
     if (NULL == n)
     {
-      /* we should never get a 'SEND_OK' for a peer that we are not
+      /* We should never get a 'SEND_OK' for a peer that we are not
          connected to */
       GNUNET_break (0);
+      h->reconnecting = GNUNET_YES;
+      disconnect_and_schedule_reconnect (h);
       break;
     }
-    if (bytes_physical >= bytes_msg)
+    if (bytes_physical > bytes_msg)
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG,
-           "Overhead for %u byte message: %u\n",
+           "Overhead for %u byte message was %u\n",
            bytes_msg,
            bytes_physical - bytes_msg);
       n->traffic_overhead += bytes_physical - bytes_msg;
@@ -838,15 +745,19 @@ demultiplexer (void *cls,
       n->th->timeout_task = NULL;
       /* we've been waiting for this (congestion, not quota,
        * caused delayed transmission) */
-      n->hn = GNUNET_CONTAINER_heap_insert (h->ready_heap, n, 0);
-      schedule_transmission (h);
+      n->hn = GNUNET_CONTAINER_heap_insert (h->ready_heap,
+                                            n,
+                                            0);
     }
+    schedule_transmission (h);
     break;
   case GNUNET_MESSAGE_TYPE_TRANSPORT_RECV:
     if (size <
         sizeof (struct InboundMessage) + sizeof (struct GNUNET_MessageHeader))
     {
       GNUNET_break (0);
+      h->reconnecting = GNUNET_YES;
+      disconnect_and_schedule_reconnect (h);
       break;
     }
     im = (const struct InboundMessage *) msg;
@@ -854,15 +765,21 @@ demultiplexer (void *cls,
     if (ntohs (imm->size) + sizeof (struct InboundMessage) != size)
     {
       GNUNET_break (0);
+      h->reconnecting = GNUNET_YES;
+      disconnect_and_schedule_reconnect (h);
       break;
     }
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Received message of type %u from `%s'.\n",
-         ntohs (imm->type), GNUNET_i2s (&im->peer));
+         "Received message of type %u with %u bytes from `%s'.\n",
+         (unsigned int) ntohs (imm->type),
+         (unsigned int) ntohs (imm->size),
+         GNUNET_i2s (&im->peer));
     n = neighbour_find (h, &im->peer);
     if (NULL == n)
     {
       GNUNET_break (0);
+      h->reconnecting = GNUNET_YES;
+      disconnect_and_schedule_reconnect (h);
       break;
     }
     if (NULL != h->rec)
@@ -874,12 +791,19 @@ demultiplexer (void *cls,
     if (size != sizeof (struct QuotaSetMessage))
     {
       GNUNET_break (0);
+      h->reconnecting = GNUNET_YES;
+      disconnect_and_schedule_reconnect (h);
       break;
     }
     qm = (const struct QuotaSetMessage *) msg;
     n = neighbour_find (h, &qm->peer);
     if (NULL == n)
+    {
+      GNUNET_break (0);
+      h->reconnecting = GNUNET_YES;
+      disconnect_and_schedule_reconnect (h);
       break;
+    }
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Receiving SET_QUOTA message for `%s' with quota %u\n",
          GNUNET_i2s (&qm->peer),
@@ -904,11 +828,9 @@ demultiplexer (void *cls,
  * network congestion.  Notify the initiator and clean up.
  *
  * @param cls the `struct GNUNET_TRANSPORT_TransmitHandle`
- * @param tc scheduler context
  */
 static void
-timeout_request_due_to_congestion (void *cls,
-                                   const struct GNUNET_SCHEDULER_TaskContext *tc)
+timeout_request_due_to_congestion (void *cls)
 {
   struct GNUNET_TRANSPORT_TransmitHandle *th = cls;
   struct Neighbour *n = th->neighbour;
@@ -976,7 +898,7 @@ transport_notify_ready (void *cls,
                        size,
                        &cbuf[ret]);
     delay = GNUNET_TIME_absolute_get_duration (th->request_start);
-    if (delay.rel_value_us > 1000 * 1000)
+    if (delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us)
       LOG (GNUNET_ERROR_TYPE_WARNING,
            "Added %u bytes of control message at %u after %s delay\n",
            nret,
@@ -1016,7 +938,8 @@ transport_notify_ready (void *cls,
     if (th->notify_size + sizeof (struct OutboundMessage) > size)
       break;                    /* does not fit */
     if (GNUNET_BANDWIDTH_tracker_get_delay
-        (&n->out_tracker, th->notify_size).rel_value_us > 0)
+        (&n->out_tracker,
+         th->notify_size).rel_value_us > 0)
       break;                    /* too early */
     GNUNET_assert (n == GNUNET_CONTAINER_heap_remove_root (h->ready_heap));
     n->hn = NULL;
@@ -1055,20 +978,22 @@ transport_notify_ready (void *cls,
     GNUNET_BANDWIDTH_tracker_consume (&n->out_tracker,
                                       mret);
     delay = GNUNET_TIME_absolute_get_duration (th->request_start);
-    if (delay.rel_value_us > 1000 * 1000)
+    if (delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us)
       LOG (GNUNET_ERROR_TYPE_WARNING,
-           "Added %u bytes of payload message at %u after %s delay\n",
+           "Added %u bytes of payload message for %s after %s delay at %u b/s\n",
            mret,
-           ret,
+           GNUNET_i2s (&n->id),
            GNUNET_STRINGS_relative_time_to_string (delay,
-                                                   GNUNET_YES));
+                                                   GNUNET_YES),
+           (unsigned int) n->out_tracker.available_bytes_per_s__);
     else
       LOG (GNUNET_ERROR_TYPE_DEBUG,
-           "Added %u bytes of payload message at %u after %s delay\n",
+           "Added %u bytes of payload message for %s after %s delay at %u b/s\n",
            mret,
-           ret,
+           GNUNET_i2s (&n->id),
            GNUNET_STRINGS_relative_time_to_string (delay,
-                                                   GNUNET_YES));
+                                                   GNUNET_YES),
+           (unsigned int) n->out_tracker.available_bytes_per_s__);
     GNUNET_free (th);
     break;
   }
@@ -1086,11 +1011,9 @@ transport_notify_ready (void *cls,
  * list or the peer message queues  to the service.
  *
  * @param cls transport service to schedule a transmission for
- * @param tc scheduler context
  */
 static void
-schedule_transmission_task (void *cls,
-                            const struct GNUNET_SCHEDULER_TaskContext *tc)
+schedule_transmission_task (void *cls)
 {
   struct GNUNET_TRANSPORT_Handle *h = cls;
   size_t size;
@@ -1171,7 +1094,11 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h)
     n->traffic_overhead = 0;
   }
   else
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "No work to be done, not scheduling transmission.\n");
     return;                     /* no work to be done */
+  }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Scheduling next transmission to service in %s\n",
        GNUNET_STRINGS_relative_time_to_string (delay,
@@ -1264,20 +1191,13 @@ send_start (void *cls,
  * Try again to connect to transport service.
  *
  * @param cls the handle to the transport service
- * @param tc scheduler context
  */
 static void
-reconnect (void *cls,
-           const struct GNUNET_SCHEDULER_TaskContext *tc)
+reconnect (void *cls)
 {
   struct GNUNET_TRANSPORT_Handle *h = cls;
 
   h->reconnect_task = NULL;
-  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
-  {
-    /* shutdown, just give up */
-    return;
-  }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Connecting to transport service.\n");
   GNUNET_assert (NULL == h->client);
@@ -1303,7 +1223,7 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h)
 {
   struct GNUNET_TRANSPORT_TransmitHandle *th;
 
-  GNUNET_assert (h->reconnect_task == NULL);
+  GNUNET_assert (NULL == h->reconnect_task);
   if (NULL != h->cth)
   {
     GNUNET_CLIENT_notify_transmit_ready_cancel (h->cth);
@@ -1366,216 +1286,6 @@ cancel_control_transmit (struct GNUNET_TRANSPORT_Handle *th,
 }
 
 
-/**
- * Send #GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT message to the
- * service.
- *
- * @param cls the `struct GNUNET_TRANSPORT_TryConnectHandle`
- * @param size number of bytes available in @a buf
- * @param buf where to copy the message
- * @return number of bytes copied to @a buf
- */
-static size_t
-send_try_connect (void *cls,
-                  size_t size,
-                  void *buf)
-{
-  struct GNUNET_TRANSPORT_TryConnectHandle *tch = cls;
-  struct TransportRequestConnectMessage msg;
-
-  tch->tth = NULL;
-  if (NULL == buf)
-  {
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Discarding  `%s' request to `%s' due to error in transport service connection.\n",
-         "REQUEST_CONNECT",
-         GNUNET_i2s (&tch->pid));
-    if (NULL != tch->cb)
-      tch->cb (tch->cb_cls,
-               GNUNET_SYSERR);
-    GNUNET_TRANSPORT_try_connect_cancel (tch);
-    return 0;
-  }
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Transmitting `%s' request with respect to `%s'.\n",
-       "REQUEST_CONNECT",
-       GNUNET_i2s (&tch->pid));
-  GNUNET_assert (size >= sizeof (struct TransportRequestConnectMessage));
-  msg.header.size = htons (sizeof (struct TransportRequestConnectMessage));
-  msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT);
-  msg.reserved = htonl (0);
-  msg.peer = tch->pid;
-  memcpy (buf, &msg, sizeof (msg));
-  if (NULL != tch->cb)
-    tch->cb (tch->cb_cls, GNUNET_OK);
-  GNUNET_TRANSPORT_try_connect_cancel (tch);
-  return sizeof (struct TransportRequestConnectMessage);
-}
-
-
-/**
- * Ask the transport service to establish a connection to
- * the given peer.
- *
- * @param handle connection to transport service
- * @param target who we should try to connect to
- * @param cb callback to be called when request was transmitted to transport
- *         service
- * @param cb_cls closure for the callback
- * @return a `struct GNUNET_TRANSPORT_TryConnectHandle` handle or
- *         NULL on failure (cb will not be called)
- */
-struct GNUNET_TRANSPORT_TryConnectHandle *
-GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle,
-                              const struct GNUNET_PeerIdentity *target,
-                              GNUNET_TRANSPORT_TryConnectCallback cb,
-                              void *cb_cls)
-{
-  struct GNUNET_TRANSPORT_TryConnectHandle *tch;
-
-  if (NULL == handle->client)
-    return NULL;
-  tch = GNUNET_new (struct GNUNET_TRANSPORT_TryConnectHandle);
-  tch->th = handle;
-  tch->pid = *target;
-  tch->cb = cb;
-  tch->cb_cls = cb_cls;
-  tch->tth = schedule_control_transmit (handle,
-                                        sizeof (struct TransportRequestConnectMessage),
-                                        &send_try_connect, tch);
-  GNUNET_CONTAINER_DLL_insert (handle->tc_head,
-                               handle->tc_tail,
-                               tch);
-  return tch;
-}
-
-
-/**
- * Cancel the request to transport to try a connect
- * Callback will not be called
- *
- * @param tch the handle to cancel
- */
-void
-GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *tch)
-{
-  struct GNUNET_TRANSPORT_Handle *th;
-
-  th = tch->th;
-  if (NULL != tch->tth)
-    cancel_control_transmit (th, tch->tth);
-  GNUNET_CONTAINER_DLL_remove (th->tc_head,
-                               th->tc_tail,
-                               tch);
-  GNUNET_free (tch);
-}
-
-
-/**
- * Send #GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_DISCONNECT message to the
- * service.
- *
- * @param cls the `struct GNUNET_TRANSPORT_TryDisconnectHandle`
- * @param size number of bytes available in @a buf
- * @param buf where to copy the message
- * @return number of bytes copied to @a buf
- */
-static size_t
-send_try_disconnect (void *cls,
-                     size_t size,
-                     void *buf)
-{
-  struct GNUNET_TRANSPORT_TryDisconnectHandle *tdh = cls;
-  struct TransportRequestConnectMessage msg;
-
-  tdh->th = NULL;
-  if (NULL == buf)
-  {
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Discarding  `%s' request to `%s' due to error in transport service connection.\n",
-         "REQUEST_DISCONNECT",
-         GNUNET_i2s (&tdh->pid));
-    if (NULL != tdh->cb)
-      tdh->cb (tdh->cb_cls,
-               GNUNET_SYSERR);
-    GNUNET_TRANSPORT_try_disconnect_cancel (tdh);
-    return 0;
-  }
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Transmitting `%s' request with respect to `%s'.\n",
-       "REQUEST_DISCONNECT",
-       GNUNET_i2s (&tdh->pid));
-  GNUNET_assert (size >= sizeof (struct TransportRequestDisconnectMessage));
-  msg.header.size = htons (sizeof (struct TransportRequestDisconnectMessage));
-  msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_DISCONNECT);
-  msg.reserved = htonl (0);
-  msg.peer = tdh->pid;
-  memcpy (buf, &msg, sizeof (msg));
-  if (NULL != tdh->cb)
-    tdh->cb (tdh->cb_cls, GNUNET_OK);
-  GNUNET_TRANSPORT_try_disconnect_cancel (tdh);
-  return sizeof (struct TransportRequestDisconnectMessage);
-}
-
-
-/**
- * Ask the transport service to shutdown a connection to
- * the given peer.
- *
- * @param handle connection to transport service
- * @param target who we should try to connect to
- * @param cb callback to be called when request was transmitted to transport
- *         service
- * @param cb_cls closure for the callback @a cb
- * @return a `struct GNUNET_TRANSPORT_TryDisconnectHandle` handle or
- *         NULL on failure (cb will not be called)
- */
-struct GNUNET_TRANSPORT_TryDisconnectHandle *
-GNUNET_TRANSPORT_try_disconnect (struct GNUNET_TRANSPORT_Handle *handle,
-                                 const struct GNUNET_PeerIdentity *target,
-                                 GNUNET_TRANSPORT_TryDisconnectCallback cb,
-                                 void *cb_cls)
-{
-  struct GNUNET_TRANSPORT_TryDisconnectHandle *tdh;
-
-  if (NULL == handle->client)
-    return NULL;
-  tdh = GNUNET_new (struct GNUNET_TRANSPORT_TryDisconnectHandle);
-  tdh->th = handle;
-  tdh->pid = *target;
-  tdh->cb = cb;
-  tdh->cb_cls = cb_cls;
-  tdh->tth = schedule_control_transmit (handle,
-                                        sizeof (struct TransportRequestDisconnectMessage),
-                                        &send_try_disconnect, tdh);
-  GNUNET_CONTAINER_DLL_insert (handle->td_head,
-                               handle->td_tail,
-                               tdh);
-  return tdh;
-}
-
-
-/**
- * Cancel the request to transport to try a disconnect
- * Callback will not be called
- *
- * @param tdh the handle to cancel
- */
-void
-GNUNET_TRANSPORT_try_disconnect_cancel (struct GNUNET_TRANSPORT_TryDisconnectHandle *tdh)
-{
-  struct GNUNET_TRANSPORT_Handle *th;
-
-  th = tdh->th;
-  if (NULL != tdh->tth)
-    cancel_control_transmit (th, tdh->tth);
-  GNUNET_CONTAINER_DLL_remove (th->td_head,
-                               th->td_tail,
-                               tdh);
-  GNUNET_free (tdh);
-}
-
-
 /**
  * Send HELLO message to the service.
  *
@@ -1592,19 +1302,14 @@ send_hello (void *cls,
   struct GNUNET_TRANSPORT_OfferHelloHandle *ohh = cls;
   struct GNUNET_MessageHeader *msg = ohh->msg;
   uint16_t ssize;
-  struct GNUNET_SCHEDULER_TaskContext tc;
 
-  tc.read_ready = NULL;
-  tc.write_ready = NULL;
-  tc.reason = GNUNET_SCHEDULER_REASON_TIMEOUT;
   if (NULL == buf)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Timeout while trying to transmit `%s' request.\n",
          "HELLO");
     if (NULL != ohh->cont)
-      ohh->cont (ohh->cls,
-                 &tc);
+      ohh->cont (ohh->cls);
     GNUNET_free (msg);
     GNUNET_CONTAINER_DLL_remove (ohh->th->oh_head,
                                  ohh->th->oh_tail,
@@ -1621,10 +1326,8 @@ send_hello (void *cls,
           msg,
           ssize);
   GNUNET_free (msg);
-  tc.reason = GNUNET_SCHEDULER_REASON_READ_READY;
   if (NULL != ohh->cont)
-    ohh->cont (ohh->cls,
-               &tc);
+    ohh->cont (ohh->cls);
   GNUNET_CONTAINER_DLL_remove (ohh->th->oh_head,
                                ohh->th->oh_tail,
                                ohh);
@@ -1713,16 +1416,16 @@ GNUNET_TRANSPORT_set_traffic_metric (struct GNUNET_TRANSPORT_Handle *handle,
  * @param cont continuation to call when HELLO has been sent,
  *     tc reason #GNUNET_SCHEDULER_REASON_TIMEOUT for fail
  *     tc reasong #GNUNET_SCHEDULER_REASON_READ_READY for success
- * @param cls closure for continuation
+ * @param cont_cls closure for @a cont
  * @return a `struct GNUNET_TRANSPORT_OfferHelloHandle` handle or NULL on failure,
- *      in case of failure cont will not be called
+ *      in case of failure @a cont will not be called
  *
  */
 struct GNUNET_TRANSPORT_OfferHelloHandle *
 GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
                               const struct GNUNET_MessageHeader *hello,
                               GNUNET_SCHEDULER_TaskCallback cont,
-                              void *cls)
+                              void *cont_cls)
 {
   struct GNUNET_TRANSPORT_OfferHelloHandle *ohh;
   struct GNUNET_MessageHeader *msg;
@@ -1751,11 +1454,15 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
   ohh = GNUNET_new (struct GNUNET_TRANSPORT_OfferHelloHandle);
   ohh->th = handle;
   ohh->cont = cont;
-  ohh->cls = cls;
+  ohh->cls = cont_cls;
   ohh->msg = msg;
-  ohh->tth = schedule_control_transmit (handle, size,
-                                        &send_hello, ohh);
-  GNUNET_CONTAINER_DLL_insert (handle->oh_head, handle->oh_tail, ohh);
+  ohh->tth = schedule_control_transmit (handle,
+                                        size,
+                                        &send_hello,
+                                        ohh);
+  GNUNET_CONTAINER_DLL_insert (handle->oh_head,
+                               handle->oh_tail,
+                               ohh);
   return ohh;
 }
 
@@ -1802,11 +1509,9 @@ GNUNET_TRANSPORT_check_peer_connected (struct GNUNET_TRANSPORT_Handle *handle,
  * Task to call the HelloUpdateCallback of the GetHelloHandle
  *
  * @param cls the `struct GNUNET_TRANSPORT_GetHelloHandle`
- * @param tc the scheduler task context
  */
 static void
-call_hello_update_cb_async (void *cls,
-                            const struct GNUNET_SCHEDULER_TaskContext *tc)
+call_hello_update_cb_async (void *cls)
 {
   struct GNUNET_TRANSPORT_GetHelloHandle *ghh = cls;
 
@@ -1863,7 +1568,9 @@ GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *ghh)
 
   if (NULL != ghh->notify_task)
     GNUNET_SCHEDULER_cancel (ghh->notify_task);
-  GNUNET_CONTAINER_DLL_remove (handle->hwl_head, handle->hwl_tail, ghh);
+  GNUNET_CONTAINER_DLL_remove (handle->hwl_head,
+                               handle->hwl_tail,
+                               ghh);
   GNUNET_free (ghh);
 }
 
@@ -1987,8 +1694,6 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle)
   }
   GNUNET_free_non_null (handle->my_hello);
   handle->my_hello = NULL;
-  GNUNET_assert (NULL == handle->tc_head);
-  GNUNET_assert (NULL == handle->tc_tail);
   GNUNET_assert (NULL == handle->hwl_head);
   GNUNET_assert (NULL == handle->hwl_tail);
   GNUNET_CONTAINER_heap_destroy (handle->ready_heap);
@@ -2030,7 +1735,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *handle,
   n = neighbour_find (handle, target);
   if (NULL == n)
   {
-    /* use GNUNET_TRANSPORT_try_connect first, only use this function
+    /* only use this function
      * once a connection has been established */
     GNUNET_assert (0);
     return NULL;
@@ -2056,7 +1761,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *handle,
   n->traffic_overhead = 0;
   if (delay.rel_value_us > timeout.rel_value_us)
     delay.rel_value_us = 0;        /* notify immediately (with failure) */
-  if (delay.rel_value_us > GNUNET_TIME_UNIT_SECONDS.rel_value_us)
+  if (delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us)
     LOG (GNUNET_ERROR_TYPE_WARNING,
          "At bandwidth %u byte/s next transmission to %s in %s\n",
          (unsigned int) n->out_tracker.available_bytes_per_s__,