diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-11-04 09:47:40 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-11-04 09:47:40 +0000 |
commit | 592b81029e325fd2444a5f5cc1abc24e357f1ebe (patch) | |
tree | 7a930160404e36aa8fabc4bfc9ef906925987bab /src/transport/gnunet-service-transport_neighbours.c | |
parent | 7301211bb756c4119d370b6f5f79a9054f2cbe92 (diff) | |
download | gnunet-592b81029e325fd2444a5f5cc1abc24e357f1ebe.tar.gz gnunet-592b81029e325fd2444a5f5cc1abc24e357f1ebe.zip |
additional checks due to mantis 0001868
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 85 |
1 files changed, 53 insertions, 32 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index cf23c5b35..cfe988ac4 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -1200,29 +1200,47 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
1200 | struct SessionConnectMessage connect_msg; | 1200 | struct SessionConnectMessage connect_msg; |
1201 | size_t msg_len; | 1201 | size_t msg_len; |
1202 | size_t ret; | 1202 | size_t ret; |
1203 | int checks_failed; | ||
1203 | 1204 | ||
1204 | // This can happen during shutdown | 1205 | // This can happen during shutdown |
1205 | if (neighbours == NULL) | 1206 | if (neighbours == NULL) |
1206 | { | 1207 | { |
1207 | return GNUNET_NO; | 1208 | return GNUNET_NO; |
1208 | } | 1209 | } |
1209 | n = lookup_neighbour (peer); | 1210 | |
1210 | if (NULL == n) | 1211 | checks_failed = GNUNET_NO; |
1212 | |||
1213 | if (plugin_name == NULL) | ||
1211 | { | 1214 | { |
1212 | if (NULL == session) | 1215 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1213 | GNUNET_ATS_address_destroyed (GST_ats, | 1216 | "ATS offered suggested us empty address: plugin NULL"); |
1214 | peer, | 1217 | GNUNET_break_op(0); |
1215 | plugin_name, address, | 1218 | checks_failed = GNUNET_YES; |
1216 | address_len, NULL); | 1219 | } |
1217 | return GNUNET_NO; | 1220 | if ((address == NULL) && (address_len == 0 )) |
1221 | { | ||
1222 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1223 | "ATS offered suggested us empty address: address NULL"); | ||
1224 | GNUNET_break_op(0); | ||
1225 | checks_failed = GNUNET_YES; | ||
1218 | } | 1226 | } |
1219 | 1227 | ||
1220 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) | 1228 | n = lookup_neighbour (peer); |
1229 | if (NULL == n) | ||
1230 | checks_failed = GNUNET_YES; | ||
1231 | |||
1232 | if (checks_failed == GNUNET_YES) | ||
1221 | { | 1233 | { |
1222 | GNUNET_SCHEDULER_cancel(n->ats_suggest); | 1234 | GNUNET_ATS_address_destroyed (GST_ats, |
1223 | n->ats_suggest = GNUNET_SCHEDULER_NO_TASK; | 1235 | peer, |
1236 | plugin_name, address, | ||
1237 | address_len, session); | ||
1238 | if (n != NULL) | ||
1239 | GNUNET_ATS_suggest_address(GST_ats, peer); | ||
1240 | return GNUNET_NO; | ||
1224 | } | 1241 | } |
1225 | 1242 | ||
1243 | /* checks successful and neighbour != NULL */ | ||
1226 | #if DEBUG_TRANSPORT | 1244 | #if DEBUG_TRANSPORT |
1227 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1245 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1228 | "ATS tells us to switch to plugin `%s' address '%s' session %X for %s peer `%s'\n", | 1246 | "ATS tells us to switch to plugin `%s' address '%s' session %X for %s peer `%s'\n", |
@@ -1234,35 +1252,38 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
1234 | GNUNET_i2s (peer)); | 1252 | GNUNET_i2s (peer)); |
1235 | #endif | 1253 | #endif |
1236 | 1254 | ||
1255 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) | ||
1256 | { | ||
1257 | GNUNET_SCHEDULER_cancel(n->ats_suggest); | ||
1258 | n->ats_suggest = GNUNET_SCHEDULER_NO_TASK; | ||
1259 | } | ||
1260 | |||
1237 | // do not switch addresses just update quotas | 1261 | // do not switch addresses just update quotas |
1238 | if (n != NULL) | 1262 | if ((is_connected(n)) && (address_len == n->addrlen)) |
1239 | { | 1263 | { |
1240 | if ((is_connected(n)) && (address_len == n->addrlen)) | 1264 | if ((0 == memcmp (address, n->addr, address_len)) && |
1265 | (n->session == session)) | ||
1241 | { | 1266 | { |
1242 | if ((0 == memcmp (address, n->addr, address_len)) && | 1267 | struct QuotaSetMessage q_msg; |
1243 | (n->session == session)) | ||
1244 | { | ||
1245 | struct QuotaSetMessage q_msg; | ||
1246 | 1268 | ||
1247 | #if DEBUG_TRANSPORT | 1269 | #if DEBUG_TRANSPORT |
1248 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1270 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1249 | "Sending outbound quota of %u Bps and inbound quota of %u Bps for peer `%s' to all clients\n", | 1271 | "Sending outbound quota of %u Bps and inbound quota of %u Bps for peer `%s' to all clients\n", |
1250 | ntohl (n->bandwidth_out.value__), | 1272 | ntohl (n->bandwidth_out.value__), |
1251 | ntohl (n->bandwidth_in.value__), | 1273 | ntohl (n->bandwidth_in.value__), |
1252 | GNUNET_i2s (peer)); | 1274 | GNUNET_i2s (peer)); |
1253 | #endif | 1275 | #endif |
1254 | 1276 | ||
1255 | n->bandwidth_in = bandwidth_in; | 1277 | n->bandwidth_in = bandwidth_in; |
1256 | n->bandwidth_out = bandwidth_out; | 1278 | n->bandwidth_out = bandwidth_out; |
1257 | GST_neighbours_set_incoming_quota(&n->id, n->bandwidth_in); | 1279 | GST_neighbours_set_incoming_quota(&n->id, n->bandwidth_in); |
1258 | 1280 | ||
1259 | q_msg.header.size = htons (sizeof (struct QuotaSetMessage)); | 1281 | q_msg.header.size = htons (sizeof (struct QuotaSetMessage)); |
1260 | q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA); | 1282 | q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA); |
1261 | q_msg.quota = n->bandwidth_out; | 1283 | q_msg.quota = n->bandwidth_out; |
1262 | q_msg.peer = (*peer); | 1284 | q_msg.peer = (*peer); |
1263 | GST_clients_broadcast (&q_msg.header, GNUNET_NO); | 1285 | GST_clients_broadcast (&q_msg.header, GNUNET_NO); |
1264 | return GNUNET_NO; | 1286 | return GNUNET_NO; |
1265 | } | ||
1266 | } | 1287 | } |
1267 | } | 1288 | } |
1268 | 1289 | ||