- measure overhead
[oweals/gnunet.git] / src / transport / plugin_transport_udp.c
index 3f97380550af9d1991f782b36642dec9af081b9b..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 */
@@ -780,9 +785,6 @@ call_continuation (struct UDP_MessageWrapper *udpw, int result)
           GNUNET_STATISTICS_update (plugin->env->stats,
                                     "# UDP, fragmented msgs, fragments bytes, sent, success",
                                     udpw->msg_size, GNUNET_NO);
-          GNUNET_STATISTICS_update (plugin->env->stats,
-                                    "# UDP, fragmented msgs, messages, pending",
-                                    -1, GNUNET_NO);
           break;
         case MSG_ACK:
           /* No continuation */
@@ -824,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",
@@ -836,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",
@@ -846,6 +856,14 @@ call_continuation (struct UDP_MessageWrapper *udpw, int result)
                                     "# 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 */
@@ -1992,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);