diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-02-17 11:11:39 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-02-17 11:11:39 +0000 |
commit | f99467164edfb1d0b30843b60e320a3cb8991698 (patch) | |
tree | 6f426d73428b8c0f542a0dda25a6637c5b920eed /src/transport | |
parent | d509bb66653383b4876cb1cb736047b5f84e10ce (diff) | |
download | gnunet-f99467164edfb1d0b30843b60e320a3cb8991698.tar.gz gnunet-f99467164edfb1d0b30843b60e320a3cb8991698.zip |
- fix for FAST_RECONNECT related timeout issue
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 7dfe5b25a..181817602 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -57,7 +57,7 @@ | |||
57 | #define KEEPALIVE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 57 | #define KEEPALIVE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
58 | 58 | ||
59 | 59 | ||
60 | #define ATS_RESPONSE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) | 60 | #define ATS_RESPONSE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) |
61 | 61 | ||
62 | #define FAST_RECONNECT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) | 62 | #define FAST_RECONNECT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) |
63 | 63 | ||
@@ -393,6 +393,14 @@ lookup_neighbour (const struct GNUNET_PeerIdentity *pid) | |||
393 | return GNUNET_CONTAINER_multihashmap_get (neighbours, &pid->hashPubKey); | 393 | return GNUNET_CONTAINER_multihashmap_get (neighbours, &pid->hashPubKey); |
394 | } | 394 | } |
395 | 395 | ||
396 | /** | ||
397 | * Disconnect from the given neighbour, clean up the record. | ||
398 | * | ||
399 | * @param n neighbour to disconnect from | ||
400 | */ | ||
401 | static void | ||
402 | disconnect_neighbour (struct NeighbourMapEntry *n); | ||
403 | |||
396 | #define change_state(n, state, ...) change (n, state, __LINE__) | 404 | #define change_state(n, state, ...) change (n, state, __LINE__) |
397 | 405 | ||
398 | static int | 406 | static int |
@@ -476,7 +484,22 @@ reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
476 | #endif | 484 | #endif |
477 | 485 | ||
478 | /* resetting state */ | 486 | /* resetting state */ |
487 | |||
488 | if (n->state == S_FAST_RECONNECT) | ||
489 | { | ||
490 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
491 | "Fast reconnect time out, disconnecting peer `%s'\n", | ||
492 | GNUNET_i2s (&n->id)); | ||
493 | disconnect_neighbour(n); | ||
494 | return; | ||
495 | } | ||
496 | |||
497 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
498 | "State for neighbour `%s' %X changed from `%s' to `%s' in line %u\n", | ||
499 | GNUNET_i2s (&n->id), n, print_state(n->state), "S_NOT_CONNECTED", __LINE__); | ||
500 | |||
479 | n->state = S_NOT_CONNECTED; | 501 | n->state = S_NOT_CONNECTED; |
502 | GNUNET_break (0); | ||
480 | 503 | ||
481 | /* destroying address */ | 504 | /* destroying address */ |
482 | if (n->address != NULL) | 505 | if (n->address != NULL) |
@@ -543,7 +566,6 @@ change (struct NeighbourMapEntry *n, int state, int line) | |||
543 | GNUNET_free (new); | 566 | GNUNET_free (new); |
544 | return GNUNET_SYSERR; | 567 | return GNUNET_SYSERR; |
545 | } | 568 | } |
546 | #if DEBUG_TRANSPORT | ||
547 | { | 569 | { |
548 | char *old = GNUNET_strdup (print_state (n->state)); | 570 | char *old = GNUNET_strdup (print_state (n->state)); |
549 | char *new = GNUNET_strdup (print_state (state)); | 571 | char *new = GNUNET_strdup (print_state (state)); |
@@ -554,7 +576,6 @@ change (struct NeighbourMapEntry *n, int state, int line) | |||
554 | GNUNET_free (old); | 576 | GNUNET_free (old); |
555 | GNUNET_free (new); | 577 | GNUNET_free (new); |
556 | } | 578 | } |
557 | #endif | ||
558 | n->state = state; | 579 | n->state = state; |
559 | 580 | ||
560 | switch (n->state) | 581 | switch (n->state) |
@@ -1079,7 +1100,7 @@ ats_suggest_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1079 | 1100 | ||
1080 | n->ats_suggest = GNUNET_SCHEDULER_NO_TASK; | 1101 | n->ats_suggest = GNUNET_SCHEDULER_NO_TASK; |
1081 | 1102 | ||
1082 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1103 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1083 | "ATS did not suggested address to connect to peer `%s'\n", | 1104 | "ATS did not suggested address to connect to peer `%s'\n", |
1084 | GNUNET_i2s (&n->id)); | 1105 | GNUNET_i2s (&n->id)); |
1085 | 1106 | ||
@@ -1424,6 +1445,17 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, | |||
1424 | n->ats_suggest = GNUNET_SCHEDULER_NO_TASK; | 1445 | n->ats_suggest = GNUNET_SCHEDULER_NO_TASK; |
1425 | } | 1446 | } |
1426 | /* do not switch addresses just update quotas */ | 1447 | /* do not switch addresses just update quotas */ |
1448 | /* | ||
1449 | if (n->state == S_FAST_RECONNECT) | ||
1450 | { | ||
1451 | if (0 == GNUNET_HELLO_address_cmp(address, n->address)) | ||
1452 | { | ||
1453 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1454 | "FAST RECONNECT to peer `%s' and address '%s' with identical ADDRESS\n", | ||
1455 | GNUNET_i2s (&n->id), GST_plugins_a2s (n->address)); | ||
1456 | } | ||
1457 | } | ||
1458 | */ | ||
1427 | if ((n->state == S_CONNECTED) && (NULL != n->address) && | 1459 | if ((n->state == S_CONNECTED) && (NULL != n->address) && |
1428 | (0 == GNUNET_HELLO_address_cmp (address, n->address)) && | 1460 | (0 == GNUNET_HELLO_address_cmp (address, n->address)) && |
1429 | (n->session == session)) | 1461 | (n->session == session)) |
@@ -1783,10 +1815,10 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
1783 | * neighbours_connected -= 1 | 1815 | * neighbours_connected -= 1 |
1784 | * BUT: no disconnect_cb to notify clients about disconnect | 1816 | * BUT: no disconnect_cb to notify clients about disconnect |
1785 | */ | 1817 | */ |
1786 | #if DEBUG_TRANSPORT | 1818 | |
1787 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying fast reconnect to peer `%s'\n", | 1819 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying fast reconnect to peer `%s'\n", |
1788 | GNUNET_i2s (peer)); | 1820 | GNUNET_i2s (peer)); |
1789 | #endif | 1821 | |
1790 | GNUNET_assert (neighbours_connected > 0); | 1822 | GNUNET_assert (neighbours_connected > 0); |
1791 | change_state (n, S_FAST_RECONNECT); | 1823 | change_state (n, S_FAST_RECONNECT); |
1792 | neighbours_connected--; | 1824 | neighbours_connected--; |