diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-11-11 16:41:00 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-11-11 16:41:00 +0000 |
commit | e2199a0502c03f679b2d4ebf07067235a54d3483 (patch) | |
tree | 61af05d4c63b5d14667b8bf8a773c029e231cbab | |
parent | 91c4da14bcfa26a9a077d07fb9063d4460ae095e (diff) | |
download | gnunet-e2199a0502c03f679b2d4ebf07067235a54d3483.tar.gz gnunet-e2199a0502c03f679b2d4ebf07067235a54d3483.zip |
ATS address updatign and deletion
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index f2cc3b4fd..b01c82d55 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -450,25 +450,28 @@ change (struct NeighbourMapEntry *n, int state, int line); | |||
450 | static void | 450 | static void |
451 | ats_suggest_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 451 | ats_suggest_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); |
452 | 452 | ||
453 | |||
453 | static void | 454 | static void |
454 | reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 455 | reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
455 | { | 456 | { |
456 | struct NeighbourMapEntry *n = cls; | 457 | struct NeighbourMapEntry *n = cls; |
457 | 458 | ||
458 | n->state_reset = GNUNET_SCHEDULER_NO_TASK; | 459 | n->state_reset = GNUNET_SCHEDULER_NO_TASK; |
460 | if (n->state == S_CONNECTED) | ||
461 | return; | ||
459 | 462 | ||
460 | #if DEBUG_TRANSPORT | 463 | #if DEBUG_TRANSPORT |
461 | #endif | ||
462 | |||
463 | GNUNET_STATISTICS_update (GST_stats, | 464 | GNUNET_STATISTICS_update (GST_stats, |
464 | gettext_noop | 465 | gettext_noop |
465 | ("# failed connection attempts due to timeout"), 1, | 466 | ("# failed connection attempts due to timeout"), 1, |
466 | GNUNET_NO); | 467 | GNUNET_NO); |
468 | #endif | ||
467 | 469 | ||
468 | /* resetting state */ | 470 | /* resetting state */ |
469 | n->state = S_NOT_CONNECTED; | 471 | n->state = S_NOT_CONNECTED; |
470 | 472 | ||
471 | /* destroying address */ | 473 | /* destroying address */ |
474 | |||
472 | GNUNET_ATS_address_destroyed (GST_ats, n->address, n->session); | 475 | GNUNET_ATS_address_destroyed (GST_ats, n->address, n->session); |
473 | 476 | ||
474 | /* request new address */ | 477 | /* request new address */ |
@@ -1139,8 +1142,7 @@ send_connect_continuation (void *cls, const struct GNUNET_PeerIdentity *target, | |||
1139 | struct NeighbourMapEntry *n = lookup_neighbour (&cc->address->peer); | 1142 | struct NeighbourMapEntry *n = lookup_neighbour (&cc->address->peer); |
1140 | 1143 | ||
1141 | if (GNUNET_YES != success) | 1144 | if (GNUNET_YES != success) |
1142 | GNUNET_ATS_address_destroyed (GST_ats, cc->address, NULL); | 1145 | GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session); |
1143 | //GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session); | ||
1144 | if ( (NULL == neighbours) || | 1146 | if ( (NULL == neighbours) || |
1145 | (NULL == n) || | 1147 | (NULL == n) || |
1146 | (n->state == S_DISCONNECT)) | 1148 | (n->state == S_DISCONNECT)) |
@@ -1170,8 +1172,8 @@ send_connect_continuation (void *cls, const struct GNUNET_PeerIdentity *target, | |||
1170 | n->session); | 1172 | n->session); |
1171 | #endif | 1173 | #endif |
1172 | change_state (n, S_NOT_CONNECTED); | 1174 | change_state (n, S_NOT_CONNECTED); |
1173 | GNUNET_ATS_address_destroyed (GST_ats, cc->address, NULL); | 1175 | |
1174 | //GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session); | 1176 | GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session); |
1175 | 1177 | ||
1176 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) | 1178 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) |
1177 | GNUNET_SCHEDULER_cancel (n->ats_suggest); | 1179 | GNUNET_SCHEDULER_cancel (n->ats_suggest); |
@@ -1223,8 +1225,7 @@ send_switch_address_continuation (void *cls, | |||
1223 | GNUNET_i2s (&n->id), | 1225 | GNUNET_i2s (&n->id), |
1224 | GST_plugins_a2s (n->address), n->session); | 1226 | GST_plugins_a2s (n->address), n->session); |
1225 | #endif | 1227 | #endif |
1226 | GNUNET_ATS_address_destroyed (GST_ats, cc->address, NULL); | 1228 | GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session); |
1227 | //GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session); | ||
1228 | 1229 | ||
1229 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) | 1230 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) |
1230 | GNUNET_SCHEDULER_cancel (n->ats_suggest); | 1231 | GNUNET_SCHEDULER_cancel (n->ats_suggest); |
@@ -1245,6 +1246,7 @@ send_switch_address_continuation (void *cls, | |||
1245 | cc->address, | 1246 | cc->address, |
1246 | cc->session, | 1247 | cc->session, |
1247 | GNUNET_YES); | 1248 | GNUNET_YES); |
1249 | GNUNET_ATS_address_update (GST_ats, cc->address, cc->session, NULL, 0); | ||
1248 | GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, GNUNET_YES); | 1250 | GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, GNUNET_YES); |
1249 | n->address_state = USED; | 1251 | n->address_state = USED; |
1250 | } | 1252 | } |
@@ -1265,6 +1267,7 @@ send_switch_address_continuation (void *cls, | |||
1265 | cc->address, | 1267 | cc->address, |
1266 | cc->session, | 1268 | cc->session, |
1267 | GNUNET_YES); | 1269 | GNUNET_YES); |
1270 | GNUNET_ATS_address_update (GST_ats, cc->address, cc->session, NULL, 0); | ||
1268 | GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, GNUNET_YES); | 1271 | GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, GNUNET_YES); |
1269 | n->address_state = USED; | 1272 | n->address_state = USED; |
1270 | } | 1273 | } |
@@ -1331,8 +1334,7 @@ send_connect_ack_continuation (void *cls, | |||
1331 | #endif | 1334 | #endif |
1332 | change_state (n, S_NOT_CONNECTED); | 1335 | change_state (n, S_NOT_CONNECTED); |
1333 | 1336 | ||
1334 | GNUNET_ATS_address_destroyed (GST_ats, cc->address, NULL); | 1337 | GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session); |
1335 | //GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session); | ||
1336 | 1338 | ||
1337 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) | 1339 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) |
1338 | GNUNET_SCHEDULER_cancel (n->ats_suggest); | 1340 | GNUNET_SCHEDULER_cancel (n->ats_suggest); |
@@ -1693,9 +1695,6 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
1693 | } | 1695 | } |
1694 | } | 1696 | } |
1695 | 1697 | ||
1696 | |||
1697 | //GNUNET_ATS_address_destroyed(GST_ats, n->address, n->session); | ||
1698 | |||
1699 | if (NULL != n->address) | 1698 | if (NULL != n->address) |
1700 | { | 1699 | { |
1701 | GNUNET_HELLO_address_free (n->address); | 1700 | GNUNET_HELLO_address_free (n->address); |
@@ -1704,7 +1703,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
1704 | n->session = NULL; | 1703 | n->session = NULL; |
1705 | 1704 | ||
1706 | /* not connected anymore anyway, shouldn't matter */ | 1705 | /* not connected anymore anyway, shouldn't matter */ |
1707 | if ((S_CONNECTED != n->state) && (!is_connecting (n))) | 1706 | if (S_CONNECTED != n->state) |
1708 | return; | 1707 | return; |
1709 | 1708 | ||
1710 | /* connected, try fast reconnect */ | 1709 | /* connected, try fast reconnect */ |
@@ -2011,7 +2010,9 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour, | |||
2011 | 2010 | ||
2012 | 2011 | ||
2013 | if (n->latency.rel_value == GNUNET_TIME_relative_get_forever().rel_value) | 2012 | if (n->latency.rel_value == GNUNET_TIME_relative_get_forever().rel_value) |
2013 | { | ||
2014 | GNUNET_ATS_address_update (GST_ats, n->address, n->session, ats, ats_count); | 2014 | GNUNET_ATS_address_update (GST_ats, n->address, n->session, ats, ats_count); |
2015 | } | ||
2015 | else | 2016 | else |
2016 | { | 2017 | { |
2017 | ats_new = GNUNET_malloc (sizeof (struct GNUNET_ATS_Information) * (ats_count + 1)); | 2018 | ats_new = GNUNET_malloc (sizeof (struct GNUNET_ATS_Information) * (ats_count + 1)); |
@@ -2297,15 +2298,17 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | |||
2297 | return; | 2298 | return; |
2298 | } | 2299 | } |
2299 | 2300 | ||
2301 | change_state (n, S_CONNECTED); | ||
2302 | |||
2300 | if (NULL != session) | 2303 | if (NULL != session) |
2304 | { | ||
2301 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 2305 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
2302 | "transport-ats", | 2306 | "transport-ats", |
2303 | "Giving ATS session %p of plugin %s for peer %s\n", | 2307 | "Giving ATS session %p of plugin %s for peer %s\n", |
2304 | session, address->transport_name, GNUNET_i2s (peer)); | 2308 | session, address->transport_name, GNUNET_i2s (peer)); |
2309 | } | ||
2305 | GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count); | 2310 | GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count); |
2306 | GNUNET_assert (NULL != n->address); | 2311 | GNUNET_assert (NULL != n->address); |
2307 | |||
2308 | change_state (n, S_CONNECTED); | ||
2309 | if (n->address_state == FRESH) | 2312 | if (n->address_state == FRESH) |
2310 | { | 2313 | { |
2311 | GST_validation_set_address_use (&n->id, | 2314 | GST_validation_set_address_use (&n->id, |
@@ -2392,6 +2395,7 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | |||
2392 | GNUNET_NO); | 2395 | GNUNET_NO); |
2393 | return; | 2396 | return; |
2394 | } | 2397 | } |
2398 | change_state (n, S_CONNECTED); | ||
2395 | if (NULL != session) | 2399 | if (NULL != session) |
2396 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 2400 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
2397 | "transport-ats", | 2401 | "transport-ats", |
@@ -2399,11 +2403,6 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | |||
2399 | session, address->transport_name, GNUNET_i2s (peer)); | 2403 | session, address->transport_name, GNUNET_i2s (peer)); |
2400 | GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count); | 2404 | GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count); |
2401 | GNUNET_assert (n->address != NULL); | 2405 | GNUNET_assert (n->address != NULL); |
2402 | change_state (n, S_CONNECTED); | ||
2403 | |||
2404 | GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in); | ||
2405 | if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK) | ||
2406 | n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n); | ||
2407 | if (n->address_state == FRESH) | 2406 | if (n->address_state == FRESH) |
2408 | { | 2407 | { |
2409 | GST_validation_set_address_use (&n->id, | 2408 | GST_validation_set_address_use (&n->id, |
@@ -2413,10 +2412,14 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | |||
2413 | GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES); | 2412 | GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES); |
2414 | n->address_state = USED; | 2413 | n->address_state = USED; |
2415 | } | 2414 | } |
2415 | |||
2416 | neighbours_connected++; | 2416 | neighbours_connected++; |
2417 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, | 2417 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, |
2418 | GNUNET_NO); | 2418 | GNUNET_NO); |
2419 | 2419 | ||
2420 | GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in); | ||
2421 | if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK) | ||
2422 | n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n); | ||
2420 | #if DEBUG_TRANSPORT | 2423 | #if DEBUG_TRANSPORT |
2421 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2422 | "Notify about connect of `%4s' using address '%s' session %X LINE %u\n", | 2425 | "Notify about connect of `%4s' using address '%s' session %X LINE %u\n", |
@@ -2478,8 +2481,13 @@ handle_connect_blacklist_cont (void *cls, | |||
2478 | bcc->session, | 2481 | bcc->session, |
2479 | GST_plugins_a2s (bcc->address), | 2482 | GST_plugins_a2s (bcc->address), |
2480 | GNUNET_i2s (peer)); | 2483 | GNUNET_i2s (peer)); |
2481 | GNUNET_ATS_address_update (GST_ats, bcc->address, | 2484 | /* Tell ATS about the session, so ATS can suggest it if it likes it. */ |
2482 | bcc->session, bcc->ats, bcc->ats_count); | 2485 | |
2486 | GNUNET_ATS_address_update (GST_ats, | ||
2487 | bcc->address, | ||
2488 | bcc->session, | ||
2489 | bcc->ats, | ||
2490 | bcc->ats_count); | ||
2483 | n->connect_ts = bcc->ts; | 2491 | n->connect_ts = bcc->ts; |
2484 | } | 2492 | } |
2485 | 2493 | ||