diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-10-17 15:52:27 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-10-17 15:52:27 +0000 |
commit | 3560166cefe33e76f098ae6f14d5efc1c99008b5 (patch) | |
tree | 75df2d2123e95ef2a327308e862a0d2771a44150 /src/transport | |
parent | 4b452a365b674cc69bf62be7d15950ccbdd7329c (diff) | |
download | gnunet-3560166cefe33e76f098ae6f14d5efc1c99008b5.tar.gz gnunet-3560166cefe33e76f098ae6f14d5efc1c99008b5.zip |
new statistic values and fixes
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 90 |
1 files changed, 60 insertions, 30 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index e73712a83..1dcdeee98 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -696,14 +696,15 @@ call_continuation (struct UDP_MessageWrapper *udpw, int result) | |||
696 | "Calling continuation for %u byte message to `%s' with result %s\n", | 696 | "Calling continuation for %u byte message to `%s' with result %s\n", |
697 | udpw->payload_size, GNUNET_i2s (&udpw->session->target), | 697 | udpw->payload_size, GNUNET_i2s (&udpw->session->target), |
698 | (GNUNET_OK == result) ? "OK" : "SYSERR"); | 698 | (GNUNET_OK == result) ? "OK" : "SYSERR"); |
699 | if (NULL == udpw->cont) | ||
700 | return; | ||
701 | 699 | ||
702 | if (NULL == udpw->frag_ctx) | 700 | if (NULL == udpw->frag_ctx) |
703 | { | 701 | { |
704 | /* Not fragmented message */ | 702 | /* Not fragmented message */ |
705 | if (GNUNET_OK == result) | 703 | if (GNUNET_OK == result) |
706 | { | 704 | { |
705 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
706 | "# unfragmented messages transmit with success via UDP", | ||
707 | 1, GNUNET_NO); | ||
707 | if (udpw->msg_size >= udpw->payload_size) | 708 | if (udpw->msg_size >= udpw->payload_size) |
708 | { | 709 | { |
709 | GNUNET_STATISTICS_update (plugin->env->stats, | 710 | GNUNET_STATISTICS_update (plugin->env->stats, |
@@ -714,7 +715,14 @@ call_continuation (struct UDP_MessageWrapper *udpw, int result) | |||
714 | "# bytes payload transmitted via UDP", | 715 | "# bytes payload transmitted via UDP", |
715 | udpw->payload_size, GNUNET_NO); | 716 | udpw->payload_size, GNUNET_NO); |
716 | } | 717 | } |
717 | udpw->cont (udpw->cont_cls, &udpw->session->target, result, | 718 | else |
719 | { | ||
720 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
721 | "# unfragmented messages transmit with failure via UDP", | ||
722 | 1, GNUNET_NO); | ||
723 | } | ||
724 | if (NULL != udpw->cont) | ||
725 | udpw->cont (udpw->cont_cls, &udpw->session->target, result, | ||
718 | udpw->payload_size, udpw->msg_size); | 726 | udpw->payload_size, udpw->msg_size); |
719 | } | 727 | } |
720 | else | 728 | else |
@@ -723,7 +731,8 @@ call_continuation (struct UDP_MessageWrapper *udpw, int result) | |||
723 | if (GNUNET_OK == result) | 731 | if (GNUNET_OK == result) |
724 | { | 732 | { |
725 | /* Fragmented message: only call next_fragment continuation on success */ | 733 | /* Fragmented message: only call next_fragment continuation on success */ |
726 | udpw->cont (udpw->cont_cls, &udpw->session->target, result, | 734 | if (NULL != udpw->cont) |
735 | udpw->cont (udpw->cont_cls, &udpw->session->target, result, | ||
727 | udpw->payload_size, udpw->msg_size); | 736 | udpw->payload_size, udpw->msg_size); |
728 | } | 737 | } |
729 | } | 738 | } |
@@ -824,6 +833,23 @@ free_session (struct Session *s) | |||
824 | } | 833 | } |
825 | 834 | ||
826 | 835 | ||
836 | static void | ||
837 | dequeue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) | ||
838 | { | ||
839 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
840 | "# bytes currently in UDP buffers", | ||
841 | -udpw->msg_size, GNUNET_NO); | ||
842 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
843 | "# msgs currently in UDP buffers", | ||
844 | -1, GNUNET_NO); | ||
845 | if (udpw->session->addrlen == sizeof (struct sockaddr_in)) | ||
846 | GNUNET_CONTAINER_DLL_remove (plugin->ipv4_queue_head, | ||
847 | plugin->ipv4_queue_tail, udpw); | ||
848 | if (udpw->session->addrlen == sizeof (struct sockaddr_in6)) | ||
849 | GNUNET_CONTAINER_DLL_remove (plugin->ipv6_queue_head, | ||
850 | plugin->ipv6_queue_tail, udpw); | ||
851 | } | ||
852 | |||
827 | /** | 853 | /** |
828 | * Functions with this signature are called whenever we need | 854 | * Functions with this signature are called whenever we need |
829 | * to close a session due to a disconnect or failure to | 855 | * to close a session due to a disconnect or failure to |
@@ -850,7 +876,7 @@ disconnect_session (struct Session *s) | |||
850 | next = udpw->next; | 876 | next = udpw->next; |
851 | if (udpw->session == s) | 877 | if (udpw->session == s) |
852 | { | 878 | { |
853 | GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw); | 879 | dequeue (plugin, udpw); |
854 | call_continuation(udpw, GNUNET_SYSERR); | 880 | call_continuation(udpw, GNUNET_SYSERR); |
855 | GNUNET_free (udpw); | 881 | GNUNET_free (udpw); |
856 | } | 882 | } |
@@ -861,7 +887,7 @@ disconnect_session (struct Session *s) | |||
861 | next = udpw->next; | 887 | next = udpw->next; |
862 | if (udpw->session == s) | 888 | if (udpw->session == s) |
863 | { | 889 | { |
864 | GNUNET_CONTAINER_DLL_remove(plugin->ipv6_queue_head, plugin->ipv6_queue_tail, udpw); | 890 | dequeue (plugin, udpw); |
865 | call_continuation(udpw, GNUNET_SYSERR); | 891 | call_continuation(udpw, GNUNET_SYSERR); |
866 | GNUNET_free (udpw); | 892 | GNUNET_free (udpw); |
867 | } | 893 | } |
@@ -1204,7 +1230,12 @@ udp_plugin_get_session (void *cls, | |||
1204 | static void | 1230 | static void |
1205 | enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) | 1231 | enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) |
1206 | { | 1232 | { |
1207 | 1233 | GNUNET_STATISTICS_update (plugin->env->stats, | |
1234 | "# bytes currently in UDP buffers", | ||
1235 | udpw->msg_size, GNUNET_NO); | ||
1236 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
1237 | "# msgs currently in UDP buffers", | ||
1238 | 1, GNUNET_NO); | ||
1208 | if (udpw->session->addrlen == sizeof (struct sockaddr_in)) | 1239 | if (udpw->session->addrlen == sizeof (struct sockaddr_in)) |
1209 | GNUNET_CONTAINER_DLL_insert (plugin->ipv4_queue_head, | 1240 | GNUNET_CONTAINER_DLL_insert (plugin->ipv4_queue_head, |
1210 | plugin->ipv4_queue_tail, udpw); | 1241 | plugin->ipv4_queue_tail, udpw); |
@@ -1214,6 +1245,7 @@ enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) | |||
1214 | } | 1245 | } |
1215 | 1246 | ||
1216 | 1247 | ||
1248 | |||
1217 | /** | 1249 | /** |
1218 | * Fragment message was transmitted via UDP, let fragmentation know | 1250 | * Fragment message was transmitted via UDP, let fragmentation know |
1219 | * to send the next fragment now. | 1251 | * to send the next fragment now. |
@@ -1333,13 +1365,9 @@ udp_plugin_send (void *cls, | |||
1333 | GNUNET_a2s(s->sock_addr, s->addrlen)); | 1365 | GNUNET_a2s(s->sock_addr, s->addrlen)); |
1334 | 1366 | ||
1335 | GNUNET_STATISTICS_update (plugin->env->stats, | 1367 | GNUNET_STATISTICS_update (plugin->env->stats, |
1336 | "# bytes currently in UDP buffers", | ||
1337 | msgbuf_size, GNUNET_NO); | ||
1338 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
1339 | "# bytes payload asked to transmit via UDP", | 1368 | "# bytes payload asked to transmit via UDP", |
1340 | msgbuf_size, GNUNET_NO); | 1369 | msgbuf_size, GNUNET_NO); |
1341 | 1370 | ||
1342 | |||
1343 | /* Message */ | 1371 | /* Message */ |
1344 | udp = (struct UDPMessage *) mbuf; | 1372 | udp = (struct UDPMessage *) mbuf; |
1345 | udp->header.size = htons (udpmlen); | 1373 | udp->header.size = htons (udpmlen); |
@@ -1351,6 +1379,9 @@ udp_plugin_send (void *cls, | |||
1351 | if (udpmlen <= UDP_MTU) | 1379 | if (udpmlen <= UDP_MTU) |
1352 | { | 1380 | { |
1353 | /* unfragmented message */ | 1381 | /* unfragmented message */ |
1382 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
1383 | "# unfragmented messages asked to transmit via UDP", | ||
1384 | 1, GNUNET_NO); | ||
1354 | udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + udpmlen); | 1385 | udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + udpmlen); |
1355 | udpw->session = s; | 1386 | udpw->session = s; |
1356 | udpw->msg_buf = (char *) &udpw[1]; | 1387 | udpw->msg_buf = (char *) &udpw[1]; |
@@ -1366,7 +1397,12 @@ udp_plugin_send (void *cls, | |||
1366 | } | 1397 | } |
1367 | else | 1398 | else |
1368 | { | 1399 | { |
1400 | // FIXME | ||
1401 | return GNUNET_SYSERR; | ||
1369 | /* fragmented message */ | 1402 | /* fragmented message */ |
1403 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
1404 | "# fragmented messages asked to transmit via UDP", | ||
1405 | 1, GNUNET_NO); | ||
1370 | if (s->frag_ctx != NULL) | 1406 | if (s->frag_ctx != NULL) |
1371 | return GNUNET_SYSERR; | 1407 | return GNUNET_SYSERR; |
1372 | memcpy (&udp[1], msgbuf, msgbuf_size); | 1408 | memcpy (&udp[1], msgbuf, msgbuf_size); |
@@ -1685,6 +1721,10 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) | |||
1685 | udp_ack->sender = *rc->plugin->env->my_identity; | 1721 | udp_ack->sender = *rc->plugin->env->my_identity; |
1686 | memcpy (&udp_ack[1], msg, ntohs (msg->size)); | 1722 | memcpy (&udp_ack[1], msg, ntohs (msg->size)); |
1687 | 1723 | ||
1724 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
1725 | "# messages ACKs transmitted via UDP", | ||
1726 | 1, GNUNET_NO); | ||
1727 | |||
1688 | enqueue (rc->plugin, udpw); | 1728 | enqueue (rc->plugin, udpw); |
1689 | } | 1729 | } |
1690 | 1730 | ||
@@ -1775,7 +1815,7 @@ read_process_ack (struct Plugin *plugin, | |||
1775 | tmp = udpw->next; | 1815 | tmp = udpw->next; |
1776 | if ((udpw->frag_ctx != NULL) && (udpw->frag_ctx == s->frag_ctx)) | 1816 | if ((udpw->frag_ctx != NULL) && (udpw->frag_ctx == s->frag_ctx)) |
1777 | { | 1817 | { |
1778 | GNUNET_CONTAINER_DLL_remove(plugin->ipv6_queue_head, plugin->ipv6_queue_tail, udpw); | 1818 | dequeue (plugin, udpw); |
1779 | GNUNET_free (udpw); | 1819 | GNUNET_free (udpw); |
1780 | } | 1820 | } |
1781 | udpw = tmp; | 1821 | udpw = tmp; |
@@ -1789,7 +1829,7 @@ read_process_ack (struct Plugin *plugin, | |||
1789 | tmp = udpw->next; | 1829 | tmp = udpw->next; |
1790 | if ((udpw->frag_ctx != NULL) && (udpw->frag_ctx == s->frag_ctx)) | 1830 | if ((udpw->frag_ctx != NULL) && (udpw->frag_ctx == s->frag_ctx)) |
1791 | { | 1831 | { |
1792 | GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw); | 1832 | dequeue (plugin, udpw); |
1793 | GNUNET_free (udpw); | 1833 | GNUNET_free (udpw); |
1794 | } | 1834 | } |
1795 | udpw = tmp; | 1835 | udpw = tmp; |
@@ -2001,22 +2041,18 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, | |||
2001 | } | 2041 | } |
2002 | 2042 | ||
2003 | GNUNET_STATISTICS_update (plugin->env->stats, | 2043 | GNUNET_STATISTICS_update (plugin->env->stats, |
2004 | "# bytes currently in UDP buffers", | ||
2005 | -udpw->msg_size, GNUNET_NO); | ||
2006 | |||
2007 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
2008 | "# messages dismissed due to timeout", | 2044 | "# messages dismissed due to timeout", |
2009 | 1, GNUNET_NO); | 2045 | 1, GNUNET_NO); |
2010 | /* Remove message */ | 2046 | /* Remove message */ |
2011 | if (sock == plugin->sockv4) | 2047 | if (sock == plugin->sockv4) |
2012 | { | 2048 | { |
2013 | GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw); | 2049 | dequeue (plugin, udpw); |
2014 | GNUNET_free (udpw); | 2050 | GNUNET_free (udpw); |
2015 | udpw = plugin->ipv4_queue_head; | 2051 | udpw = plugin->ipv4_queue_head; |
2016 | } | 2052 | } |
2017 | if (sock == plugin->sockv6) | 2053 | if (sock == plugin->sockv6) |
2018 | { | 2054 | { |
2019 | GNUNET_CONTAINER_DLL_remove(plugin->ipv6_queue_head, plugin->ipv6_queue_tail, udpw); | 2055 | dequeue (plugin, udpw); |
2020 | GNUNET_free (udpw); | 2056 | GNUNET_free (udpw); |
2021 | udpw = plugin->ipv6_queue_head; | 2057 | udpw = plugin->ipv6_queue_head; |
2022 | } | 2058 | } |
@@ -2135,15 +2171,7 @@ udp_select_send (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *sock) | |||
2135 | udpw->frag_ctx->on_wire_size += udpw->msg_size; | 2171 | udpw->frag_ctx->on_wire_size += udpw->msg_size; |
2136 | call_continuation (udpw, GNUNET_OK); | 2172 | call_continuation (udpw, GNUNET_OK); |
2137 | } | 2173 | } |
2138 | 2174 | dequeue (plugin, udpw); | |
2139 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
2140 | "# bytes currently in UDP buffers", | ||
2141 | -udpw->msg_size, GNUNET_NO); | ||
2142 | |||
2143 | if (sock == plugin->sockv4) | ||
2144 | GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw); | ||
2145 | else if (sock == plugin->sockv6) | ||
2146 | GNUNET_CONTAINER_DLL_remove(plugin->ipv6_queue_head, plugin->ipv6_queue_tail, udpw); | ||
2147 | GNUNET_free (udpw); | 2175 | GNUNET_free (udpw); |
2148 | udpw = NULL; | 2176 | udpw = NULL; |
2149 | 2177 | ||
@@ -2610,18 +2638,20 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
2610 | while (udpw != NULL) | 2638 | while (udpw != NULL) |
2611 | { | 2639 | { |
2612 | struct UDP_MessageWrapper *tmp = udpw->next; | 2640 | struct UDP_MessageWrapper *tmp = udpw->next; |
2613 | GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw); | 2641 | dequeue (plugin, udpw); |
2614 | call_continuation(udpw, GNUNET_SYSERR); | 2642 | call_continuation(udpw, GNUNET_SYSERR); |
2615 | GNUNET_free (udpw); | 2643 | GNUNET_free (udpw); |
2644 | |||
2616 | udpw = tmp; | 2645 | udpw = tmp; |
2617 | } | 2646 | } |
2618 | udpw = plugin->ipv6_queue_head; | 2647 | udpw = plugin->ipv6_queue_head; |
2619 | while (udpw != NULL) | 2648 | while (udpw != NULL) |
2620 | { | 2649 | { |
2621 | struct UDP_MessageWrapper *tmp = udpw->next; | 2650 | struct UDP_MessageWrapper *tmp = udpw->next; |
2622 | GNUNET_CONTAINER_DLL_remove(plugin->ipv6_queue_head, plugin->ipv6_queue_tail, udpw); | 2651 | dequeue (plugin, udpw); |
2623 | call_continuation(udpw, GNUNET_SYSERR); | 2652 | call_continuation(udpw, GNUNET_SYSERR); |
2624 | GNUNET_free (udpw); | 2653 | GNUNET_free (udpw); |
2654 | |||
2625 | udpw = tmp; | 2655 | udpw = tmp; |
2626 | } | 2656 | } |
2627 | 2657 | ||