diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-09 11:53:04 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-09 11:53:04 +0000 |
commit | 48394cb1b3140ffad691ed0da9f3a541c0e00b28 (patch) | |
tree | 8d4a86763ec6a28532bc0a25e8ad399fe73889a4 /src/transport | |
parent | ea4b4d075258f385b3ffdc9976bf978802691e1d (diff) | |
download | gnunet-48394cb1b3140ffad691ed0da9f3a541c0e00b28.tar.gz gnunet-48394cb1b3140ffad691ed0da9f3a541c0e00b28.zip |
assertions and minor cleanup
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 55 |
1 files changed, 24 insertions, 31 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 332260e40..0cf6656eb 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -819,10 +819,12 @@ static void | |||
819 | disconnect_neighbour (struct NeighbourMapEntry *n) | 819 | disconnect_neighbour (struct NeighbourMapEntry *n) |
820 | { | 820 | { |
821 | struct MessageQueue *mq; | 821 | struct MessageQueue *mq; |
822 | int was_connected = is_connected (n); | 822 | int is_connected; |
823 | |||
824 | is_connected = (n->state == S_CONNECTED); | ||
823 | 825 | ||
824 | /* send DISCONNECT MESSAGE */ | 826 | /* send DISCONNECT MESSAGE */ |
825 | if (is_connected (n) || is_connecting (n)) | 827 | if (is_connected || is_connecting (n)) |
826 | { | 828 | { |
827 | if (GNUNET_OK == | 829 | if (GNUNET_OK == |
828 | send_disconnect (&n->id, n->address, | 830 | send_disconnect (&n->id, n->address, |
@@ -835,7 +837,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n) | |||
835 | GNUNET_i2s (&n->id)); | 837 | GNUNET_i2s (&n->id)); |
836 | } | 838 | } |
837 | 839 | ||
838 | if (is_connected(n)) | 840 | if (is_connected) |
839 | { | 841 | { |
840 | GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_NO); | 842 | GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_NO); |
841 | } | 843 | } |
@@ -869,7 +871,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n) | |||
869 | n->is_active->n = NULL; | 871 | n->is_active->n = NULL; |
870 | n->is_active = NULL; | 872 | n->is_active = NULL; |
871 | } | 873 | } |
872 | if (was_connected) | 874 | if (is_connected) |
873 | { | 875 | { |
874 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != n->keepalive_task); | 876 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != n->keepalive_task); |
875 | GNUNET_SCHEDULER_cancel (n->keepalive_task); | 877 | GNUNET_SCHEDULER_cancel (n->keepalive_task); |
@@ -2053,6 +2055,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | |||
2053 | 2055 | ||
2054 | } | 2056 | } |
2055 | 2057 | ||
2058 | |||
2056 | void | 2059 | void |
2057 | GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | 2060 | GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, |
2058 | const struct GNUNET_PeerIdentity *peer, | 2061 | const struct GNUNET_PeerIdentity *peer, |
@@ -2063,10 +2066,10 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | |||
2063 | { | 2066 | { |
2064 | struct NeighbourMapEntry *n; | 2067 | struct NeighbourMapEntry *n; |
2065 | struct QuotaSetMessage q_msg; | 2068 | struct QuotaSetMessage q_msg; |
2066 | int was_connected; | ||
2067 | 2069 | ||
2068 | #if DEBUG_TRANSPORT | 2070 | #if DEBUG_TRANSPORT |
2069 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ACK message from peer `%s'\n", | 2071 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2072 | "Received ACK message from peer `%s'\n", | ||
2070 | GNUNET_i2s (peer)); | 2073 | GNUNET_i2s (peer)); |
2071 | #endif | 2074 | #endif |
2072 | 2075 | ||
@@ -2075,7 +2078,6 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | |||
2075 | GNUNET_break_op (0); | 2078 | GNUNET_break_op (0); |
2076 | return; | 2079 | return; |
2077 | } | 2080 | } |
2078 | |||
2079 | n = lookup_neighbour (peer); | 2081 | n = lookup_neighbour (peer); |
2080 | if (NULL == n) | 2082 | if (NULL == n) |
2081 | { | 2083 | { |
@@ -2084,27 +2086,22 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | |||
2084 | GNUNET_break (0); | 2086 | GNUNET_break (0); |
2085 | return; | 2087 | return; |
2086 | } | 2088 | } |
2087 | |||
2088 | if (is_connected (n)) | 2089 | if (is_connected (n)) |
2089 | return; | 2090 | return; |
2090 | |||
2091 | if (!is_connecting(n)) | 2091 | if (!is_connecting(n)) |
2092 | { | 2092 | { |
2093 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# unexpected ACK messages"), 1, | 2093 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# unexpected ACK messages"), 1, |
2094 | GNUNET_NO); | 2094 | GNUNET_NO); |
2095 | return; | 2095 | return; |
2096 | } | 2096 | } |
2097 | |||
2098 | if (NULL != session) | 2097 | if (NULL != session) |
2099 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 2098 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
2100 | "transport-ats", | 2099 | "transport-ats", |
2101 | "Giving ATS session %p of plugin %s for peer %s\n", | 2100 | "Giving ATS session %p of plugin %s for peer %s\n", |
2102 | session, address->transport_name, GNUNET_i2s (peer)); | 2101 | session, address->transport_name, GNUNET_i2s (peer)); |
2103 | GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count); | 2102 | GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count); |
2104 | 2103 | GNUNET_assert (n->address != NULL); | |
2105 | was_connected = is_connected (n); | ||
2106 | change_state (n, S_CONNECTED); | 2104 | change_state (n, S_CONNECTED); |
2107 | |||
2108 | GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES); | 2105 | GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES); |
2109 | 2106 | ||
2110 | GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in); | 2107 | GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in); |
@@ -2113,26 +2110,22 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | |||
2113 | n->keepalive_task = | 2110 | n->keepalive_task = |
2114 | GNUNET_SCHEDULER_add_delayed (KEEPALIVE_FREQUENCY, | 2111 | GNUNET_SCHEDULER_add_delayed (KEEPALIVE_FREQUENCY, |
2115 | &neighbour_keepalive_task, n); | 2112 | &neighbour_keepalive_task, n); |
2116 | 2113 | GST_validation_set_address_use (&n->id, | |
2117 | if (!was_connected) | 2114 | n->address, |
2118 | { | 2115 | n->session, |
2119 | GST_validation_set_address_use (&n->id, | 2116 | GNUNET_YES); |
2120 | n->address, | 2117 | neighbours_connected++; |
2121 | n->session, | 2118 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, |
2122 | GNUNET_YES); | 2119 | GNUNET_NO); |
2123 | neighbours_connected++; | 2120 | |
2124 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, | ||
2125 | GNUNET_NO); | ||
2126 | |||
2127 | #if DEBUG_TRANSPORT | 2121 | #if DEBUG_TRANSPORT |
2128 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2122 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2129 | "Notify about connect of `%4s' using address '%s' session %X LINE %u\n", | 2123 | "Notify about connect of `%4s' using address '%s' session %X LINE %u\n", |
2130 | GNUNET_i2s (&n->id), | 2124 | GNUNET_i2s (&n->id), |
2131 | GST_plugins_a2s (n->address), n->session, | 2125 | GST_plugins_a2s (n->address), n->session, |
2132 | __LINE__); | 2126 | __LINE__); |
2133 | #endif | 2127 | #endif |
2134 | connect_notify_cb (callback_cls, &n->id, ats, ats_count); | 2128 | connect_notify_cb (callback_cls, &n->id, ats, ats_count); |
2135 | } | ||
2136 | #if DEBUG_TRANSPORT | 2129 | #if DEBUG_TRANSPORT |
2137 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2130 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2138 | "Sending outbound quota of %u Bps for peer `%s' to all clients\n", | 2131 | "Sending outbound quota of %u Bps for peer `%s' to all clients\n", |