summaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-11-15 09:38:33 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-11-15 09:38:33 +0000
commit27f7c2cbede339827597bfcadb469af6745c2e07 (patch)
treeb94229ba2db6c35f0191fc4f5f0f63ecd780c5a4 /src/transport
parentc4f86db382be46c1740a69ce9f0493b4ed1c271d (diff)
- bug hunting
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/plugin_transport_udp.c24
-rw-r--r--src/transport/plugin_transport_udp.h6
2 files changed, 25 insertions, 5 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index dd5d6388f..4333432cc 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -979,6 +979,16 @@ free_session (struct Session *s)
static void
dequeue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw)
{
+ if (plugin->bytes_in_buffer - udpw->msg_size < 0)
+ GNUNET_break (0);
+ else
+ {
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ "# UDP, total, bytes in buffers",
+ udpw->msg_size, GNUNET_NO);
+ plugin->bytes_in_buffer -= udpw->msg_size;
+ }
+
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, total, bytes in buffers",
-udpw->msg_size, GNUNET_NO);
@@ -1015,7 +1025,6 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, int result)
call_continuation (&dummy, result);
- /* Remove left-over fragments from queue */
/* Remove leftover fragments from queue */
if (s->addrlen == sizeof (struct sockaddr_in6))
{
@@ -1440,13 +1449,18 @@ udp_plugin_get_session (void *cls,
return s;
}
-
static void
enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw)
{
- GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, total, bytes in buffers",
- udpw->msg_size, GNUNET_NO);
+ if (plugin->bytes_in_buffer + udpw->msg_size > INT64_MAX)
+ GNUNET_break (0);
+ else
+ {
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ "# UDP, total, bytes in buffers",
+ udpw->msg_size, GNUNET_NO);
+ plugin->bytes_in_buffer += udpw->msg_size;
+ }
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, total, msgs in buffers",
1, GNUNET_NO);
diff --git a/src/transport/plugin_transport_udp.h b/src/transport/plugin_transport_udp.h
index 3bdf4a561..bab8e6cf0 100644
--- a/src/transport/plugin_transport_udp.h
+++ b/src/transport/plugin_transport_udp.h
@@ -159,6 +159,12 @@ struct Plugin
*/
char *bind6_address;
+
+ /**
+ * Bytes currently in buffer
+ */
+ int64_t bytes_in_buffer;
+
/**
* Handle to NAT traversal support.
*/