"Calling continuation for %u byte message to `%s' with result %s\n",
udpw->payload_size, GNUNET_i2s (&udpw->session->target),
(GNUNET_OK == result) ? "OK" : "SYSERR");
- if (NULL == udpw->cont)
- return;
if (NULL == udpw->frag_ctx)
{
/* Not fragmented message */
if (GNUNET_OK == result)
{
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ "# unfragmented messages transmit with success via UDP",
+ 1, GNUNET_NO);
if (udpw->msg_size >= udpw->payload_size)
{
GNUNET_STATISTICS_update (plugin->env->stats,
"# bytes payload transmitted via UDP",
udpw->payload_size, GNUNET_NO);
}
- udpw->cont (udpw->cont_cls, &udpw->session->target, result,
+ else
+ {
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ "# unfragmented messages transmit with failure via UDP",
+ 1, GNUNET_NO);
+ }
+ if (NULL != udpw->cont)
+ udpw->cont (udpw->cont_cls, &udpw->session->target, result,
udpw->payload_size, udpw->msg_size);
}
else
if (GNUNET_OK == result)
{
/* Fragmented message: only call next_fragment continuation on success */
- udpw->cont (udpw->cont_cls, &udpw->session->target, result,
+ if (NULL != udpw->cont)
+ udpw->cont (udpw->cont_cls, &udpw->session->target, result,
udpw->payload_size, udpw->msg_size);
}
}
}
+static void
+dequeue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw)
+{
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ "# bytes currently in UDP buffers",
+ -udpw->msg_size, GNUNET_NO);
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ "# msgs currently in UDP buffers",
+ -1, GNUNET_NO);
+ if (udpw->session->addrlen == sizeof (struct sockaddr_in))
+ GNUNET_CONTAINER_DLL_remove (plugin->ipv4_queue_head,
+ plugin->ipv4_queue_tail, udpw);
+ if (udpw->session->addrlen == sizeof (struct sockaddr_in6))
+ GNUNET_CONTAINER_DLL_remove (plugin->ipv6_queue_head,
+ plugin->ipv6_queue_tail, udpw);
+}
+
/**
* Functions with this signature are called whenever we need
* to close a session due to a disconnect or failure to
next = udpw->next;
if (udpw->session == s)
{
- GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw);
+ dequeue (plugin, udpw);
call_continuation(udpw, GNUNET_SYSERR);
GNUNET_free (udpw);
}
next = udpw->next;
if (udpw->session == s)
{
- GNUNET_CONTAINER_DLL_remove(plugin->ipv6_queue_head, plugin->ipv6_queue_tail, udpw);
+ dequeue (plugin, udpw);
call_continuation(udpw, GNUNET_SYSERR);
GNUNET_free (udpw);
}
static void
enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw)
{
-
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ "# bytes currently in UDP buffers",
+ udpw->msg_size, GNUNET_NO);
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ "# msgs currently in UDP buffers",
+ 1, GNUNET_NO);
if (udpw->session->addrlen == sizeof (struct sockaddr_in))
GNUNET_CONTAINER_DLL_insert (plugin->ipv4_queue_head,
plugin->ipv4_queue_tail, udpw);
}
+
/**
* Fragment message was transmitted via UDP, let fragmentation know
* to send the next fragment now.
GNUNET_i2s (&s->target),
GNUNET_a2s(s->sock_addr, s->addrlen));
- GNUNET_STATISTICS_update (plugin->env->stats,
- "# bytes currently in UDP buffers",
- msgbuf_size, GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
"# bytes payload asked to transmit via UDP",
msgbuf_size, GNUNET_NO);
-
/* Message */
udp = (struct UDPMessage *) mbuf;
udp->header.size = htons (udpmlen);
if (udpmlen <= UDP_MTU)
{
/* unfragmented message */
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ "# unfragmented messages asked to transmit via UDP",
+ 1, GNUNET_NO);
udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + udpmlen);
udpw->session = s;
udpw->msg_buf = (char *) &udpw[1];
else
{
/* fragmented message */
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ "# fragmented messages asked to transmit via UDP",
+ 1, GNUNET_NO);
if (s->frag_ctx != NULL)
return GNUNET_SYSERR;
memcpy (&udp[1], msgbuf, msgbuf_size);
udp_ack->sender = *rc->plugin->env->my_identity;
memcpy (&udp_ack[1], msg, ntohs (msg->size));
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ "# messages ACKs transmitted via UDP",
+ 1, GNUNET_NO);
+
enqueue (rc->plugin, udpw);
}
tmp = udpw->next;
if ((udpw->frag_ctx != NULL) && (udpw->frag_ctx == s->frag_ctx))
{
- GNUNET_CONTAINER_DLL_remove(plugin->ipv6_queue_head, plugin->ipv6_queue_tail, udpw);
+ dequeue (plugin, udpw);
GNUNET_free (udpw);
}
udpw = tmp;
tmp = udpw->next;
if ((udpw->frag_ctx != NULL) && (udpw->frag_ctx == s->frag_ctx))
{
- GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw);
+ dequeue (plugin, udpw);
GNUNET_free (udpw);
}
udpw = tmp;
udpw->session->frag_ctx = NULL;
}
- GNUNET_STATISTICS_update (plugin->env->stats,
- "# bytes currently in UDP buffers",
- -udpw->msg_size, GNUNET_NO);
-
GNUNET_STATISTICS_update (plugin->env->stats,
"# messages dismissed due to timeout",
1, GNUNET_NO);
/* Remove message */
if (sock == plugin->sockv4)
{
- GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw);
+ dequeue (plugin, udpw);
GNUNET_free (udpw);
udpw = plugin->ipv4_queue_head;
}
if (sock == plugin->sockv6)
{
- GNUNET_CONTAINER_DLL_remove(plugin->ipv6_queue_head, plugin->ipv6_queue_tail, udpw);
+ dequeue (plugin, udpw);
GNUNET_free (udpw);
udpw = plugin->ipv6_queue_head;
}
udpw->frag_ctx->on_wire_size += udpw->msg_size;
call_continuation (udpw, GNUNET_OK);
}
-
- GNUNET_STATISTICS_update (plugin->env->stats,
- "# bytes currently in UDP buffers",
- -udpw->msg_size, GNUNET_NO);
-
- if (sock == plugin->sockv4)
- GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw);
- else if (sock == plugin->sockv6)
- GNUNET_CONTAINER_DLL_remove(plugin->ipv6_queue_head, plugin->ipv6_queue_tail, udpw);
+ dequeue (plugin, udpw);
GNUNET_free (udpw);
udpw = NULL;
while (udpw != NULL)
{
struct UDP_MessageWrapper *tmp = udpw->next;
- GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw);
+ dequeue (plugin, udpw);
call_continuation(udpw, GNUNET_SYSERR);
GNUNET_free (udpw);
+
udpw = tmp;
}
udpw = plugin->ipv6_queue_head;
while (udpw != NULL)
{
struct UDP_MessageWrapper *tmp = udpw->next;
- GNUNET_CONTAINER_DLL_remove(plugin->ipv6_queue_head, plugin->ipv6_queue_tail, udpw);
+ dequeue (plugin, udpw);
call_continuation(udpw, GNUNET_SYSERR);
GNUNET_free (udpw);
+
udpw = tmp;
}