diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-23 11:08:12 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-23 11:08:12 +0000 |
commit | 844776ae1b6d1beb0af2e93a672d4681a9f7d51c (patch) | |
tree | 7e4ce6d7b3b262d32c5381d22e2c53caa343ed35 /src | |
parent | 77056f3bc6cd9b2a67498d007a8c2252a375cabb (diff) | |
download | gnunet-844776ae1b6d1beb0af2e93a672d4681a9f7d51c.tar.gz gnunet-844776ae1b6d1beb0af2e93a672d4681a9f7d51c.zip |
adding monitoring support to UDP plugin, plus some doxygen/indentation fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 242 |
1 files changed, 169 insertions, 73 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 37f93f6a7..782a5ea8f 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -185,13 +185,11 @@ struct Session | |||
185 | 185 | ||
186 | /** | 186 | /** |
187 | * Number of bytes waiting for transmission to this peer. | 187 | * Number of bytes waiting for transmission to this peer. |
188 | * FIXME: not updated yet! | ||
189 | */ | 188 | */ |
190 | unsigned long long bytes_in_queue; | 189 | unsigned long long bytes_in_queue; |
191 | 190 | ||
192 | /** | 191 | /** |
193 | * Number of messages waiting for transmission to this peer. | 192 | * Number of messages waiting for transmission to this peer. |
194 | * FIXME: not updated yet! | ||
195 | */ | 193 | */ |
196 | unsigned int msgs_in_queue; | 194 | unsigned int msgs_in_queue; |
197 | 195 | ||
@@ -1183,14 +1181,21 @@ free_session (struct Session *s) | |||
1183 | 1181 | ||
1184 | 1182 | ||
1185 | /** | 1183 | /** |
1186 | * FIXME. | 1184 | * Remove a message from the transmission queue. |
1185 | * | ||
1186 | * @param plugin the UDP plugin | ||
1187 | * @param udpw message wrapper to queue | ||
1187 | */ | 1188 | */ |
1188 | static void | 1189 | static void |
1189 | dequeue (struct Plugin *plugin, | 1190 | dequeue (struct Plugin *plugin, |
1190 | struct UDP_MessageWrapper *udpw) | 1191 | struct UDP_MessageWrapper *udpw) |
1191 | { | 1192 | { |
1193 | struct Session *session = udpw->session; | ||
1194 | |||
1192 | if (plugin->bytes_in_buffer < udpw->msg_size) | 1195 | if (plugin->bytes_in_buffer < udpw->msg_size) |
1193 | GNUNET_break(0); | 1196 | { |
1197 | GNUNET_break (0); | ||
1198 | } | ||
1194 | else | 1199 | else |
1195 | { | 1200 | { |
1196 | GNUNET_STATISTICS_update (plugin->env->stats, | 1201 | GNUNET_STATISTICS_update (plugin->env->stats, |
@@ -1203,13 +1208,22 @@ dequeue (struct Plugin *plugin, | |||
1203 | "# UDP, total, msgs in buffers", | 1208 | "# UDP, total, msgs in buffers", |
1204 | -1, GNUNET_NO); | 1209 | -1, GNUNET_NO); |
1205 | if (udpw->session->address->address_length == sizeof(struct IPv4UdpAddress)) | 1210 | if (udpw->session->address->address_length == sizeof(struct IPv4UdpAddress)) |
1206 | GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, | 1211 | GNUNET_CONTAINER_DLL_remove (plugin->ipv4_queue_head, |
1207 | plugin->ipv4_queue_tail, udpw); | 1212 | plugin->ipv4_queue_tail, |
1213 | udpw); | ||
1208 | else if (udpw->session->address->address_length == sizeof(struct IPv6UdpAddress)) | 1214 | else if (udpw->session->address->address_length == sizeof(struct IPv6UdpAddress)) |
1209 | GNUNET_CONTAINER_DLL_remove(plugin->ipv6_queue_head, | 1215 | GNUNET_CONTAINER_DLL_remove (plugin->ipv6_queue_head, |
1210 | plugin->ipv6_queue_tail, udpw); | 1216 | plugin->ipv6_queue_tail, |
1217 | udpw); | ||
1211 | else | 1218 | else |
1219 | { | ||
1212 | GNUNET_break (0); | 1220 | GNUNET_break (0); |
1221 | return; | ||
1222 | } | ||
1223 | GNUNET_assert (session->msgs_in_queue > 0); | ||
1224 | session->msgs_in_queue--; | ||
1225 | GNUNET_assert (session->bytes_in_queue >= udpw->msg_size); | ||
1226 | session->bytes_in_queue -= udpw->msg_size; | ||
1213 | } | 1227 | } |
1214 | 1228 | ||
1215 | 1229 | ||
@@ -1240,9 +1254,7 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, | |||
1240 | dummy.cont = NULL; | 1254 | dummy.cont = NULL; |
1241 | dummy.cont_cls = NULL; | 1255 | dummy.cont_cls = NULL; |
1242 | dummy.session = s; | 1256 | dummy.session = s; |
1243 | |||
1244 | call_continuation (&dummy, result); | 1257 | call_continuation (&dummy, result); |
1245 | |||
1246 | /* Remove leftover fragments from queue */ | 1258 | /* Remove leftover fragments from queue */ |
1247 | if (s->address->address_length == sizeof(struct IPv6UdpAddress)) | 1259 | if (s->address->address_length == sizeof(struct IPv6UdpAddress)) |
1248 | { | 1260 | { |
@@ -1273,12 +1285,15 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, | |||
1273 | udpw = tmp; | 1285 | udpw = tmp; |
1274 | } | 1286 | } |
1275 | } | 1287 | } |
1276 | 1288 | notify_session_monitor (s->plugin, | |
1289 | s, | ||
1290 | GNUNET_TRANSPORT_SS_UP); | ||
1277 | /* Destroy fragmentation context */ | 1291 | /* Destroy fragmentation context */ |
1278 | GNUNET_FRAGMENT_context_destroy (fc->frag, &s->last_expected_msg_delay, | 1292 | GNUNET_FRAGMENT_context_destroy (fc->frag, |
1279 | &s->last_expected_ack_delay); | 1293 | &s->last_expected_msg_delay, |
1294 | &s->last_expected_ack_delay); | ||
1280 | s->frag_ctx = NULL; | 1295 | s->frag_ctx = NULL; |
1281 | GNUNET_free(fc); | 1296 | GNUNET_free (fc); |
1282 | } | 1297 | } |
1283 | 1298 | ||
1284 | 1299 | ||
@@ -1363,7 +1378,6 @@ udp_disconnect_session (void *cls, | |||
1363 | GNUNET_free (d_ctx); | 1378 | GNUNET_free (d_ctx); |
1364 | } | 1379 | } |
1365 | } | 1380 | } |
1366 | |||
1367 | next = plugin->ipv4_queue_head; | 1381 | next = plugin->ipv4_queue_head; |
1368 | while (NULL != (udpw = next)) | 1382 | while (NULL != (udpw = next)) |
1369 | { | 1383 | { |
@@ -1386,6 +1400,9 @@ udp_disconnect_session (void *cls, | |||
1386 | GNUNET_free(udpw); | 1400 | GNUNET_free(udpw); |
1387 | } | 1401 | } |
1388 | } | 1402 | } |
1403 | notify_session_monitor (s->plugin, | ||
1404 | s, | ||
1405 | GNUNET_TRANSPORT_SS_DOWN); | ||
1389 | plugin->env->session_end (plugin->env->cls, | 1406 | plugin->env->session_end (plugin->env->cls, |
1390 | s->address, | 1407 | s->address, |
1391 | s); | 1408 | s); |
@@ -1414,7 +1431,9 @@ udp_disconnect_session (void *cls, | |||
1414 | GNUNET_CONTAINER_multipeermap_size (plugin->sessions), | 1431 | GNUNET_CONTAINER_multipeermap_size (plugin->sessions), |
1415 | GNUNET_NO); | 1432 | GNUNET_NO); |
1416 | if (s->rc > 0) | 1433 | if (s->rc > 0) |
1434 | { | ||
1417 | s->in_destroy = GNUNET_YES; | 1435 | s->in_destroy = GNUNET_YES; |
1436 | } | ||
1418 | else | 1437 | else |
1419 | { | 1438 | { |
1420 | GNUNET_HELLO_address_free (s->address); | 1439 | GNUNET_HELLO_address_free (s->address); |
@@ -1881,30 +1900,45 @@ udp_plugin_get_session (void *cls, | |||
1881 | 1900 | ||
1882 | 1901 | ||
1883 | /** | 1902 | /** |
1884 | * FIXME. | 1903 | * Enqueue a message for transmission. |
1904 | * | ||
1905 | * @param plugin the UDP plugin | ||
1906 | * @param udpw message wrapper to queue | ||
1885 | */ | 1907 | */ |
1886 | static void | 1908 | static void |
1887 | enqueue (struct Plugin *plugin, | 1909 | enqueue (struct Plugin *plugin, |
1888 | struct UDP_MessageWrapper *udpw) | 1910 | struct UDP_MessageWrapper *udpw) |
1889 | { | 1911 | { |
1912 | struct Session *session = udpw->session; | ||
1913 | |||
1890 | if (plugin->bytes_in_buffer + udpw->msg_size > INT64_MAX) | 1914 | if (plugin->bytes_in_buffer + udpw->msg_size > INT64_MAX) |
1891 | GNUNET_break(0); | 1915 | { |
1916 | GNUNET_break (0); | ||
1917 | } | ||
1892 | else | 1918 | else |
1893 | { | 1919 | { |
1894 | GNUNET_STATISTICS_update (plugin->env->stats, | 1920 | GNUNET_STATISTICS_update (plugin->env->stats, |
1895 | "# UDP, total, bytes in buffers", udpw->msg_size, GNUNET_NO); | 1921 | "# UDP, total, bytes in buffers", udpw->msg_size, GNUNET_NO); |
1896 | plugin->bytes_in_buffer += udpw->msg_size; | 1922 | plugin->bytes_in_buffer += udpw->msg_size; |
1897 | } | 1923 | } |
1898 | GNUNET_STATISTICS_update (plugin->env->stats, "# UDP, total, msgs in buffers", | 1924 | GNUNET_STATISTICS_update (plugin->env->stats, |
1899 | 1, GNUNET_NO); | 1925 | "# UDP, total, msgs in buffers", |
1926 | 1, GNUNET_NO); | ||
1900 | if (udpw->session->address->address_length == sizeof (struct IPv4UdpAddress)) | 1927 | if (udpw->session->address->address_length == sizeof (struct IPv4UdpAddress)) |
1901 | GNUNET_CONTAINER_DLL_insert(plugin->ipv4_queue_head, | 1928 | GNUNET_CONTAINER_DLL_insert(plugin->ipv4_queue_head, |
1902 | plugin->ipv4_queue_tail, udpw); | 1929 | plugin->ipv4_queue_tail, |
1930 | udpw); | ||
1903 | else if (udpw->session->address->address_length == sizeof (struct IPv6UdpAddress)) | 1931 | else if (udpw->session->address->address_length == sizeof (struct IPv6UdpAddress)) |
1904 | GNUNET_CONTAINER_DLL_insert(plugin->ipv6_queue_head, | 1932 | GNUNET_CONTAINER_DLL_insert (plugin->ipv6_queue_head, |
1905 | plugin->ipv6_queue_tail, udpw); | 1933 | plugin->ipv6_queue_tail, |
1934 | udpw); | ||
1906 | else | 1935 | else |
1936 | { | ||
1907 | GNUNET_break (0); | 1937 | GNUNET_break (0); |
1938 | return; | ||
1939 | } | ||
1940 | session->msgs_in_queue++; | ||
1941 | session->bytes_in_queue += udpw->msg_size; | ||
1908 | } | 1942 | } |
1909 | 1943 | ||
1910 | 1944 | ||
@@ -1949,7 +1983,9 @@ enqueue_fragment (void *cls, | |||
1949 | struct UDP_MessageWrapper * udpw; | 1983 | struct UDP_MessageWrapper * udpw; |
1950 | size_t msg_len = ntohs (msg->size); | 1984 | size_t msg_len = ntohs (msg->size); |
1951 | 1985 | ||
1952 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Enqueuing fragment with %u bytes\n", msg_len); | 1986 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1987 | "Enqueuing fragment with %u bytes\n", | ||
1988 | msg_len); | ||
1953 | frag_ctx->fragments_used++; | 1989 | frag_ctx->fragments_used++; |
1954 | udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msg_len); | 1990 | udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msg_len); |
1955 | udpw->session = frag_ctx->session; | 1991 | udpw->session = frag_ctx->session; |
@@ -2073,8 +2109,9 @@ udp_plugin_send (void *cls, | |||
2073 | GNUNET_STATISTICS_update (plugin->env->stats, | 2109 | GNUNET_STATISTICS_update (plugin->env->stats, |
2074 | "# UDP, unfragmented msgs, messages, attempt", 1, GNUNET_NO); | 2110 | "# UDP, unfragmented msgs, messages, attempt", 1, GNUNET_NO); |
2075 | GNUNET_STATISTICS_update (plugin->env->stats, | 2111 | GNUNET_STATISTICS_update (plugin->env->stats, |
2076 | "# UDP, unfragmented msgs, bytes payload, attempt", udpw->payload_size, | 2112 | "# UDP, unfragmented msgs, bytes payload, attempt", |
2077 | GNUNET_NO); | 2113 | udpw->payload_size, |
2114 | GNUNET_NO); | ||
2078 | } | 2115 | } |
2079 | else | 2116 | else |
2080 | { | 2117 | { |
@@ -2092,17 +2129,30 @@ udp_plugin_send (void *cls, | |||
2092 | frag_ctx->payload_size = msgbuf_size; /* unfragmented message size without UDP overhead */ | 2129 | frag_ctx->payload_size = msgbuf_size; /* unfragmented message size without UDP overhead */ |
2093 | frag_ctx->on_wire_size = 0; /* bytes with UDP and fragmentation overhead */ | 2130 | frag_ctx->on_wire_size = 0; /* bytes with UDP and fragmentation overhead */ |
2094 | frag_ctx->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, | 2131 | frag_ctx->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, |
2095 | UDP_MTU, &plugin->tracker, s->last_expected_msg_delay, | 2132 | UDP_MTU, |
2096 | s->last_expected_ack_delay, &udp->header, &enqueue_fragment, frag_ctx); | 2133 | &plugin->tracker, |
2134 | s->last_expected_msg_delay, | ||
2135 | s->last_expected_ack_delay, | ||
2136 | &udp->header, | ||
2137 | &enqueue_fragment, | ||
2138 | frag_ctx); | ||
2097 | s->frag_ctx = frag_ctx; | 2139 | s->frag_ctx = frag_ctx; |
2098 | GNUNET_STATISTICS_update (plugin->env->stats, | 2140 | GNUNET_STATISTICS_update (plugin->env->stats, |
2099 | "# UDP, fragmented msgs, messages, pending", 1, GNUNET_NO); | 2141 | "# UDP, fragmented msgs, messages, pending", |
2142 | 1, | ||
2143 | GNUNET_NO); | ||
2100 | GNUNET_STATISTICS_update (plugin->env->stats, | 2144 | GNUNET_STATISTICS_update (plugin->env->stats, |
2101 | "# UDP, fragmented msgs, messages, attempt", 1, GNUNET_NO); | 2145 | "# UDP, fragmented msgs, messages, attempt", |
2146 | 1, | ||
2147 | GNUNET_NO); | ||
2102 | GNUNET_STATISTICS_update (plugin->env->stats, | 2148 | GNUNET_STATISTICS_update (plugin->env->stats, |
2103 | "# UDP, fragmented msgs, bytes payload, attempt", | 2149 | "# UDP, fragmented msgs, bytes payload, attempt", |
2104 | frag_ctx->payload_size, GNUNET_NO); | 2150 | frag_ctx->payload_size, |
2151 | GNUNET_NO); | ||
2105 | } | 2152 | } |
2153 | notify_session_monitor (s->plugin, | ||
2154 | s, | ||
2155 | GNUNET_TRANSPORT_SS_UP); | ||
2106 | schedule_select (plugin); | 2156 | schedule_select (plugin); |
2107 | return udpmlen; | 2157 | return udpmlen; |
2108 | } | 2158 | } |
@@ -2392,6 +2442,9 @@ ack_proc (void *cls, | |||
2392 | udp_ack->sender = *rc->plugin->env->my_identity; | 2442 | udp_ack->sender = *rc->plugin->env->my_identity; |
2393 | memcpy (&udp_ack[1], msg, ntohs (msg->size)); | 2443 | memcpy (&udp_ack[1], msg, ntohs (msg->size)); |
2394 | enqueue (rc->plugin, udpw); | 2444 | enqueue (rc->plugin, udpw); |
2445 | notify_session_monitor (s->plugin, | ||
2446 | s, | ||
2447 | GNUNET_TRANSPORT_SS_UP); | ||
2395 | schedule_select (rc->plugin); | 2448 | schedule_select (rc->plugin); |
2396 | } | 2449 | } |
2397 | 2450 | ||
@@ -2658,7 +2711,9 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, | |||
2658 | struct GNUNET_TIME_Relative remaining; | 2711 | struct GNUNET_TIME_Relative remaining; |
2659 | struct Session *session; | 2712 | struct Session *session; |
2660 | struct Plugin *plugin; | 2713 | struct Plugin *plugin; |
2714 | int removed; | ||
2661 | 2715 | ||
2716 | removed = GNUNET_NO; | ||
2662 | udpw = head; | 2717 | udpw = head; |
2663 | while (NULL != udpw) | 2718 | while (NULL != udpw) |
2664 | { | 2719 | { |
@@ -2673,52 +2728,74 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, | |||
2673 | { | 2728 | { |
2674 | case UMT_MSG_UNFRAGMENTED: | 2729 | case UMT_MSG_UNFRAGMENTED: |
2675 | GNUNET_STATISTICS_update (plugin->env->stats, | 2730 | GNUNET_STATISTICS_update (plugin->env->stats, |
2676 | "# UDP, total, bytes, sent, timeout", udpw->msg_size, GNUNET_NO); | 2731 | "# UDP, total, bytes, sent, timeout", |
2732 | udpw->msg_size, | ||
2733 | GNUNET_NO); | ||
2677 | GNUNET_STATISTICS_update (plugin->env->stats, | 2734 | GNUNET_STATISTICS_update (plugin->env->stats, |
2678 | "# UDP, total, messages, sent, timeout", 1, GNUNET_NO); | 2735 | "# UDP, total, messages, sent, timeout", |
2736 | 1, | ||
2737 | GNUNET_NO); | ||
2679 | GNUNET_STATISTICS_update (plugin->env->stats, | 2738 | GNUNET_STATISTICS_update (plugin->env->stats, |
2680 | "# UDP, unfragmented msgs, messages, sent, timeout", 1, GNUNET_NO); | 2739 | "# UDP, unfragmented msgs, messages, sent, timeout", |
2740 | 1, | ||
2741 | GNUNET_NO); | ||
2681 | GNUNET_STATISTICS_update (plugin->env->stats, | 2742 | GNUNET_STATISTICS_update (plugin->env->stats, |
2682 | "# UDP, unfragmented msgs, bytes, sent, timeout", | 2743 | "# UDP, unfragmented msgs, bytes, sent, timeout", |
2683 | udpw->payload_size, GNUNET_NO); | 2744 | udpw->payload_size, |
2745 | GNUNET_NO); | ||
2684 | /* Not fragmented message */ | 2746 | /* Not fragmented message */ |
2685 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 2747 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2686 | "Message for peer `%s' with size %u timed out\n", | 2748 | "Message for peer `%s' with size %u timed out\n", |
2687 | GNUNET_i2s (&udpw->session->target), udpw->payload_size); | 2749 | GNUNET_i2s (&udpw->session->target), |
2750 | udpw->payload_size); | ||
2688 | call_continuation (udpw, GNUNET_SYSERR); | 2751 | call_continuation (udpw, GNUNET_SYSERR); |
2689 | /* Remove message */ | 2752 | /* Remove message */ |
2753 | removed = GNUNET_YES; | ||
2690 | dequeue (plugin, udpw); | 2754 | dequeue (plugin, udpw); |
2691 | GNUNET_free(udpw); | 2755 | GNUNET_free(udpw); |
2692 | break; | 2756 | break; |
2693 | case UMT_MSG_FRAGMENTED: | 2757 | case UMT_MSG_FRAGMENTED: |
2694 | /* Fragmented message */ | 2758 | /* Fragmented message */ |
2695 | GNUNET_STATISTICS_update (plugin->env->stats, | 2759 | GNUNET_STATISTICS_update (plugin->env->stats, |
2696 | "# UDP, total, bytes, sent, timeout", udpw->frag_ctx->on_wire_size, | 2760 | "# UDP, total, bytes, sent, timeout", |
2697 | GNUNET_NO); | 2761 | udpw->frag_ctx->on_wire_size, |
2762 | GNUNET_NO); | ||
2698 | GNUNET_STATISTICS_update (plugin->env->stats, | 2763 | GNUNET_STATISTICS_update (plugin->env->stats, |
2699 | "# UDP, total, messages, sent, timeout", 1, GNUNET_NO); | 2764 | "# UDP, total, messages, sent, timeout", |
2765 | 1, | ||
2766 | GNUNET_NO); | ||
2700 | call_continuation (udpw, GNUNET_SYSERR); | 2767 | call_continuation (udpw, GNUNET_SYSERR); |
2701 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 2768 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2702 | "Fragment for message for peer `%s' with size %u timed out\n", | 2769 | "Fragment for message for peer `%s' with size %u timed out\n", |
2703 | GNUNET_i2s (&udpw->session->target), udpw->frag_ctx->payload_size); | 2770 | GNUNET_i2s (&udpw->session->target), |
2771 | udpw->frag_ctx->payload_size); | ||
2704 | 2772 | ||
2705 | GNUNET_STATISTICS_update (plugin->env->stats, | 2773 | GNUNET_STATISTICS_update (plugin->env->stats, |
2706 | "# UDP, fragmented msgs, messages, sent, timeout", 1, GNUNET_NO); | 2774 | "# UDP, fragmented msgs, messages, sent, timeout", |
2775 | 1, | ||
2776 | GNUNET_NO); | ||
2707 | GNUNET_STATISTICS_update (plugin->env->stats, | 2777 | GNUNET_STATISTICS_update (plugin->env->stats, |
2708 | "# UDP, fragmented msgs, bytes, sent, timeout", | 2778 | "# UDP, fragmented msgs, bytes, sent, timeout", |
2709 | udpw->frag_ctx->payload_size, GNUNET_NO); | 2779 | udpw->frag_ctx->payload_size, |
2780 | GNUNET_NO); | ||
2710 | /* Remove fragmented message due to timeout */ | 2781 | /* Remove fragmented message due to timeout */ |
2711 | fragmented_message_done (udpw->frag_ctx, GNUNET_SYSERR); | 2782 | fragmented_message_done (udpw->frag_ctx, GNUNET_SYSERR); |
2712 | break; | 2783 | break; |
2713 | case UMT_MSG_ACK: | 2784 | case UMT_MSG_ACK: |
2714 | GNUNET_STATISTICS_update (plugin->env->stats, | 2785 | GNUNET_STATISTICS_update (plugin->env->stats, |
2715 | "# UDP, total, bytes, sent, timeout", udpw->msg_size, GNUNET_NO); | 2786 | "# UDP, total, bytes, sent, timeout", |
2787 | udpw->msg_size, | ||
2788 | GNUNET_NO); | ||
2716 | GNUNET_STATISTICS_update (plugin->env->stats, | 2789 | GNUNET_STATISTICS_update (plugin->env->stats, |
2717 | "# UDP, total, messages, sent, timeout", 1, GNUNET_NO); | 2790 | "# UDP, total, messages, sent, timeout", |
2718 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 2791 | 1, |
2719 | "ACK Message for peer `%s' with size %u timed out\n", | 2792 | GNUNET_NO); |
2720 | GNUNET_i2s (&udpw->session->target), udpw->payload_size); | 2793 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2794 | "ACK Message for peer `%s' with size %u timed out\n", | ||
2795 | GNUNET_i2s (&udpw->session->target), | ||
2796 | udpw->payload_size); | ||
2721 | call_continuation (udpw, GNUNET_SYSERR); | 2797 | call_continuation (udpw, GNUNET_SYSERR); |
2798 | removed = GNUNET_YES; | ||
2722 | dequeue (plugin, udpw); | 2799 | dequeue (plugin, udpw); |
2723 | GNUNET_free(udpw); | 2800 | GNUNET_free(udpw); |
2724 | break; | 2801 | break; |
@@ -2735,32 +2812,38 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, | |||
2735 | udpw = NULL; | 2812 | udpw = NULL; |
2736 | } | 2813 | } |
2737 | GNUNET_STATISTICS_update (plugin->env->stats, | 2814 | GNUNET_STATISTICS_update (plugin->env->stats, |
2738 | "# messages dismissed due to timeout", 1, GNUNET_NO); | 2815 | "# messages discarded due to timeout", |
2816 | 1, | ||
2817 | GNUNET_NO); | ||
2739 | } | 2818 | } |
2740 | else | 2819 | else |
2741 | { | 2820 | { |
2742 | /* Message did not time out, check flow delay */ | 2821 | /* Message did not time out, check flow delay */ |
2743 | remaining = GNUNET_TIME_absolute_get_remaining ( | 2822 | remaining = GNUNET_TIME_absolute_get_remaining (udpw->session->flow_delay_from_other_peer); |
2744 | udpw->session->flow_delay_from_other_peer); | ||
2745 | if (GNUNET_TIME_UNIT_ZERO.rel_value_us == remaining.rel_value_us) | 2823 | if (GNUNET_TIME_UNIT_ZERO.rel_value_us == remaining.rel_value_us) |
2746 | { | 2824 | { |
2747 | /* this message is not delayed */ | 2825 | /* this message is not delayed */ |
2748 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 2826 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2749 | "Message for peer `%s' (%u bytes) is not delayed \n", | 2827 | "Message for peer `%s' (%u bytes) is not delayed \n", |
2750 | GNUNET_i2s (&udpw->session->target), udpw->payload_size); | 2828 | GNUNET_i2s (&udpw->session->target), |
2829 | udpw->payload_size); | ||
2751 | break; /* Found message to send, break */ | 2830 | break; /* Found message to send, break */ |
2752 | } | 2831 | } |
2753 | else | 2832 | else |
2754 | { | 2833 | { |
2755 | /* Message is delayed, try next */ | 2834 | /* Message is delayed, try next */ |
2756 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 2835 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2757 | "Message for peer `%s' (%u bytes) is delayed for %s\n", | 2836 | "Message for peer `%s' (%u bytes) is delayed for %s\n", |
2758 | GNUNET_i2s (&udpw->session->target), udpw->payload_size, | 2837 | GNUNET_i2s (&udpw->session->target), udpw->payload_size, |
2759 | GNUNET_STRINGS_relative_time_to_string (remaining, GNUNET_YES)); | 2838 | GNUNET_STRINGS_relative_time_to_string (remaining, GNUNET_YES)); |
2760 | udpw = udpw->next; | 2839 | udpw = udpw->next; |
2761 | } | 2840 | } |
2762 | } | 2841 | } |
2763 | } | 2842 | } |
2843 | if (GNUNET_YES == removed) | ||
2844 | notify_session_monitor (session->plugin, | ||
2845 | session, | ||
2846 | GNUNET_TRANSPORT_SS_UP); | ||
2764 | return udpw; | 2847 | return udpw; |
2765 | } | 2848 | } |
2766 | 2849 | ||
@@ -2868,13 +2951,18 @@ udp_select_send (struct Plugin *plugin, | |||
2868 | { | 2951 | { |
2869 | call_continuation (udpw, GNUNET_OK); | 2952 | call_continuation (udpw, GNUNET_OK); |
2870 | dequeue (plugin, udpw); | 2953 | dequeue (plugin, udpw); |
2954 | notify_session_monitor (plugin, | ||
2955 | udpw->session, | ||
2956 | GNUNET_TRANSPORT_SS_UP); | ||
2871 | GNUNET_free (udpw); | 2957 | GNUNET_free (udpw); |
2872 | return GNUNET_SYSERR; | 2958 | return GNUNET_SYSERR; |
2873 | } | 2959 | } |
2874 | 2960 | ||
2875 | sent = GNUNET_NETWORK_socket_sendto (sock, udpw->msg_buf, udpw->msg_size, a, | 2961 | sent = GNUNET_NETWORK_socket_sendto (sock, |
2876 | slen); | 2962 | udpw->msg_buf, |
2877 | 2963 | udpw->msg_size, | |
2964 | a, | ||
2965 | slen); | ||
2878 | if (GNUNET_SYSERR == sent) | 2966 | if (GNUNET_SYSERR == sent) |
2879 | { | 2967 | { |
2880 | /* Failure */ | 2968 | /* Failure */ |
@@ -2902,9 +2990,10 @@ udp_select_send (struct Plugin *plugin, | |||
2902 | call_continuation (udpw, GNUNET_OK); | 2990 | call_continuation (udpw, GNUNET_OK); |
2903 | } | 2991 | } |
2904 | dequeue (plugin, udpw); | 2992 | dequeue (plugin, udpw); |
2993 | notify_session_monitor (plugin, | ||
2994 | udpw->session, | ||
2995 | GNUNET_TRANSPORT_SS_UP); | ||
2905 | GNUNET_free(udpw); | 2996 | GNUNET_free(udpw); |
2906 | udpw = NULL; | ||
2907 | |||
2908 | return sent; | 2997 | return sent; |
2909 | } | 2998 | } |
2910 | 2999 | ||
@@ -3146,8 +3235,10 @@ setup_sockets (struct Plugin *plugin, | |||
3146 | } | 3235 | } |
3147 | else | 3236 | else |
3148 | { | 3237 | { |
3149 | LOG(GNUNET_ERROR_TYPE_ERROR, "Failed to bind UDP socket to %s: %s\n", | 3238 | LOG (GNUNET_ERROR_TYPE_ERROR, |
3150 | GNUNET_a2s (server_addr, addrlen), STRERROR (eno)); | 3239 | _("Failed to bind UDP socket to %s: %s\n"), |
3240 | GNUNET_a2s (server_addr, addrlen), | ||
3241 | STRERROR (eno)); | ||
3151 | } | 3242 | } |
3152 | } | 3243 | } |
3153 | 3244 | ||
@@ -3185,10 +3276,15 @@ setup_sockets (struct Plugin *plugin, | |||
3185 | } | 3276 | } |
3186 | 3277 | ||
3187 | schedule_select (plugin); | 3278 | schedule_select (plugin); |
3188 | plugin->nat = GNUNET_NAT_register (plugin->env->cfg, GNUNET_NO, plugin->port, | 3279 | plugin->nat = GNUNET_NAT_register (plugin->env->cfg, |
3280 | GNUNET_NO, | ||
3281 | plugin->port, | ||
3189 | sockets_created, | 3282 | sockets_created, |
3190 | (const struct sockaddr **) addrs, addrlens, | 3283 | (const struct sockaddr **) addrs, |
3191 | &udp_nat_port_map_callback, NULL, plugin); | 3284 | addrlens, |
3285 | &udp_nat_port_map_callback, | ||
3286 | NULL, | ||
3287 | plugin); | ||
3192 | 3288 | ||
3193 | return sockets_created; | 3289 | return sockets_created; |
3194 | } | 3290 | } |