-fix udp transmission, avoid scheduling when unready
authorChristian Grothoff <christian@grothoff.org>
Mon, 26 Oct 2015 18:07:37 +0000 (18:07 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 26 Oct 2015 18:07:37 +0000 (18:07 +0000)
src/transport/plugin_transport_udp.c
src/transport/test_transport_api_reliability.c
src/transport/transport_api.c

index d1ea23645647bdf7514a3813c543e7ec5228d73a..5faed3ad01c5914d6b5c3380898513abad73972a 100644 (file)
@@ -1825,6 +1825,10 @@ qc_fragment_sent (void *cls,
   GNUNET_assert (NULL != udpw->frag_ctx);
   if (GNUNET_OK == result)
   {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Fragment of message with %u bytes transmitted to %s\n",
+                (unsigned int) udpw->payload_size,
+                GNUNET_i2s (&udpw->session->target));
     GNUNET_FRAGMENT_context_transmission_done (udpw->frag_ctx->frag);
     GNUNET_STATISTICS_update (plugin->env->stats,
                               "# UDP, fragmented msgs, fragments, sent, success",
@@ -1837,6 +1841,10 @@ qc_fragment_sent (void *cls,
   }
   else
   {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Failed to transmit fragment of message with %u bytes to %s\n",
+                (unsigned int) udpw->payload_size,
+                GNUNET_i2s (&udpw->session->target));
     fragmented_message_done (udpw->frag_ctx,
                              GNUNET_SYSERR);
     GNUNET_STATISTICS_update (plugin->env->stats,
@@ -1892,6 +1900,10 @@ enqueue_fragment (void *cls,
           msg_len);
   enqueue (plugin,
            udpw);
+  if (session->address->address_length == sizeof (struct IPv4UdpAddress))
+    schedule_select_v4 (plugin);
+  else
+    schedule_select_v6 (plugin);
 }
 
 
@@ -2102,6 +2114,10 @@ udp_plugin_send (void *cls,
                               "# UDP, unfragmented bytes payload queued total",
                               msgbuf_size,
                               GNUNET_NO);
+    if (s->address->address_length == sizeof (struct IPv4UdpAddress))
+      schedule_select_v4 (plugin);
+    else
+      schedule_select_v6 (plugin);
   }
   else
   {
@@ -2167,10 +2183,6 @@ udp_plugin_send (void *cls,
   notify_session_monitor (s->plugin,
                           s,
                           GNUNET_TRANSPORT_SS_UPDATE);
-  if (s->address->address_length == sizeof (struct IPv4UdpAddress))
-    schedule_select_v4 (plugin);
-  else
-    schedule_select_v6 (plugin);
   return udpmlen;
 }
 
index c95729ab985869821a432e73c3904d0f5cc5a6df..0b80477bfbb330db921f3b8c6b4b88685cc88560 100644 (file)
@@ -393,8 +393,10 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
 #if VERBOSE
   if (ntohl (hdr->num) % 5 == 0)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n",
-                ntohl (hdr->num), ntohs (message->size));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Got message %u of size %u\n",
+                ntohl (hdr->num),
+                ntohs (message->size));
   }
 #endif
   n++;
@@ -505,7 +507,8 @@ notify_ready (void *cls, size_t size, void *buf)
 static void
 notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Peer `%4s' connected to us (%p)!\n",
               GNUNET_i2s (peer), cls);
 }
 
@@ -513,7 +516,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
 static void
 notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Peer `%4s' disconnected (%p)!\n",
               GNUNET_i2s (peer), cls);
   if (th != NULL)
     GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
@@ -522,7 +526,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
 
 
 static void
-sendtask ()
+sendtask (void *cls,
+          const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   start_time = GNUNET_TIME_absolute_get ();
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -533,13 +538,17 @@ sendtask ()
                                                NULL);
 }
 
+
 static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (struct PeerContext *p1,
+                    struct PeerContext *p2,
+                    void *cls)
 {
   char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Peers connected: %s <-> %s\n", p1_c,
+              "Peers connected: %s <-> %s\n",
+              p1_c,
               GNUNET_i2s (&p2->id));
   GNUNET_free (p1_c);
 
index 55caf407a5d88a453a1f993d69f8d8b8b5379d70..f69cd80cc722829aa76cd67c99c966bd8af406c7 100644 (file)
@@ -780,7 +780,7 @@ demultiplexer (void *cls,
     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;
@@ -799,9 +799,11 @@ 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 <
@@ -822,8 +824,10 @@ demultiplexer (void *cls,
       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)
     {
@@ -1102,6 +1106,8 @@ schedule_transmission_task (void *cls,
   }
   else
   {
+    if (GNUNET_YES != n->is_ready)
+      return;                   /* service not ready for another one */
     n = GNUNET_CONTAINER_heap_peek (h->ready_heap);
     if (NULL == n)
       return;                   /* no pending messages */
@@ -1148,7 +1154,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,
@@ -1364,8 +1374,7 @@ send_try_connect (void *cls,
   if (NULL == buf)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Discarding  `%s' request to `%s' due to error in transport service connection.\n",
-         "REQUEST_CONNECT",
+         "Discarding REQUEST_CONNECT request to `%s' due to error in transport service connection.\n",
          GNUNET_i2s (&tch->pid));
     if (NULL != tch->cb)
       tch->cb (tch->cb_cls,