diff options
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index be19c5de3..cb95a5a00 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | (C) 2010, 2011 Christian Grothoff (and other contributing authors) | 3 | (C) 2010-2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -509,9 +509,9 @@ schedule_select (struct Plugin *plugin) | |||
509 | * - timeout minimum delay */ | 509 | * - timeout minimum delay */ |
510 | plugin->select_task = | 510 | plugin->select_task = |
511 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 511 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
512 | (0 == min_delay.rel_value) ? GNUNET_TIME_UNIT_FOREVER_REL : min_delay, | 512 | (0 == min_delay.rel_value_us) ? GNUNET_TIME_UNIT_FOREVER_REL : min_delay, |
513 | plugin->rs_v4, | 513 | plugin->rs_v4, |
514 | (0 == min_delay.rel_value) ? plugin->ws_v4 : NULL, | 514 | (0 == min_delay.rel_value_us) ? plugin->ws_v4 : NULL, |
515 | &udp_plugin_select, plugin); | 515 | &udp_plugin_select, plugin); |
516 | } | 516 | } |
517 | if ((GNUNET_YES == plugin->enable_ipv6) && (NULL != plugin->sockv6)) | 517 | if ((GNUNET_YES == plugin->enable_ipv6) && (NULL != plugin->sockv6)) |
@@ -525,9 +525,9 @@ schedule_select (struct Plugin *plugin) | |||
525 | GNUNET_SCHEDULER_cancel(plugin->select_task_v6); | 525 | GNUNET_SCHEDULER_cancel(plugin->select_task_v6); |
526 | plugin->select_task_v6 = | 526 | plugin->select_task_v6 = |
527 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 527 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
528 | (0 == min_delay.rel_value) ? GNUNET_TIME_UNIT_FOREVER_REL : min_delay, | 528 | (0 == min_delay.rel_value_us) ? GNUNET_TIME_UNIT_FOREVER_REL : min_delay, |
529 | plugin->rs_v6, | 529 | plugin->rs_v6, |
530 | (0 == min_delay.rel_value) ? plugin->ws_v6 : NULL, | 530 | (0 == min_delay.rel_value_us) ? plugin->ws_v6 : NULL, |
531 | &udp_plugin_select_v6, plugin); | 531 | &udp_plugin_select_v6, plugin); |
532 | } | 532 | } |
533 | } | 533 | } |
@@ -1328,8 +1328,10 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1328 | 1328 | ||
1329 | s->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 1329 | s->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
1330 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1330 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1331 | "Session %p was idle for %llu ms, disconnecting\n", | 1331 | "Session %p was idle for %s, disconnecting\n", |
1332 | s, (unsigned long long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); | 1332 | s, |
1333 | GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | ||
1334 | GNUNET_YES)); | ||
1333 | /* call session destroy function */ | 1335 | /* call session destroy function */ |
1334 | disconnect_session (s); | 1336 | disconnect_session (s); |
1335 | } | 1337 | } |
@@ -1347,8 +1349,10 @@ start_session_timeout (struct Session *s) | |||
1347 | &session_timeout, | 1349 | &session_timeout, |
1348 | s); | 1350 | s); |
1349 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1351 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1350 | "Timeout for session %p set to %llu ms\n", | 1352 | "Timeout for session %p set to %s\n", |
1351 | s, (unsigned long long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); | 1353 | s, |
1354 | GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | ||
1355 | GNUNET_YES)); | ||
1352 | } | 1356 | } |
1353 | 1357 | ||
1354 | 1358 | ||
@@ -1366,8 +1370,10 @@ reschedule_session_timeout (struct Session *s) | |||
1366 | &session_timeout, | 1370 | &session_timeout, |
1367 | s); | 1371 | s); |
1368 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1369 | "Timeout rescheduled for session %p set to %llu ms\n", | 1373 | "Timeout rescheduled for session %p set to %s\n", |
1370 | s, (unsigned long long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); | 1374 | s, |
1375 | GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | ||
1376 | GNUNET_YES)); | ||
1371 | } | 1377 | } |
1372 | 1378 | ||
1373 | 1379 | ||
@@ -1385,7 +1391,7 @@ stop_session_timeout (struct Session *s) | |||
1385 | s->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 1391 | s->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
1386 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1392 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1387 | "Timeout stopped for session %p canceled\n", | 1393 | "Timeout stopped for session %p canceled\n", |
1388 | s, (unsigned long long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); | 1394 | s); |
1389 | } | 1395 | } |
1390 | } | 1396 | } |
1391 | 1397 | ||
@@ -2173,16 +2179,17 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) | |||
2173 | if (NULL == s) | 2179 | if (NULL == s) |
2174 | return; | 2180 | return; |
2175 | 2181 | ||
2176 | if (s->flow_delay_for_other_peer.rel_value <= UINT32_MAX) | 2182 | if (s->flow_delay_for_other_peer.rel_value_us <= UINT32_MAX) |
2177 | delay = s->flow_delay_for_other_peer.rel_value; | 2183 | delay = s->flow_delay_for_other_peer.rel_value_us; |
2178 | 2184 | ||
2179 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2185 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2180 | "Sending ACK to `%s' including delay of %u ms\n", | 2186 | "Sending ACK to `%s' including delay of %s\n", |
2181 | GNUNET_a2s (rc->src_addr, | 2187 | GNUNET_a2s (rc->src_addr, |
2182 | (rc->src_addr->sa_family == | 2188 | (rc->src_addr->sa_family == |
2183 | AF_INET) ? sizeof (struct sockaddr_in) : sizeof (struct | 2189 | AF_INET) ? sizeof (struct sockaddr_in) : sizeof (struct |
2184 | sockaddr_in6)), | 2190 | sockaddr_in6)), |
2185 | delay); | 2191 | GNUNET_STRINGS_relative_time_to_string (s->flow_delay_for_other_peer, |
2192 | GNUNET_YES)); | ||
2186 | udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msize); | 2193 | udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msize); |
2187 | udpw->msg_size = msize; | 2194 | udpw->msg_size = msize; |
2188 | udpw->payload_size = 0; | 2195 | udpw->payload_size = 0; |
@@ -2248,10 +2255,11 @@ read_process_ack (struct Plugin *plugin, | |||
2248 | return; | 2255 | return; |
2249 | } | 2256 | } |
2250 | 2257 | ||
2251 | flow_delay.rel_value = (uint64_t) ntohl (udp_ack->delay); | 2258 | flow_delay.rel_value_us = (uint64_t) ntohl (udp_ack->delay); |
2252 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2259 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2253 | "We received a sending delay of %llu\n", | 2260 | "We received a sending delay of %s\n", |
2254 | flow_delay.rel_value); | 2261 | GNUNET_STRINGS_relative_time_to_string (flow_delay, |
2262 | GNUNET_YES)); | ||
2255 | s->flow_delay_from_other_peer = | 2263 | s->flow_delay_from_other_peer = |
2256 | GNUNET_TIME_relative_to_absolute (flow_delay); | 2264 | GNUNET_TIME_relative_to_absolute (flow_delay); |
2257 | 2265 | ||
@@ -2324,7 +2332,7 @@ read_process_fragment (struct Plugin *plugin, | |||
2324 | d_ctx->hnode = | 2332 | d_ctx->hnode = |
2325 | GNUNET_CONTAINER_heap_insert (plugin->defrag_ctxs, d_ctx, | 2333 | GNUNET_CONTAINER_heap_insert (plugin->defrag_ctxs, d_ctx, |
2326 | (GNUNET_CONTAINER_HeapCostType) | 2334 | (GNUNET_CONTAINER_HeapCostType) |
2327 | now.abs_value); | 2335 | now.abs_value_us); |
2328 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2336 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2329 | "Created new defragmentation context for %u-byte fragment from `%s'\n", | 2337 | "Created new defragmentation context for %u-byte fragment from `%s'\n", |
2330 | (unsigned int) ntohs (msg->size), | 2338 | (unsigned int) ntohs (msg->size), |
@@ -2343,7 +2351,7 @@ read_process_fragment (struct Plugin *plugin, | |||
2343 | /* keep this 'rc' from expiring */ | 2351 | /* keep this 'rc' from expiring */ |
2344 | GNUNET_CONTAINER_heap_update_cost (plugin->defrag_ctxs, d_ctx->hnode, | 2352 | GNUNET_CONTAINER_heap_update_cost (plugin->defrag_ctxs, d_ctx->hnode, |
2345 | (GNUNET_CONTAINER_HeapCostType) | 2353 | (GNUNET_CONTAINER_HeapCostType) |
2346 | now.abs_value); | 2354 | now.abs_value_us); |
2347 | } | 2355 | } |
2348 | if (GNUNET_CONTAINER_heap_get_size (plugin->defrag_ctxs) > | 2356 | if (GNUNET_CONTAINER_heap_get_size (plugin->defrag_ctxs) > |
2349 | UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG) | 2357 | UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG) |
@@ -2459,7 +2467,7 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, | |||
2459 | { | 2467 | { |
2460 | /* Find messages with timeout */ | 2468 | /* Find messages with timeout */ |
2461 | remaining = GNUNET_TIME_absolute_get_remaining (udpw->timeout); | 2469 | remaining = GNUNET_TIME_absolute_get_remaining (udpw->timeout); |
2462 | if (GNUNET_TIME_UNIT_ZERO.rel_value == remaining.rel_value) | 2470 | if (GNUNET_TIME_UNIT_ZERO.rel_value_us == remaining.rel_value_us) |
2463 | { | 2471 | { |
2464 | /* Message timed out */ | 2472 | /* Message timed out */ |
2465 | switch (udpw->msg_type) { | 2473 | switch (udpw->msg_type) { |
@@ -2542,7 +2550,7 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, | |||
2542 | { | 2550 | { |
2543 | /* Message did not time out, check flow delay */ | 2551 | /* Message did not time out, check flow delay */ |
2544 | remaining = GNUNET_TIME_absolute_get_remaining (udpw->session->flow_delay_from_other_peer); | 2552 | remaining = GNUNET_TIME_absolute_get_remaining (udpw->session->flow_delay_from_other_peer); |
2545 | if (GNUNET_TIME_UNIT_ZERO.rel_value == remaining.rel_value) | 2553 | if (GNUNET_TIME_UNIT_ZERO.rel_value_us == remaining.rel_value_us) |
2546 | { | 2554 | { |
2547 | /* this message is not delayed */ | 2555 | /* this message is not delayed */ |
2548 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2556 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2554,8 +2562,10 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, | |||
2554 | { | 2562 | { |
2555 | /* Message is delayed, try next */ | 2563 | /* Message is delayed, try next */ |
2556 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2564 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2557 | "Message for peer `%s' (%u bytes) is delayed for %llu \n", | 2565 | "Message for peer `%s' (%u bytes) is delayed for %s\n", |
2558 | GNUNET_i2s(&udpw->session->target), udpw->payload_size, remaining.rel_value); | 2566 | GNUNET_i2s(&udpw->session->target), udpw->payload_size, |
2567 | GNUNET_STRINGS_relative_time_to_string (remaining, | ||
2568 | GNUNET_YES)); | ||
2559 | udpw = udpw->next; | 2569 | udpw = udpw->next; |
2560 | } | 2570 | } |
2561 | } | 2571 | } |