diff options
-rw-r--r-- | src/transport/plugin_transport_udp.c | 24 | ||||
-rw-r--r-- | src/transport/plugin_transport_udp.h | 6 |
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) | |||
979 | static void | 979 | static void |
980 | dequeue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) | 980 | dequeue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) |
981 | { | 981 | { |
982 | if (plugin->bytes_in_buffer - udpw->msg_size < 0) | ||
983 | GNUNET_break (0); | ||
984 | else | ||
985 | { | ||
986 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
987 | "# UDP, total, bytes in buffers", | ||
988 | udpw->msg_size, GNUNET_NO); | ||
989 | plugin->bytes_in_buffer -= udpw->msg_size; | ||
990 | } | ||
991 | |||
982 | GNUNET_STATISTICS_update (plugin->env->stats, | 992 | GNUNET_STATISTICS_update (plugin->env->stats, |
983 | "# UDP, total, bytes in buffers", | 993 | "# UDP, total, bytes in buffers", |
984 | -udpw->msg_size, GNUNET_NO); | 994 | -udpw->msg_size, GNUNET_NO); |
@@ -1015,7 +1025,6 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, int result) | |||
1015 | 1025 | ||
1016 | call_continuation (&dummy, result); | 1026 | call_continuation (&dummy, result); |
1017 | 1027 | ||
1018 | /* Remove left-over fragments from queue */ | ||
1019 | /* Remove leftover fragments from queue */ | 1028 | /* Remove leftover fragments from queue */ |
1020 | if (s->addrlen == sizeof (struct sockaddr_in6)) | 1029 | if (s->addrlen == sizeof (struct sockaddr_in6)) |
1021 | { | 1030 | { |
@@ -1440,13 +1449,18 @@ udp_plugin_get_session (void *cls, | |||
1440 | return s; | 1449 | return s; |
1441 | } | 1450 | } |
1442 | 1451 | ||
1443 | |||
1444 | static void | 1452 | static void |
1445 | enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) | 1453 | enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) |
1446 | { | 1454 | { |
1447 | GNUNET_STATISTICS_update (plugin->env->stats, | 1455 | if (plugin->bytes_in_buffer + udpw->msg_size > INT64_MAX) |
1448 | "# UDP, total, bytes in buffers", | 1456 | GNUNET_break (0); |
1449 | udpw->msg_size, GNUNET_NO); | 1457 | else |
1458 | { | ||
1459 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
1460 | "# UDP, total, bytes in buffers", | ||
1461 | udpw->msg_size, GNUNET_NO); | ||
1462 | plugin->bytes_in_buffer += udpw->msg_size; | ||
1463 | } | ||
1450 | GNUNET_STATISTICS_update (plugin->env->stats, | 1464 | GNUNET_STATISTICS_update (plugin->env->stats, |
1451 | "# UDP, total, msgs in buffers", | 1465 | "# UDP, total, msgs in buffers", |
1452 | 1, GNUNET_NO); | 1466 | 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 | |||
159 | */ | 159 | */ |
160 | char *bind6_address; | 160 | char *bind6_address; |
161 | 161 | ||
162 | |||
163 | /** | ||
164 | * Bytes currently in buffer | ||
165 | */ | ||
166 | int64_t bytes_in_buffer; | ||
167 | |||
162 | /** | 168 | /** |
163 | * Handle to NAT traversal support. | 169 | * Handle to NAT traversal support. |
164 | */ | 170 | */ |