- measure overhead
[oweals/gnunet.git] / src / transport / plugin_transport_udp.c
index c456bd461b5bb1969f324ce141bdd6e03dcaa39e..b6b13eab2ec33bd110c658dd9d4fb2be94b7165f 100644 (file)
@@ -712,6 +712,7 @@ static void
 call_continuation (struct UDP_MessageWrapper *udpw, int result)
 {
   size_t overhead;
+  struct UDP_MessageWrapper dummy;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
       "Calling continuation for %u byte message to `%s' with result %s\n",
@@ -750,6 +751,7 @@ call_continuation (struct UDP_MessageWrapper *udpw, int result)
                                     udpw->payload_size, GNUNET_NO);
           break;
         case MSG_FRAGMENTED_COMPLETE:
+          GNUNET_assert (NULL != udpw->frag_ctx);
           if (udpw->frag_ctx->cont != NULL)
             udpw->frag_ctx->cont (udpw->frag_ctx->cont_cls, &udpw->session->target, GNUNET_OK,
                                udpw->frag_ctx->payload_size, udpw->frag_ctx->on_wire_size);
@@ -768,6 +770,9 @@ call_continuation (struct UDP_MessageWrapper *udpw, int result)
           GNUNET_STATISTICS_update (plugin->env->stats,
                                     "# UDP, total, bytes payload, sent",
                                     udpw->payload_size, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, fragmented msgs, messages, pending",
+                                    -1, GNUNET_NO);
           break;
         case MSG_FRAGMENTED:
           /* Fragmented message: enqueue next fragment */
@@ -821,8 +826,9 @@ call_continuation (struct UDP_MessageWrapper *udpw, int result)
                                     overhead, GNUNET_NO);
           break;
         case MSG_FRAGMENTED_COMPLETE:
+          GNUNET_assert (NULL != udpw->frag_ctx);
           if (udpw->frag_ctx->cont != NULL)
-            udpw->frag_ctx->cont (udpw->frag_ctx->cont_cls, &udpw->session->target, GNUNET_OK,
+            udpw->frag_ctx->cont (udpw->frag_ctx->cont_cls, &udpw->session->target, GNUNET_SYSERR,
                                udpw->frag_ctx->payload_size, udpw->frag_ctx->on_wire_size);
           GNUNET_STATISTICS_update (plugin->env->stats,
                                     "# UDP, fragmented msgs, messages, sent, failure",
@@ -833,8 +839,15 @@ call_continuation (struct UDP_MessageWrapper *udpw, int result)
           GNUNET_STATISTICS_update (plugin->env->stats,
                                     "# UDP, fragmented msgs, bytes payload, sent, failure",
                                     overhead, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, fragmented msgs, bytes payload, sent, failure",
+                                    overhead, GNUNET_NO);
+          GNUNET_STATISTICS_update (plugin->env->stats,
+                                    "# UDP, fragmented msgs, messages, pending",
+                                    -1, GNUNET_NO);
           break;
         case MSG_FRAGMENTED:
+          GNUNET_assert (NULL != udpw->frag_ctx);
           /* Fragmented message: failed to send */
           GNUNET_STATISTICS_update (plugin->env->stats,
                                     "# UDP, fragmented msgs, fragments, sent, failure",
@@ -842,6 +855,15 @@ call_continuation (struct UDP_MessageWrapper *udpw, int result)
           GNUNET_STATISTICS_update (plugin->env->stats,
                                     "# UDP, fragmented msgs, fragments bytes, sent, failure",
                                     udpw->msg_size, GNUNET_NO);
+
+          dummy.msg_type = MSG_FRAGMENTED_COMPLETE;
+          dummy.msg_buf = NULL;
+          dummy.msg_size = udpw->frag_ctx->on_wire_size;
+          dummy.payload_size = udpw->frag_ctx->payload_size;
+          dummy.frag_ctx = udpw->frag_ctx;
+          dummy.session = udpw->session;
+          call_continuation (&dummy, GNUNET_SYSERR);
+
           break;
         case MSG_ACK:
           /* ACK message: failed to send */
@@ -1988,10 +2010,6 @@ read_process_ack (struct Plugin *plugin,
   dummy.frag_ctx = s->frag_ctx;
   dummy.session = s;
 
-  GNUNET_STATISTICS_update (plugin->env->stats,
-                            "# UDP, fragmented msgs, messages, pending",
-                            -1, GNUNET_NO);
-
   call_continuation (&dummy, GNUNET_OK);
 
   GNUNET_free (s->frag_ctx);
@@ -2159,22 +2177,31 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head,
     {
       /* Message timed out */
       call_continuation (udpw, GNUNET_SYSERR);
-      if (NULL == udpw->frag_ctx)
-      {
-        /* Not fragmented message */
-        LOG (GNUNET_ERROR_TYPE_DEBUG,
-             "Message for peer `%s' with size %u timed out\n",
-             GNUNET_i2s(&udpw->session->target), udpw->payload_size);
-      }
-      else
-      {
+      switch (udpw->msg_type) {
+        case MSG_UNFRAGMENTED:
+          /* Not fragmented message */
+          LOG (GNUNET_ERROR_TYPE_DEBUG,
+               "Message for peer `%s' with size %u timed out\n",
+               GNUNET_i2s(&udpw->session->target), udpw->payload_size);
+          break;
+        case MSG_FRAGMENTED:
           /* Fragmented message */
+          call_continuation (udpw, GNUNET_SYSERR);
           LOG (GNUNET_ERROR_TYPE_DEBUG,
                "Fragment for message for peer `%s' with size %u timed out\n",
                GNUNET_i2s(&udpw->session->target), udpw->frag_ctx->payload_size);
           udpw->session->last_expected_delay = GNUNET_FRAGMENT_context_destroy (udpw->frag_ctx->frag);
           GNUNET_free (udpw->frag_ctx);
           udpw->session->frag_ctx = NULL;
+
+          break;
+        case MSG_ACK:
+          LOG (GNUNET_ERROR_TYPE_DEBUG,
+               "ACK Message for peer `%s' with size %u timed out\n",
+               GNUNET_i2s(&udpw->session->target), udpw->payload_size);
+          break;
+        default:
+          break;
       }
 
       GNUNET_STATISTICS_update (plugin->env->stats,