diff options
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 8f53b93be..f09641506 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.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,2012 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 |
@@ -155,7 +155,7 @@ print_allocators () | |||
155 | next = GNUNET_TIME_UNIT_ZERO_ABS; | 155 | next = GNUNET_TIME_UNIT_ZERO_ABS; |
156 | start = GNUNET_NO; | 156 | start = GNUNET_NO; |
157 | } | 157 | } |
158 | if (0 == (rem = GNUNET_TIME_absolute_get_remaining(next)).rel_value) | 158 | if (0 == (rem = GNUNET_TIME_absolute_get_remaining(next)).rel_value_us) |
159 | { | 159 | { |
160 | fprintf (stderr, "Allocated in `%s' total: %5u bytes\n", __FILE__, bytes_alloced); | 160 | fprintf (stderr, "Allocated in `%s' total: %5u bytes\n", __FILE__, bytes_alloced); |
161 | while (NULL != cur) | 161 | while (NULL != cur) |
@@ -1406,7 +1406,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) | |||
1406 | while (NULL != (mq = n->messages_head)) | 1406 | while (NULL != (mq = n->messages_head)) |
1407 | { | 1407 | { |
1408 | timeout = GNUNET_TIME_absolute_get_remaining (mq->timeout); | 1408 | timeout = GNUNET_TIME_absolute_get_remaining (mq->timeout); |
1409 | if (timeout.rel_value > 0) | 1409 | if (timeout.rel_value_us > 0) |
1410 | break; | 1410 | break; |
1411 | GNUNET_STATISTICS_update (GST_stats, | 1411 | GNUNET_STATISTICS_update (GST_stats, |
1412 | gettext_noop | 1412 | gettext_noop |
@@ -1443,7 +1443,7 @@ send_keepalive (struct NeighbourMapEntry *n) | |||
1443 | GNUNET_assert ((S_CONNECTED == n->state) || | 1443 | GNUNET_assert ((S_CONNECTED == n->state) || |
1444 | (S_CONNECTED_SWITCHING_BLACKLIST == n->state) || | 1444 | (S_CONNECTED_SWITCHING_BLACKLIST == n->state) || |
1445 | (S_CONNECTED_SWITCHING_CONNECT_SENT)); | 1445 | (S_CONNECTED_SWITCHING_CONNECT_SENT)); |
1446 | if (GNUNET_TIME_absolute_get_remaining (n->keep_alive_time).rel_value > 0) | 1446 | if (GNUNET_TIME_absolute_get_remaining (n->keep_alive_time).rel_value_us > 0) |
1447 | return; /* no keepalive needed at this time */ | 1447 | return; /* no keepalive needed at this time */ |
1448 | m.size = htons (sizeof (struct GNUNET_MessageHeader)); | 1448 | m.size = htons (sizeof (struct GNUNET_MessageHeader)); |
1449 | m.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE); | 1449 | m.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE); |
@@ -1534,14 +1534,16 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour) | |||
1534 | n->latency = GNUNET_TIME_absolute_get_duration (n->last_keep_alive_time); | 1534 | n->latency = GNUNET_TIME_absolute_get_duration (n->last_keep_alive_time); |
1535 | n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | 1535 | n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |
1536 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1536 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1537 | "Latency for peer `%s' is %llu ms\n", | 1537 | "Latency for peer `%s' is %s\n", |
1538 | GNUNET_i2s (&n->id), n->latency.rel_value); | 1538 | GNUNET_i2s (&n->id), |
1539 | GNUNET_STRINGS_relative_time_to_string (n->latency, | ||
1540 | GNUNET_YES)); | ||
1539 | /* append latency */ | 1541 | /* append latency */ |
1540 | ats.type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); | 1542 | ats.type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); |
1541 | if (n->latency.rel_value > UINT32_MAX) | 1543 | if (n->latency.rel_value_us > UINT32_MAX) |
1542 | latency = UINT32_MAX; | 1544 | latency = UINT32_MAX; |
1543 | else | 1545 | else |
1544 | latency = n->latency.rel_value; | 1546 | latency = n->latency.rel_value_us; |
1545 | ats.value = htonl (latency); | 1547 | ats.value = htonl (latency); |
1546 | GST_ats_update_metrics (&n->id, | 1548 | GST_ats_update_metrics (&n->id, |
1547 | n->primary_address.address, | 1549 | n->primary_address.address, |
@@ -1622,17 +1624,18 @@ GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity | |||
1622 | } | 1624 | } |
1623 | *do_forward = GNUNET_YES; | 1625 | *do_forward = GNUNET_YES; |
1624 | ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 32 * 1024); | 1626 | ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 32 * 1024); |
1625 | if (ret.rel_value > 0) | 1627 | if (ret.rel_value_us > 0) |
1626 | { | 1628 | { |
1627 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1629 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1628 | "Throttling read (%llu bytes excess at %u b/s), waiting %llu ms before reading more.\n", | 1630 | "Throttling read (%llu bytes excess at %u b/s), waiting %s before reading more.\n", |
1629 | (unsigned long long) n->in_tracker. | 1631 | (unsigned long long) n->in_tracker. |
1630 | consumption_since_last_update__, | 1632 | consumption_since_last_update__, |
1631 | (unsigned int) n->in_tracker.available_bytes_per_s__, | 1633 | (unsigned int) n->in_tracker.available_bytes_per_s__, |
1632 | (unsigned long long) ret.rel_value); | 1634 | GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES)); |
1633 | GNUNET_STATISTICS_update (GST_stats, | 1635 | GNUNET_STATISTICS_update (GST_stats, |
1634 | gettext_noop ("# ms throttling suggested"), | 1636 | gettext_noop ("# ms throttling suggested"), |
1635 | (int64_t) ret.rel_value, GNUNET_NO); | 1637 | (int64_t) ret.rel_value_us / 1000LL, |
1638 | GNUNET_NO); | ||
1636 | } | 1639 | } |
1637 | return ret; | 1640 | return ret; |
1638 | } | 1641 | } |
@@ -2526,10 +2529,11 @@ master_task (void *cls, | |||
2526 | n->task = GNUNET_SCHEDULER_NO_TASK; | 2529 | n->task = GNUNET_SCHEDULER_NO_TASK; |
2527 | delay = GNUNET_TIME_absolute_get_remaining (n->timeout); | 2530 | delay = GNUNET_TIME_absolute_get_remaining (n->timeout); |
2528 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2531 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2529 | "Master task runs for neighbour `%s' in state %s with timeout in %llu ms\n", | 2532 | "Master task runs for neighbour `%s' in state %s with timeout in %s\n", |
2530 | GNUNET_i2s (&n->id), | 2533 | GNUNET_i2s (&n->id), |
2531 | print_state(n->state), | 2534 | print_state(n->state), |
2532 | (unsigned long long) delay.rel_value); | 2535 | GNUNET_STRINGS_relative_time_to_string (delay, |
2536 | GNUNET_YES)); | ||
2533 | switch (n->state) | 2537 | switch (n->state) |
2534 | { | 2538 | { |
2535 | case S_NOT_CONNECTED: | 2539 | case S_NOT_CONNECTED: |
@@ -2539,7 +2543,7 @@ master_task (void *cls, | |||
2539 | free_neighbour (n, GNUNET_NO); | 2543 | free_neighbour (n, GNUNET_NO); |
2540 | return; | 2544 | return; |
2541 | case S_INIT_ATS: | 2545 | case S_INIT_ATS: |
2542 | if (0 == delay.rel_value) | 2546 | if (0 == delay.rel_value_us) |
2543 | { | 2547 | { |
2544 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2548 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2545 | "Connection to `%s' timed out waiting for ATS to provide address\n", | 2549 | "Connection to `%s' timed out waiting for ATS to provide address\n", |
@@ -2550,7 +2554,7 @@ master_task (void *cls, | |||
2550 | } | 2554 | } |
2551 | break; | 2555 | break; |
2552 | case S_INIT_BLACKLIST: | 2556 | case S_INIT_BLACKLIST: |
2553 | if (0 == delay.rel_value) | 2557 | if (0 == delay.rel_value_us) |
2554 | { | 2558 | { |
2555 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2559 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2556 | "Connection to `%s' timed out waiting for BLACKLIST to approve address\n", | 2560 | "Connection to `%s' timed out waiting for BLACKLIST to approve address\n", |
@@ -2561,7 +2565,7 @@ master_task (void *cls, | |||
2561 | } | 2565 | } |
2562 | break; | 2566 | break; |
2563 | case S_CONNECT_SENT: | 2567 | case S_CONNECT_SENT: |
2564 | if (0 == delay.rel_value) | 2568 | if (0 == delay.rel_value_us) |
2565 | { | 2569 | { |
2566 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2570 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2567 | "Connection to `%s' timed out waiting for other peer to send CONNECT_ACK\n", | 2571 | "Connection to `%s' timed out waiting for other peer to send CONNECT_ACK\n", |
@@ -2571,7 +2575,7 @@ master_task (void *cls, | |||
2571 | } | 2575 | } |
2572 | break; | 2576 | break; |
2573 | case S_CONNECT_RECV_BLACKLIST_INBOUND: | 2577 | case S_CONNECT_RECV_BLACKLIST_INBOUND: |
2574 | if (0 == delay.rel_value) | 2578 | if (0 == delay.rel_value_us) |
2575 | { | 2579 | { |
2576 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2580 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2577 | "Connection to `%s' timed out waiting BLACKLIST to approve address to use for received CONNECT\n", | 2581 | "Connection to `%s' timed out waiting BLACKLIST to approve address to use for received CONNECT\n", |
@@ -2582,7 +2586,7 @@ master_task (void *cls, | |||
2582 | } | 2586 | } |
2583 | break; | 2587 | break; |
2584 | case S_CONNECT_RECV_ATS: | 2588 | case S_CONNECT_RECV_ATS: |
2585 | if (0 == delay.rel_value) | 2589 | if (0 == delay.rel_value_us) |
2586 | { | 2590 | { |
2587 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2591 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2588 | "Connection to `%s' timed out waiting ATS to provide address to use for CONNECT_ACK\n", | 2592 | "Connection to `%s' timed out waiting ATS to provide address to use for CONNECT_ACK\n", |
@@ -2593,7 +2597,7 @@ master_task (void *cls, | |||
2593 | } | 2597 | } |
2594 | break; | 2598 | break; |
2595 | case S_CONNECT_RECV_BLACKLIST: | 2599 | case S_CONNECT_RECV_BLACKLIST: |
2596 | if (0 == delay.rel_value) | 2600 | if (0 == delay.rel_value_us) |
2597 | { | 2601 | { |
2598 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2602 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2599 | "Connection to `%s' timed out waiting BLACKLIST to approve address to use for CONNECT_ACK\n", | 2603 | "Connection to `%s' timed out waiting BLACKLIST to approve address to use for CONNECT_ACK\n", |
@@ -2604,7 +2608,7 @@ master_task (void *cls, | |||
2604 | } | 2608 | } |
2605 | break; | 2609 | break; |
2606 | case S_CONNECT_RECV_ACK: | 2610 | case S_CONNECT_RECV_ACK: |
2607 | if (0 == delay.rel_value) | 2611 | if (0 == delay.rel_value_us) |
2608 | { | 2612 | { |
2609 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2613 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2610 | "Connection to `%s' timed out waiting for other peer to send SESSION_ACK\n", | 2614 | "Connection to `%s' timed out waiting for other peer to send SESSION_ACK\n", |
@@ -2614,7 +2618,7 @@ master_task (void *cls, | |||
2614 | } | 2618 | } |
2615 | break; | 2619 | break; |
2616 | case S_CONNECTED: | 2620 | case S_CONNECTED: |
2617 | if (0 == delay.rel_value) | 2621 | if (0 == delay.rel_value_us) |
2618 | { | 2622 | { |
2619 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2623 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2620 | "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs\n", | 2624 | "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs\n", |
@@ -2626,7 +2630,7 @@ master_task (void *cls, | |||
2626 | send_keepalive (n); | 2630 | send_keepalive (n); |
2627 | break; | 2631 | break; |
2628 | case S_RECONNECT_ATS: | 2632 | case S_RECONNECT_ATS: |
2629 | if (0 == delay.rel_value) | 2633 | if (0 == delay.rel_value_us) |
2630 | { | 2634 | { |
2631 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2635 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2632 | "Connection to `%s' timed out, waiting for ATS replacement address\n", | 2636 | "Connection to `%s' timed out, waiting for ATS replacement address\n", |
@@ -2636,7 +2640,7 @@ master_task (void *cls, | |||
2636 | } | 2640 | } |
2637 | break; | 2641 | break; |
2638 | case S_RECONNECT_BLACKLIST: | 2642 | case S_RECONNECT_BLACKLIST: |
2639 | if (0 == delay.rel_value) | 2643 | if (0 == delay.rel_value_us) |
2640 | { | 2644 | { |
2641 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2645 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2642 | "Connection to `%s' timed out, waiting for BLACKLIST to approve replacement address\n", | 2646 | "Connection to `%s' timed out, waiting for BLACKLIST to approve replacement address\n", |
@@ -2646,7 +2650,7 @@ master_task (void *cls, | |||
2646 | } | 2650 | } |
2647 | break; | 2651 | break; |
2648 | case S_RECONNECT_SENT: | 2652 | case S_RECONNECT_SENT: |
2649 | if (0 == delay.rel_value) | 2653 | if (0 == delay.rel_value_us) |
2650 | { | 2654 | { |
2651 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2655 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2652 | "Connection to `%s' timed out, waiting for other peer to CONNECT_ACK replacement address\n", | 2656 | "Connection to `%s' timed out, waiting for other peer to CONNECT_ACK replacement address\n", |
@@ -2656,7 +2660,7 @@ master_task (void *cls, | |||
2656 | } | 2660 | } |
2657 | break; | 2661 | break; |
2658 | case S_CONNECTED_SWITCHING_BLACKLIST: | 2662 | case S_CONNECTED_SWITCHING_BLACKLIST: |
2659 | if (0 == delay.rel_value) | 2663 | if (0 == delay.rel_value_us) |
2660 | { | 2664 | { |
2661 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2665 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2662 | "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs\n", | 2666 | "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs\n", |
@@ -2668,7 +2672,7 @@ master_task (void *cls, | |||
2668 | send_keepalive (n); | 2672 | send_keepalive (n); |
2669 | break; | 2673 | break; |
2670 | case S_CONNECTED_SWITCHING_CONNECT_SENT: | 2674 | case S_CONNECTED_SWITCHING_CONNECT_SENT: |
2671 | if (0 == delay.rel_value) | 2675 | if (0 == delay.rel_value_us) |
2672 | { | 2676 | { |
2673 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2677 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2674 | "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs (after trying to CONNECT on alternative address)\n", | 2678 | "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs (after trying to CONNECT on alternative address)\n", |
@@ -2785,7 +2789,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | |||
2785 | 1, GNUNET_NO); | 2789 | 1, GNUNET_NO); |
2786 | break; | 2790 | break; |
2787 | case S_CONNECT_SENT: | 2791 | case S_CONNECT_SENT: |
2788 | if (ts.abs_value != n->primary_address.connect_timestamp.abs_value) | 2792 | if (ts.abs_value_us != n->primary_address.connect_timestamp.abs_value_us) |
2789 | break; /* ACK does not match our original CONNECT message */ | 2793 | break; /* ACK does not match our original CONNECT message */ |
2790 | n->state = S_CONNECTED; | 2794 | n->state = S_CONNECTED; |
2791 | n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | 2795 | n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |
@@ -3142,7 +3146,7 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity | |||
3142 | sdm = (const struct SessionDisconnectMessage *) msg; | 3146 | sdm = (const struct SessionDisconnectMessage *) msg; |
3143 | if (NULL == (n = lookup_neighbour (peer))) | 3147 | if (NULL == (n = lookup_neighbour (peer))) |
3144 | return; /* gone already */ | 3148 | return; /* gone already */ |
3145 | if (GNUNET_TIME_absolute_ntoh (sdm->timestamp).abs_value <= n->connect_ack_timestamp.abs_value) | 3149 | if (GNUNET_TIME_absolute_ntoh (sdm->timestamp).abs_value_us <= n->connect_ack_timestamp.abs_value_us) |
3146 | { | 3150 | { |
3147 | GNUNET_STATISTICS_update (GST_stats, | 3151 | GNUNET_STATISTICS_update (GST_stats, |
3148 | gettext_noop | 3152 | gettext_noop |