diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-07-19 12:45:31 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-07-19 12:45:31 +0000 |
commit | c4fc1472add4f2bf819ff16ec96e6306ee998c02 (patch) | |
tree | 804cff9bf3e6a12ee04dfe984f66fd37f4e120a2 /src | |
parent | 1e19a49f164870f536e0ef28357b73cee25441c8 (diff) | |
download | gnunet-c4fc1472add4f2bf819ff16ec96e6306ee998c02.tar.gz gnunet-c4fc1472add4f2bf819ff16ec96e6306ee998c02.zip |
fixing 1732:
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 142 |
1 files changed, 67 insertions, 75 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 88240ff4c..c629efebe 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -1601,7 +1601,7 @@ transmit_send_continuation (void *cls, | |||
1601 | } | 1601 | } |
1602 | else | 1602 | else |
1603 | { | 1603 | { |
1604 | if (mq->specific_address->connected != GNUNET_NO) | 1604 | if (mq->specific_address->connected == GNUNET_YES) |
1605 | { | 1605 | { |
1606 | #if DEBUG_TRANSPORT | 1606 | #if DEBUG_TRANSPORT |
1607 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1607 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1938,12 +1938,10 @@ mark_address_connected(struct ForeignAddressList *fal) | |||
1938 | struct ForeignAddressList *pos; | 1938 | struct ForeignAddressList *pos; |
1939 | struct ForeignAddressList *inbound; | 1939 | struct ForeignAddressList *inbound; |
1940 | struct ForeignAddressList *outbound; | 1940 | struct ForeignAddressList *outbound; |
1941 | int cnt; | ||
1942 | 1941 | ||
1943 | GNUNET_assert (GNUNET_YES == fal->validated); | 1942 | GNUNET_assert (GNUNET_YES == fal->validated); |
1944 | if (fal->connected == GNUNET_YES) | 1943 | if (fal->connected == GNUNET_YES) |
1945 | return; /* nothing to do */ | 1944 | return; /* nothing to do */ |
1946 | cnt = GNUNET_YES; | ||
1947 | inbound = NULL; | 1945 | inbound = NULL; |
1948 | outbound = NULL; | 1946 | outbound = NULL; |
1949 | 1947 | ||
@@ -1951,10 +1949,12 @@ mark_address_connected(struct ForeignAddressList *fal) | |||
1951 | while (pos != NULL) | 1949 | while (pos != NULL) |
1952 | { | 1950 | { |
1953 | /* Already have inbound address, and this is also an inbound address, don't switch!! */ | 1951 | /* Already have inbound address, and this is also an inbound address, don't switch!! */ |
1954 | if ((GNUNET_YES == pos->connected) && (0 == pos->addrlen) && (0 | 1952 | if ( (GNUNET_YES == pos->connected) && |
1955 | == fal->addrlen)) | 1953 | (0 == pos->addrlen) && |
1954 | (0 == fal->addrlen) ) | ||
1956 | return; | 1955 | return; |
1957 | else if ((0 == pos->addrlen) && (GNUNET_YES == pos->connected)) | 1956 | if ( (0 == pos->addrlen) && |
1957 | (GNUNET_YES == pos->connected) ) | ||
1958 | inbound = pos; | 1958 | inbound = pos; |
1959 | pos = pos->next; | 1959 | pos = pos->next; |
1960 | } | 1960 | } |
@@ -1963,10 +1963,11 @@ mark_address_connected(struct ForeignAddressList *fal) | |||
1963 | while (pos != NULL) | 1963 | while (pos != NULL) |
1964 | { | 1964 | { |
1965 | /* Already have outbound address, and this is also an outbound address, don't switch!! */ | 1965 | /* Already have outbound address, and this is also an outbound address, don't switch!! */ |
1966 | if ((GNUNET_YES == pos->connected) && (0 < pos->addrlen) && (0 | 1966 | if ( (GNUNET_YES == pos->connected) && |
1967 | < fal->addrlen)) | 1967 | (0 < pos->addrlen) && |
1968 | (0 < fal->addrlen) ) | ||
1968 | return; | 1969 | return; |
1969 | else if ((0 < pos->addrlen) && (GNUNET_YES == pos->connected)) | 1970 | if ( (0 < pos->addrlen) && (GNUNET_YES == pos->connected) ) |
1970 | outbound = pos; | 1971 | outbound = pos; |
1971 | pos = pos->next; | 1972 | pos = pos->next; |
1972 | } | 1973 | } |
@@ -2004,16 +2005,16 @@ mark_address_connected(struct ForeignAddressList *fal) | |||
2004 | if ((GNUNET_YES == pos->connected) && (0 < pos->addrlen)) | 2005 | if ((GNUNET_YES == pos->connected) && (0 < pos->addrlen)) |
2005 | { | 2006 | { |
2006 | #if DEBUG_TRANSPORT | 2007 | #if DEBUG_TRANSPORT |
2007 | GNUNET_log ( | 2008 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2008 | GNUNET_ERROR_TYPE_DEBUG, | ||
2009 | "Marking address `%s' as no longer connected (due to connect on other address)\n", | 2009 | "Marking address `%s' as no longer connected (due to connect on other address)\n", |
2010 | a2s (pos->ready_list->plugin->short_name, pos->addr, | 2010 | a2s (pos->ready_list->plugin->short_name, pos->addr, |
2011 | pos->addrlen)); | 2011 | pos->addrlen)); |
2012 | #endif | 2012 | #endif |
2013 | GNUNET_break (cnt == GNUNET_YES); | ||
2014 | cnt = GNUNET_NO; | ||
2015 | #if DEBUG_INBOUND | 2013 | #if DEBUG_INBOUND |
2016 | fprintf(stderr, "Peer: %s, setting %s connection to disconnected.\n", GNUNET_i2s(&my_identity), (0 == pos->addrlen) ? "INBOUND" : "OUTBOUND"); | 2014 | fprintf(stderr, |
2015 | "Peer: %s, setting %s connection to disconnected.\n", | ||
2016 | GNUNET_i2s(&my_identity), | ||
2017 | (0 == pos->addrlen) ? "INBOUND" : "OUTBOUND"); | ||
2017 | #endif | 2018 | #endif |
2018 | pos->connected = GNUNET_NO; | 2019 | pos->connected = GNUNET_NO; |
2019 | GNUNET_STATISTICS_update (stats, | 2020 | GNUNET_STATISTICS_update (stats, |
@@ -2022,13 +2023,10 @@ mark_address_connected(struct ForeignAddressList *fal) | |||
2022 | } | 2023 | } |
2023 | pos = pos->next; | 2024 | pos = pos->next; |
2024 | } | 2025 | } |
2025 | 2026 | GNUNET_assert (GNUNET_NO == fal->connected); | |
2026 | fal->connected = GNUNET_YES; | 2027 | fal->connected = GNUNET_YES; |
2027 | if (GNUNET_YES == cnt) | 2028 | GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), |
2028 | { | 2029 | 1, GNUNET_NO); |
2029 | GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), | ||
2030 | 1, GNUNET_NO); | ||
2031 | } | ||
2032 | } | 2030 | } |
2033 | 2031 | ||
2034 | 2032 | ||
@@ -2462,7 +2460,14 @@ plugin_env_session_end (void *cls, | |||
2462 | return; /* was never marked as connected */ | 2460 | return; /* was never marked as connected */ |
2463 | } | 2461 | } |
2464 | pos->session = NULL; | 2462 | pos->session = NULL; |
2465 | pos->connected = GNUNET_NO; | 2463 | if (GNUNET_YES == pos->connected) |
2464 | { | ||
2465 | pos->connected = GNUNET_NO; | ||
2466 | GNUNET_STATISTICS_update (stats, | ||
2467 | gettext_noop ("# connected addresses"), | ||
2468 | -1, | ||
2469 | GNUNET_NO); | ||
2470 | } | ||
2466 | if (GNUNET_SCHEDULER_NO_TASK != pos->revalidate_task) | 2471 | if (GNUNET_SCHEDULER_NO_TASK != pos->revalidate_task) |
2467 | { | 2472 | { |
2468 | GNUNET_SCHEDULER_cancel (pos->revalidate_task); | 2473 | GNUNET_SCHEDULER_cancel (pos->revalidate_task); |
@@ -2493,11 +2498,6 @@ plugin_env_session_end (void *cls, | |||
2493 | return; | 2498 | return; |
2494 | } | 2499 | } |
2495 | 2500 | ||
2496 | GNUNET_STATISTICS_update (stats, | ||
2497 | gettext_noop ("# connected addresses"), | ||
2498 | -1, | ||
2499 | GNUNET_NO); | ||
2500 | |||
2501 | /* was inbound connection, free 'pos' */ | 2501 | /* was inbound connection, free 'pos' */ |
2502 | if (prev == NULL) | 2502 | if (prev == NULL) |
2503 | rl->addresses = pos->next; | 2503 | rl->addresses = pos->next; |
@@ -4907,10 +4907,13 @@ disconnect_neighbour (struct NeighbourList *n, int check) | |||
4907 | peer_pos = rpos->addresses; | 4907 | peer_pos = rpos->addresses; |
4908 | rpos->addresses = peer_pos->next; | 4908 | rpos->addresses = peer_pos->next; |
4909 | if (peer_pos->connected == GNUNET_YES) | 4909 | if (peer_pos->connected == GNUNET_YES) |
4910 | GNUNET_STATISTICS_update (stats, | 4910 | { |
4911 | gettext_noop ("# connected addresses"), | 4911 | GNUNET_STATISTICS_update (stats, |
4912 | -1, | 4912 | gettext_noop ("# connected addresses"), |
4913 | GNUNET_NO); | 4913 | -1, |
4914 | GNUNET_NO); | ||
4915 | peer_pos->connected = GNUNET_NO; | ||
4916 | } | ||
4914 | if (GNUNET_YES == peer_pos->validated) | 4917 | if (GNUNET_YES == peer_pos->validated) |
4915 | GNUNET_STATISTICS_update (stats, | 4918 | GNUNET_STATISTICS_update (stats, |
4916 | gettext_noop ("# peer addresses considered valid"), | 4919 | gettext_noop ("# peer addresses considered valid"), |
@@ -6378,8 +6381,6 @@ create_ats_information ( struct ATS_peer **p, | |||
6378 | #endif | 6381 | #endif |
6379 | struct ATS_mechanism * mechanisms; | 6382 | struct ATS_mechanism * mechanisms; |
6380 | struct ATS_peer *peers; | 6383 | struct ATS_peer *peers; |
6381 | |||
6382 | int connected_addresses = 0; | ||
6383 | int c_peers = 0; | 6384 | int c_peers = 0; |
6384 | int c_mechs = 0; | 6385 | int c_mechs = 0; |
6385 | struct NeighbourList *next = neighbours; | 6386 | struct NeighbourList *next = neighbours; |
@@ -6425,59 +6426,50 @@ create_ats_information ( struct ATS_peer **p, | |||
6425 | 6426 | ||
6426 | next = neighbours; | 6427 | next = neighbours; |
6427 | while (next!=NULL) | 6428 | while (next!=NULL) |
6428 | { | ||
6429 | int found_addresses = GNUNET_NO; | ||
6430 | struct ReadyList *r_next = next->plugins; | ||
6431 | while (r_next != NULL) | ||
6432 | { | 6429 | { |
6433 | struct ForeignAddressList * a_next = r_next->addresses; | 6430 | int found_addresses = GNUNET_NO; |
6434 | while (a_next != NULL) | 6431 | struct ReadyList *r_next = next->plugins; |
6435 | { | 6432 | while (r_next != NULL) |
6436 | if (a_next->connected == GNUNET_YES) | 6433 | { |
6437 | connected_addresses ++; | 6434 | struct ForeignAddressList * a_next = r_next->addresses; |
6438 | if (found_addresses == GNUNET_NO) | 6435 | while (a_next != NULL) |
6439 | { | 6436 | { |
6440 | peers[c_peers].peer = next->id; | 6437 | if (found_addresses == GNUNET_NO) |
6441 | peers[c_peers].m_head = NULL; | 6438 | { |
6442 | peers[c_peers].m_tail = NULL; | 6439 | peers[c_peers].peer = next->id; |
6443 | peers[c_peers].f = 1.0 / c_mechs; | 6440 | peers[c_peers].m_head = NULL; |
6444 | } | 6441 | peers[c_peers].m_tail = NULL; |
6445 | 6442 | peers[c_peers].f = 1.0 / c_mechs; | |
6446 | mechanisms[c_mechs].addr = a_next; | 6443 | } |
6447 | mechanisms[c_mechs].col_index = c_mechs; | 6444 | mechanisms[c_mechs].addr = a_next; |
6448 | mechanisms[c_mechs].peer = &peers[c_peers]; | 6445 | mechanisms[c_mechs].col_index = c_mechs; |
6449 | mechanisms[c_mechs].next = NULL; | 6446 | mechanisms[c_mechs].peer = &peers[c_peers]; |
6450 | mechanisms[c_mechs].plugin = r_next->plugin; | 6447 | mechanisms[c_mechs].next = NULL; |
6451 | mechanisms[c_mechs].ressources = a_next->ressources; | 6448 | mechanisms[c_mechs].plugin = r_next->plugin; |
6452 | mechanisms[c_mechs].quality = a_next->quality; | 6449 | mechanisms[c_mechs].ressources = a_next->ressources; |
6453 | 6450 | mechanisms[c_mechs].quality = a_next->quality; | |
6454 | GNUNET_CONTAINER_DLL_insert_tail(peers[c_peers].m_head, | 6451 | GNUNET_CONTAINER_DLL_insert_tail(peers[c_peers].m_head, |
6455 | peers[c_peers].m_tail, | 6452 | peers[c_peers].m_tail, |
6456 | &mechanisms[c_mechs]); | 6453 | &mechanisms[c_mechs]); |
6457 | found_addresses = GNUNET_YES; | 6454 | found_addresses = GNUNET_YES; |
6458 | c_mechs++; | 6455 | c_mechs++; |
6459 | 6456 | a_next = a_next->next; | |
6460 | a_next = a_next->next; | 6457 | } |
6461 | } | 6458 | r_next = r_next->next; |
6462 | r_next = r_next->next; | 6459 | } |
6463 | } | 6460 | if (found_addresses == GNUNET_YES) |
6464 | if (found_addresses == GNUNET_YES) | ||
6465 | c_peers++; | 6461 | c_peers++; |
6466 | next = next->next; | 6462 | next = next->next; |
6467 | } | 6463 | } |
6468 | c_mechs--; | 6464 | c_mechs--; |
6469 | c_peers--; | 6465 | c_peers--; |
6470 | (*c_m) = c_mechs; | 6466 | (*c_m) = c_mechs; |
6471 | (*c_p) = c_peers; | 6467 | (*c_p) = c_peers; |
6472 | (*p) = peers; | 6468 | (*p) = peers; |
6473 | (*m) = mechanisms; | 6469 | (*m) = mechanisms; |
6474 | |||
6475 | GNUNET_STATISTICS_set(stats, | ||
6476 | gettext_noop ("# connected addresses"), | ||
6477 | connected_addresses, | ||
6478 | GNUNET_NO); | ||
6479 | } | 6470 | } |
6480 | 6471 | ||
6472 | |||
6481 | static void | 6473 | static void |
6482 | schedule_ats (void *cls, | 6474 | schedule_ats (void *cls, |
6483 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 6475 | const struct GNUNET_SCHEDULER_TaskContext *tc) |