diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-05-21 09:28:03 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-05-21 09:28:03 +0000 |
commit | f18f70cac7c127db77d3eff6b785714cc8498bb3 (patch) | |
tree | 68a81c8c8531e71c3bfc6cbf49e63d9142dd9990 /src | |
parent | cb8d8079b402d69f1fa92ccdb5242e117493e174 (diff) | |
download | gnunet-f18f70cac7c127db77d3eff6b785714cc8498bb3.tar.gz gnunet-f18f70cac7c127db77d3eff6b785714cc8498bb3.zip |
fix for address switching when both peers switch at about the same time and an additional SESSION_ACK is received
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 16826e957..19a4abc8a 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -2338,7 +2338,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, | |||
2338 | n->ack_state = ACK_SEND_CONNECT_ACK; | 2338 | n->ack_state = ACK_SEND_CONNECT_ACK; |
2339 | n->connect_ack_timestamp = ts; | 2339 | n->connect_ack_timestamp = ts; |
2340 | 2340 | ||
2341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2341 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
2342 | "Received CONNECT for peer `%s' in state %s/%s\n", | 2342 | "Received CONNECT for peer `%s' in state %s/%s\n", |
2343 | GNUNET_i2s (peer), | 2343 | GNUNET_i2s (peer), |
2344 | GNUNET_TRANSPORT_ps2s (n->state), | 2344 | GNUNET_TRANSPORT_ps2s (n->state), |
@@ -3202,6 +3202,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | |||
3202 | n->alternative_address.session, n->alternative_address.bandwidth_in, | 3202 | n->alternative_address.session, n->alternative_address.bandwidth_in, |
3203 | n->alternative_address.bandwidth_out, GNUNET_YES); | 3203 | n->alternative_address.bandwidth_out, GNUNET_YES); |
3204 | 3204 | ||
3205 | GNUNET_break (0); | ||
3205 | GNUNET_STATISTICS_update (GST_stats, gettext_noop | 3206 | GNUNET_STATISTICS_update (GST_stats, gettext_noop |
3206 | ("# Successful attempts to switch addresses"), 1, GNUNET_NO); | 3207 | ("# Successful attempts to switch addresses"), 1, GNUNET_NO); |
3207 | 3208 | ||
@@ -3389,7 +3390,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
3389 | { | 3390 | { |
3390 | struct NeighbourMapEntry *n; | 3391 | struct NeighbourMapEntry *n; |
3391 | 3392 | ||
3392 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 3393 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3393 | "Received SESSION_ACK message from peer `%s'\n", | 3394 | "Received SESSION_ACK message from peer `%s'\n", |
3394 | GNUNET_i2s (peer)); | 3395 | GNUNET_i2s (peer)); |
3395 | if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader)) | 3396 | if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader)) |
@@ -3406,6 +3407,14 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
3406 | GNUNET_break_op (0); | 3407 | GNUNET_break_op (0); |
3407 | return GNUNET_SYSERR; | 3408 | return GNUNET_SYSERR; |
3408 | } | 3409 | } |
3410 | |||
3411 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
3412 | "Received %s for peer `%s' in state %s/%s\n", | ||
3413 | "SESSION_ACK", | ||
3414 | GNUNET_i2s (peer), | ||
3415 | GNUNET_TRANSPORT_ps2s (n->state), | ||
3416 | print_ack_state (n->ack_state)); | ||
3417 | |||
3409 | /* Check if we are in a plausible state for having sent | 3418 | /* Check if we are in a plausible state for having sent |
3410 | a CONNECT_ACK. If not, return, otherwise break. | 3419 | a CONNECT_ACK. If not, return, otherwise break. |
3411 | 3420 | ||
@@ -3446,8 +3455,16 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
3446 | GNUNET_NO); | 3455 | GNUNET_NO); |
3447 | } | 3456 | } |
3448 | 3457 | ||
3458 | if (GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT == n->state) | ||
3459 | { | ||
3460 | /* We tried to switch addresses while being connect. We explicitly wait | ||
3461 | * for a CONNECT_ACK before going to GNUNET_TRANSPORT_PS_CONNECTED, | ||
3462 | * so we do not want to set the address as in use! */ | ||
3463 | return GNUNET_OK; | ||
3464 | } | ||
3465 | |||
3449 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, | 3466 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, |
3450 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT)); | 3467 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT)); |
3451 | 3468 | ||
3452 | /* Add session to ATS since no session was given (NULL) and we may have | 3469 | /* Add session to ATS since no session was given (NULL) and we may have |
3453 | * obtained a new session */ | 3470 | * obtained a new session */ |