aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-08-06 13:07:07 +0000
committerNathan S. Evans <evans@in.tum.de>2010-08-06 13:07:07 +0000
commitb935a1b94aed33a9660638539d3f3d2a0239db49 (patch)
tree9065d49a5e9214acf2a89df5102597a53f22c08e /src
parentff7bc64d1b655d63c92d25d9a19d46ae8613dbf8 (diff)
downloadgnunet-b935a1b94aed33a9660638539d3f3d2a0239db49.tar.gz
gnunet-b935a1b94aed33a9660638539d3f3d2a0239db49.zip
fix for overzealous peer disconnect bug
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-service-transport.c66
1 files changed, 56 insertions, 10 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index eda1fec7e..181d26845 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -2014,6 +2014,9 @@ remove_session_validations (void *cls,
2014 * re-establish the connection or signal the disconnect 2014 * re-establish the connection or signal the disconnect
2015 * to the CORE. 2015 * to the CORE.
2016 * 2016 *
2017 * Only signal CORE level disconnect if ALL addresses
2018 * for the peer are exhausted.
2019 *
2017 * @param p overall plugin context 2020 * @param p overall plugin context
2018 * @param nl neighbour that was disconnected 2021 * @param nl neighbour that was disconnected
2019 */ 2022 */
@@ -2032,7 +2035,7 @@ try_fast_reconnect (struct TransportPlugin *p,
2032 So we should consider: 2035 So we should consider:
2033 1) ideally: our own willingness / need to connect 2036 1) ideally: our own willingness / need to connect
2034 2) prior failures to connect to this peer (by plugin) 2037 2) prior failures to connect to this peer (by plugin)
2035 3) ideally: reaons why other peer terminated (as far as knowable) 2038 3) ideally: reasons why other peer terminated (as far as knowable)
2036 2039
2037 Most importantly, it must be POSSIBLE for another peer to terminate 2040 Most importantly, it must be POSSIBLE for another peer to terminate
2038 a connection for a while (without us instantly re-establishing it). 2041 a connection for a while (without us instantly re-establishing it).
@@ -2045,8 +2048,20 @@ try_fast_reconnect (struct TransportPlugin *p,
2045 2048
2046 Finally, this needs to be tested throughly... */ 2049 Finally, this needs to be tested throughly... */
2047 2050
2051 /*
2052 * GNUNET_NO in the call below makes transport disconnect the peer,
2053 * even if only a single address (out of say, six) went away. This
2054 * function must be careful to ONLY disconnect if the peer is gone,
2055 * not just a specifi address.
2056 *
2057 * More specifically, half the places it was used had it WRONG.
2058 */
2059
2048 /* No reconnect, signal disconnect instead! */ 2060 /* No reconnect, signal disconnect instead! */
2049 disconnect_neighbour (nl, GNUNET_NO); 2061 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2062 "Disconnecting peer `%4s', %s\n", GNUNET_i2s(&nl->id),
2063 "try_fast_reconnect");
2064 disconnect_neighbour (nl, GNUNET_YES);
2050} 2065}
2051 2066
2052 2067
@@ -2130,7 +2145,18 @@ plugin_env_session_end (void *cls,
2130 pos = pos->next; 2145 pos = pos->next;
2131 } 2146 }
2132 /* no valid addresses left, signal disconnect! */ 2147 /* no valid addresses left, signal disconnect! */
2133 disconnect_neighbour (nl, GNUNET_NO); 2148
2149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2150 "Disconnecting peer `%4s', %s\n", GNUNET_i2s(&nl->id),
2151 "plugin_env_session_end");
2152 /* FIXME: This doesn't mean there are no addresses left for this PEER,
2153 * it means there aren't any left for this PLUGIN/PEER combination! So
2154 * calling disconnect_neighbor here with GNUNET_NO forces disconnect
2155 * when it isn't necessary. Using GNUNET_YES at least checks to see
2156 * if there are any addresses that work first, so as not to overdo it.
2157 * --NE
2158 */
2159 disconnect_neighbour (nl, GNUNET_YES);
2134} 2160}
2135 2161
2136 2162
@@ -3021,7 +3047,12 @@ confirm_or_drop_neighbour (void *cls,
3021 struct NeighbourList * orig = cls; 3047 struct NeighbourList * orig = cls;
3022 3048
3023 if (n == NULL) 3049 if (n == NULL)
3024 disconnect_neighbour (orig, GNUNET_NO); 3050 {
3051 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3052 "Disconnecting peer `%4s', %s\n", GNUNET_i2s(&orig->id),
3053 "confirm_or_drop_neighboUr");
3054 disconnect_neighbour (orig, GNUNET_NO);
3055 }
3025} 3056}
3026 3057
3027 3058
@@ -4147,9 +4178,9 @@ process_hello (struct TransportPlugin *plugin,
4147 * gone. 4178 * gone.
4148 * 4179 *
4149 * @param n the neighbour list entry for the peer 4180 * @param n the neighbour list entry for the peer
4150 * @param check should we just check if all plugins 4181 * @param check GNUNET_YES to check if ALL addresses for this peer
4151 * disconnected or must we ask all plugins to 4182 * are gone, GNUNET_NO to force a disconnect of the peer
4152 * disconnect? 4183 * regardless of whether other addresses exist.
4153 */ 4184 */
4154static void 4185static void
4155disconnect_neighbour (struct NeighbourList *n, int check) 4186disconnect_neighbour (struct NeighbourList *n, int check)
@@ -4170,7 +4201,12 @@ disconnect_neighbour (struct NeighbourList *n, int check)
4170 while (peer_addresses != NULL) 4201 while (peer_addresses != NULL)
4171 { 4202 {
4172 if (GNUNET_YES == peer_addresses->connected) 4203 if (GNUNET_YES == peer_addresses->connected)
4173 return; /* still connected */ 4204 {
4205 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4206 "NOT Disconnecting from `%4s', still have live addresses!\n",
4207 GNUNET_i2s (&n->id));
4208 return; /* still connected */
4209 }
4174 peer_addresses = peer_addresses->next; 4210 peer_addresses = peer_addresses->next;
4175 } 4211 }
4176 rpos = rpos->next; 4212 rpos = rpos->next;
@@ -4915,7 +4951,12 @@ handle_set_quota (void *cls,
4915 GNUNET_BANDWIDTH_tracker_update_quota (&n->in_tracker, 4951 GNUNET_BANDWIDTH_tracker_update_quota (&n->in_tracker,
4916 qsm->quota); 4952 qsm->quota);
4917 if (0 == ntohl (qsm->quota.value__)) 4953 if (0 == ntohl (qsm->quota.value__))
4918 disconnect_neighbour (n, GNUNET_NO); 4954 {
4955 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
4956 "Disconnecting peer `%4s', %s\n", GNUNET_i2s(&n->id),
4957 "SET_QUOTA");
4958 disconnect_neighbour (n, GNUNET_NO);
4959 }
4919 GNUNET_SERVER_receive_done (client, GNUNET_OK); 4960 GNUNET_SERVER_receive_done (client, GNUNET_OK);
4920} 4961}
4921 4962
@@ -5172,7 +5213,12 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
5172 struct CheckHelloValidatedContext *chvc; 5213 struct CheckHelloValidatedContext *chvc;
5173 5214
5174 while (neighbours != NULL) 5215 while (neighbours != NULL)
5175 disconnect_neighbour (neighbours, GNUNET_NO); 5216 {
5217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5218 "Disconnecting peer `%4s', %s\n", GNUNET_i2s(&neighbours->id),
5219 "SHUTDOWN_TASK");
5220 disconnect_neighbour (neighbours, GNUNET_NO);
5221 }
5176#if DEBUG_TRANSPORT 5222#if DEBUG_TRANSPORT
5177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 5223 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5178 "Transport service is unloading plugins...\n"); 5224 "Transport service is unloading plugins...\n");