backup errno
[oweals/gnunet.git] / src / transport / transport_api.c
index 73d1ebac9ed5a7506eb5dfa1c4ebc41724973c84..8d08f82d9d3f516796604a662dcc9b977b3992af 100644 (file)
@@ -80,7 +80,6 @@ struct NeighbourList
    */
   struct GNUNET_TRANSPORT_TransmitHandle *transmit_handle;
 
-
   /**
    * Identity of this neighbour.
    */
@@ -204,7 +203,7 @@ struct GNUNET_TRANSPORT_TransmitHandle
    * Function to call when notify_size bytes are available
    * for transmission.
    */
-  GNUNET_NETWORK_TransmitReadyNotify notify;
+  GNUNET_CONNECTION_TransmitReadyNotify notify;
 
   /**
    * Closure for notify.
@@ -279,7 +278,7 @@ struct GNUNET_TRANSPORT_Handle
   /**
    * Handle to our registration with the client for notification.
    */
-  struct GNUNET_NETWORK_TransmitHandle *network_handle;
+  struct GNUNET_CONNECTION_TransmitHandle *network_handle;
 
   /**
    * Linked list of transmit handles that are waiting for the
@@ -314,7 +313,7 @@ struct GNUNET_TRANSPORT_Handle
   /**
    * My configuration.
    */
-  struct GNUNET_CONFIGURATION_Handle *cfg;
+  const struct GNUNET_CONFIGURATION_Handle *cfg;
 
   /**
    * Linked list of the current neighbours of this peer.
@@ -379,7 +378,7 @@ transport_notify_ready (void *cls, size_t size, void *buf)
   if (buf == NULL)
     {
 #if DEBUG_TRANSPORT
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                  "Could not transmit to transport service, cancelling pending requests\n");
 #endif
       th = h->connect_ready_head;
@@ -391,8 +390,15 @@ transport_notify_ready (void *cls, size_t size, void *buf)
           GNUNET_assert (n->transmit_handle == th);
           n->transmit_handle = NULL;
         }
+      if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
+       {
+         GNUNET_SCHEDULER_cancel (h->sched,
+                                  th->notify_delay_task);
+         th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
+       }
       GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL));
       GNUNET_free (th);
+      if (h->connect_ready_head != NULL) schedule_transmission (h); /* FIXME: is this ok? */
       return 0;
     } 
 #if DEBUG_TRANSPORT
@@ -406,13 +412,11 @@ transport_notify_ready (void *cls, size_t size, void *buf)
   do
     {
       th = h->connect_ready_head;
-      if (th->notify_delay_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK)
+      if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
        {
-         /* remove existing time out task (only applies if
-            this is not the first iteration of the loop) */
          GNUNET_SCHEDULER_cancel (h->sched,
                                   th->notify_delay_task);
-         th->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK;
+         th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
        }
       GNUNET_assert (th->notify_size <= size);
       if (th->next != NULL)
@@ -460,13 +464,13 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h)
   th = h->connect_ready_head;
   if (th == NULL)
     return; /* no request pending */
-  if (th->notify_delay_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK)
+  if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
     {
       /* remove existing time out task, will be integrated
         with transmit_ready notification! */
       GNUNET_SCHEDULER_cancel (h->sched,
                               th->notify_delay_task);
-      th->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK;
+      th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
     }
   h->transmission_scheduled = GNUNET_YES;
   h->network_handle = GNUNET_CLIENT_notify_transmit_ready (h->client,
@@ -530,10 +534,10 @@ remove_from_any_list (struct GNUNET_TRANSPORT_TransmitHandle *th)
   struct GNUNET_TRANSPORT_Handle *h;
 
   h = th->handle;
-  if (th->notify_delay_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK)
+  if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
     {
       GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task);
-      th->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK;
+      th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
     }
   if (th->prev == NULL)
     {
@@ -570,11 +574,11 @@ try_connect (struct GNUNET_TRANSPORT_TransmitHandle *th);
  * TransmitHandle.
  */
 static void
-transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+peer_transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_TRANSPORT_TransmitHandle *th = cls;
 
-  th->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK;
+  th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
   if (th->neighbour != NULL)
     th->neighbour->transmit_handle = NULL;
 #if DEBUG_TRANSPORT
@@ -606,7 +610,7 @@ schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h,
                            size_t size,
                            int at_head,
                            struct GNUNET_TIME_Relative timeout,
-                           GNUNET_NETWORK_TransmitReadyNotify notify,
+                           GNUNET_CONNECTION_TransmitReadyNotify notify,
                            void *notify_cls)
 {
   struct GNUNET_TRANSPORT_TransmitHandle *th;
@@ -621,9 +625,9 @@ schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h,
     = GNUNET_SCHEDULER_add_delayed (h->sched,
                                    GNUNET_NO,
                                    GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                   GNUNET_SCHEDULER_NO_PREREQUISITE_TASK,
+                                   GNUNET_SCHEDULER_NO_TASK,
                                    timeout,
-                                   &transmit_timeout, th);    
+                                   &peer_transmit_timeout, th);    
   if (at_head)
     {
       th->next = h->connect_ready_head;
@@ -786,6 +790,27 @@ hello_wait_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   struct HelloWaitList *pos;
   struct HelloWaitList *prev;
 
+  hwl->task = GNUNET_SCHEDULER_NO_TASK;
+  if (GNUNET_TIME_absolute_get_remaining (hwl->timeout).value > 0)
+    {
+#if DEBUG_TRANSPORT
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 _("First attempt to obtain `%s' from transport service failed, will try again for %llums.\n"),
+                 "HELLO",
+                 GNUNET_TIME_absolute_get_remaining (hwl->timeout).value);
+#endif
+      hwl->task = GNUNET_SCHEDULER_add_delayed (hwl->handle->sched,
+                                                GNUNET_YES,
+                                                GNUNET_SCHEDULER_PRIORITY_KEEP,
+                                                GNUNET_SCHEDULER_NO_TASK,
+                                                GNUNET_TIME_absolute_get_remaining (hwl->timeout),
+                                                &hello_wait_timeout, hwl);
+      return;      
+    }
+  /* signal timeout */
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              _("Timeout trying to obtain `%s' from transport service.\n"),
+              "HELLO");
   prev = NULL;
   pos = hwl->handle->hwl_head;
   while (pos != hwl)
@@ -798,10 +823,6 @@ hello_wait_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     hwl->handle->hwl_head = hwl->next;
   else
     prev->next = hwl->next;
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-              _("Timeout trying to obtain `%s' from transport service.\n"),
-              "HELLO");
-  /* signal timeout */
   if (hwl->rec != NULL)
     hwl->rec (hwl->rec_cls, GNUNET_TIME_UNIT_ZERO, NULL, NULL);
   GNUNET_free (hwl);
@@ -841,7 +862,7 @@ GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
       hwl->task = GNUNET_SCHEDULER_add_delayed (handle->sched,
                                                 GNUNET_YES,
                                                 GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                                GNUNET_SCHEDULER_NO_PREREQUISITE_TASK,
+                                                GNUNET_SCHEDULER_NO_TASK,
                                                 timeout,
                                                 &hello_wait_timeout, hwl);
       return;
@@ -933,7 +954,7 @@ send_start (void *cls, size_t size, void *buf)
   if (buf == NULL)
     {
 #if DEBUG_TRANSPORT
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Timeout while trying to transmit `%s' request.\n",
                   "START");
 #endif
@@ -963,7 +984,7 @@ request_connect (void *cls, size_t size, void *buf)
   struct TryConnectMessage *tcm;
   struct GNUNET_TRANSPORT_Handle *h;
 
-  GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_PREREQUISITE_TASK);
+  GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_TASK);
   h = th->handle;
   if (buf == NULL)
     {
@@ -973,6 +994,11 @@ request_connect (void *cls, size_t size, void *buf)
                  "TRY_CONNECT",
                  GNUNET_i2s(&th->target));
 #endif
+      if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
+       {
+         GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task);
+         th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
+       }
       th->notify (th->notify_cls, 0, NULL);
       GNUNET_free (th);
       return 0;
@@ -992,10 +1018,10 @@ request_connect (void *cls, size_t size, void *buf)
     = GNUNET_SCHEDULER_add_delayed (h->sched,
                                     GNUNET_NO,
                                     GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                    GNUNET_SCHEDULER_NO_PREREQUISITE_TASK,
+                                    GNUNET_SCHEDULER_NO_TASK,
                                    GNUNET_TIME_absolute_get_remaining
                                    (th->timeout),
-                                   &transmit_timeout, th);
+                                   &peer_transmit_timeout, th);
   insert_transmit_handle (&h->connect_wait_head, th);
   return sizeof (struct TryConnectMessage);
 }
@@ -1012,7 +1038,7 @@ request_connect (void *cls, size_t size, void *buf)
 static void
 try_connect (struct GNUNET_TRANSPORT_TransmitHandle *th)
 {
-  GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_PREREQUISITE_TASK);  
+  GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_TASK);  
   schedule_control_transmit (th->handle,
                              sizeof (struct TryConnectMessage),
                              GNUNET_NO,
@@ -1034,13 +1060,7 @@ try_connect_task (void *cls,
 {
   struct GNUNET_TRANSPORT_TransmitHandle *th = cls;  
 
-  th->notify_delay_task
-    = GNUNET_SCHEDULER_add_delayed (th->handle->sched,
-                                   GNUNET_NO,
-                                   GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                   GNUNET_SCHEDULER_NO_PREREQUISITE_TASK,
-                                   GNUNET_TIME_absolute_get_remaining
-                                   (th->timeout), &transmit_timeout, th);
+  th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
   try_connect (th);
 }
 
@@ -1061,6 +1081,11 @@ remove_neighbour (struct GNUNET_TRANSPORT_Handle *h,
   struct NeighbourList *pos;
   struct GNUNET_TRANSPORT_TransmitHandle *th;
 
+#if DEBUG_TRANSPORT
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Removing neighbour `%s' from list of connected peers.\n",
+             GNUNET_i2s (peer));
+#endif
   prev = NULL;
   pos = h->neighbours;
   while ((pos != NULL) &&
@@ -1085,23 +1110,25 @@ remove_neighbour (struct GNUNET_TRANSPORT_Handle *h,
       pos->transmit_handle = NULL;
       th->neighbour = NULL;
       remove_from_any_list (th);
-      if (GNUNET_TIME_absolute_get_remaining (th->timeout).value > CONNECT_RETRY_TIMEOUT.value)
+      if (GNUNET_TIME_absolute_get_remaining (th->timeout).value <= CONNECT_RETRY_TIMEOUT.value)
        {
          /* signal error */
-         GNUNET_SCHEDULER_cancel (h->sched,
-                                  th->notify_delay_task);
-         transmit_timeout (th, NULL);    
+         GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == th->notify_delay_task);
+         peer_transmit_timeout (th, NULL);       
        }
       else
        {
+         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                     _("Connection with `%4s' failed, will keep trying for %llu ms to deliver message\n"),
+                     GNUNET_i2s (peer),
+                     GNUNET_TIME_absolute_get_remaining (th->timeout).value);
          /* try again in a bit */
-         GNUNET_SCHEDULER_cancel (h->sched,
-                                  th->notify_delay_task);
+         GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == th->notify_delay_task);
          th->notify_delay_task 
            = GNUNET_SCHEDULER_add_delayed (h->sched,
                                            GNUNET_NO,
                                            GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                           GNUNET_SCHEDULER_NO_PREREQUISITE_TASK,
+                                           GNUNET_SCHEDULER_NO_TASK,
                                            CONNECT_RETRY_TIMEOUT,
                                            &try_connect_task,
                                            th);
@@ -1123,6 +1150,9 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   struct GNUNET_TRANSPORT_TransmitHandle *pos;
   struct NeighbourList *n;
 
+  fprintf (stderr,
+          "Trying to reconnect to transport!\n");
+
   /* Forget about all neighbours that we used to be connected
      to */
   while (NULL != (n = h->neighbours))
@@ -1131,7 +1161,7 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service.\n");
 #endif
   GNUNET_assert (h->client == NULL);
-  h->reconnect_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK;
+  h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
   h->client = GNUNET_CLIENT_connect (h->sched, "transport", h->cfg);
   GNUNET_assert (h->client != NULL);
   /* make sure we don't send "START" twice,
@@ -1156,7 +1186,8 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   schedule_control_transmit (h,
                              sizeof (struct GNUNET_MessageHeader),
                              GNUNET_YES,
-                             GNUNET_TIME_UNIT_FOREVER_REL, &send_start, NULL);
+                             GNUNET_TIME_UNIT_FOREVER_REL, 
+                            &send_start, NULL);
   GNUNET_CLIENT_receive (h->client,
                          &demultiplexer, h, GNUNET_TIME_UNIT_FOREVER_REL);
 }
@@ -1175,12 +1206,12 @@ schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h)
               h->reconnect_delay.value);
 #endif
   GNUNET_assert (h->client == NULL);
-  GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_PREREQUISITE_TASK);
+  GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK);
   h->reconnect_task
     = GNUNET_SCHEDULER_add_delayed (h->sched,
                                     GNUNET_NO,
                                     GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                                    GNUNET_SCHEDULER_NO_PREREQUISITE_TASK,
+                                    GNUNET_SCHEDULER_NO_TASK,
                                     h->reconnect_delay, &reconnect, h);
   h->reconnect_delay = GNUNET_TIME_UNIT_SECONDS;
 }
@@ -1203,7 +1234,7 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_TRANSPORT_TransmitHandle *th = cls;
 
-  th->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK;
+  th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
   schedule_request (th);
 }
 
@@ -1238,10 +1269,10 @@ schedule_request (struct GNUNET_TRANSPORT_TransmitHandle *th)
 
   h = th->handle;
   n = th->neighbour;
-  if (th->notify_delay_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK)
+  if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
     {
       GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task);
-      th->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK;
+      th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
     }
   /* check outgoing quota */
   duration = GNUNET_TIME_absolute_get_duration (n->last_quota_update);
@@ -1284,7 +1315,7 @@ schedule_request (struct GNUNET_TRANSPORT_TransmitHandle *th)
         = GNUNET_SCHEDULER_add_delayed (h->sched,
                                         GNUNET_NO,
                                         GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                        GNUNET_SCHEDULER_NO_PREREQUISITE_TASK,
+                                        GNUNET_SCHEDULER_NO_TASK,
                                         duration, &transmit_ready, th);
       return;
     }
@@ -1306,9 +1337,9 @@ schedule_request (struct GNUNET_TRANSPORT_TransmitHandle *th)
         = GNUNET_SCHEDULER_add_delayed (h->sched,
                                         GNUNET_NO,
                                         GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                        GNUNET_SCHEDULER_NO_PREREQUISITE_TASK,
+                                        GNUNET_SCHEDULER_NO_TASK,
                                         GNUNET_TIME_absolute_get_remaining
-                                        (th->timeout), &transmit_timeout, th);
+                                        (th->timeout), &peer_transmit_timeout, th);
       return;
     }
   n->transmit_ok = GNUNET_NO;
@@ -1378,10 +1409,10 @@ add_neighbour (struct GNUNET_TRANSPORT_Handle *h,
                          "Found pending request for `%4s' will trigger it now.\n",
                          GNUNET_i2s (&pos->target));
 #endif
-             if (pos->notify_delay_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK)
+             if (pos->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
                {
                  GNUNET_SCHEDULER_cancel (h->sched, pos->notify_delay_task);
-                 pos->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK;
+                 pos->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
                }
               schedule_request (pos);
             }
@@ -1416,7 +1447,7 @@ add_neighbour (struct GNUNET_TRANSPORT_Handle *h,
  */
 struct GNUNET_TRANSPORT_Handle *
 GNUNET_TRANSPORT_connect (struct GNUNET_SCHEDULER_Handle *sched,
-                          struct GNUNET_CONFIGURATION_Handle *cfg,
+                          const struct GNUNET_CONFIGURATION_Handle *cfg,
                           void *cls,
                           GNUNET_TRANSPORT_ReceiveCallback rec,
                           GNUNET_TRANSPORT_NotifyConnect nc,
@@ -1470,21 +1501,23 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle)
   struct GNUNET_CLIENT_Connection *client;
 
 #if DEBUG_TRANSPORT
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transport disconnect called!\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+             "Transport disconnect called!\n");
 #endif
   while (NULL != (th = handle->connect_ready_head))
     {
       handle->connect_ready_head = th->next;
+      GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_TASK);
       th->notify (th->notify_cls, 0, NULL);
       GNUNET_free (th);
     }
   while (NULL != (th = handle->connect_wait_head))
     {
       handle->connect_wait_head = th->next;
-      if (th->notify_delay_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK)
+      if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
         {
           GNUNET_SCHEDULER_cancel (handle->sched, th->notify_delay_task);
-          th->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK;
+          th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
         }
       th->notify (th->notify_cls, 0, NULL);
       GNUNET_free (th);
@@ -1505,10 +1538,10 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle)
         hwl->rec (hwl->rec_cls, GNUNET_TIME_UNIT_ZERO, NULL, NULL);
       GNUNET_free (hwl);
     }
-  if (handle->reconnect_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK)
+  if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK)
     {
       GNUNET_SCHEDULER_cancel (handle->sched, handle->reconnect_task);
-      handle->reconnect_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK;
+      handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
     }
   GNUNET_free_non_null (handle->my_hello);
   handle->my_hello = NULL;
@@ -1559,19 +1592,19 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
 #endif
           if (h->network_handle != NULL)
             {
-              GNUNET_NETWORK_notify_transmit_ready_cancel (h->network_handle);
+              GNUNET_CONNECTION_notify_transmit_ready_cancel (h->network_handle);
               h->network_handle = NULL;
               h->transmission_scheduled = GNUNET_NO;
              th = h->connect_ready_head;
              /* add timeout again, we cancelled the transmit_ready task! */
-             GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_PREREQUISITE_TASK);
+             GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_TASK);
              th->notify_delay_task 
                = GNUNET_SCHEDULER_add_delayed (h->sched,
                                                GNUNET_NO,
                                                GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                               GNUNET_SCHEDULER_NO_PREREQUISITE_TASK,
+                                               GNUNET_SCHEDULER_NO_TASK,
                                                GNUNET_TIME_absolute_get_remaining(th->timeout),
-                                               &transmit_timeout, 
+                                               &peer_transmit_timeout, 
                                                th);    
             }
           GNUNET_CLIENT_disconnect (h->client);
@@ -1665,8 +1698,6 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
                   "Receiving `%s' message, transmission %s.\n", "SEND_OK",
                  ntohl(okm->success) == GNUNET_OK ? "succeeded" : "failed");
 #endif
-      /* FIXME: need to check status code and change action accordingly,
-        especially if the error was for CONNECT */
       n = find_neighbour (h, &okm->peer);
       GNUNET_assert (n != NULL);
       n->transmit_ok = GNUNET_YES;
@@ -1674,12 +1705,13 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
         {
 #if DEBUG_TRANSPORT
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                      "Processing pending message\n");
+                      "Processing pending message for `%4s'\n",
+                     GNUNET_i2s(&n->id));
 #endif
           GNUNET_SCHEDULER_cancel (h->sched,
                                    n->transmit_handle->notify_delay_task);
           n->transmit_handle->notify_delay_task =
-            GNUNET_SCHEDULER_NO_PREREQUISITE_TASK;
+            GNUNET_SCHEDULER_NO_TASK;
           GNUNET_assert (GNUNET_YES == n->received_ack);
           schedule_request (n->transmit_handle);
         }
@@ -1755,7 +1787,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
 
 struct ClientTransmitWrapper
 {
-  GNUNET_NETWORK_TransmitReadyNotify notify;
+  GNUNET_CONNECTION_TransmitReadyNotify notify;
   void *notify_cls;
   struct GNUNET_TRANSPORT_TransmitHandle *th;
 };
@@ -1843,7 +1875,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle
                                         *target, size_t size,
                                        unsigned int priority,
                                         struct GNUNET_TIME_Relative timeout,
-                                        GNUNET_NETWORK_TransmitReadyNotify
+                                        GNUNET_CONNECTION_TransmitReadyNotify
                                         notify, void *notify_cls)
 {
   struct GNUNET_TRANSPORT_TransmitHandle *pos;
@@ -1914,8 +1946,8 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle
        = GNUNET_SCHEDULER_add_delayed (handle->sched,
                                        GNUNET_NO,
                                        GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                       GNUNET_SCHEDULER_NO_PREREQUISITE_TASK,
-                                       timeout, &transmit_timeout, th);
+                                       GNUNET_SCHEDULER_NO_TASK,
+                                       timeout, &peer_transmit_timeout, th);
       return th;
     }
   
@@ -1930,8 +1962,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle
 
 
 /**
- * Cancel the specified transmission-ready
- * notification.
+ * Cancel the specified transmission-ready notification.
  */
 void
 GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct
@@ -1951,11 +1982,12 @@ GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct
   h = th->handle;
   if ((h->connect_ready_head == NULL) && (h->network_handle != NULL))
     {
-      GNUNET_NETWORK_notify_transmit_ready_cancel (h->network_handle);
+      GNUNET_CONNECTION_notify_transmit_ready_cancel (h->network_handle);
       h->network_handle = NULL;
       h->transmission_scheduled = GNUNET_NO;
     }
   GNUNET_free (th->notify_cls);
+  GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_TASK);
   GNUNET_free (th);
 }