aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-11-10 17:24:42 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-11-10 17:24:42 +0000
commita856620f5547c9cc2b8f5a2319b2b44bcc44c733 (patch)
tree195c5b779cd54fc7e02ab0098ea8f5a22d4e9a65 /src
parent61f0bfd3e80c61af6e422419a2071134c24d3468 (diff)
downloadgnunet-a856620f5547c9cc2b8f5a2319b2b44bcc44c733.tar.gz
gnunet-a856620f5547c9cc2b8f5a2319b2b44bcc44c733.zip
improved fast_reconnect
improved continuation management (no peer references) but - ats address update and destroying sessions is not working correctly...
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c239
1 files changed, 186 insertions, 53 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index c9e8e1624..d62e4249a 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -59,6 +59,7 @@
59 59
60#define ATS_RESPONSE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) 60#define ATS_RESPONSE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
61 61
62#define FAST_RECONNECT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
62 63
63#define SETUP_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) 64#define SETUP_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
64 65
@@ -451,13 +452,6 @@ reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
451 452
452#if DEBUG_TRANSPORT 453#if DEBUG_TRANSPORT
453#endif 454#endif
454 /* This jut a temporary debug message to check if a the value
455 * SETUP_CONNECTION_TIMEOUT was choosen to small for slow machines
456 */
457 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
458 "Information for developers: Connection to peer `%s' %s failed in state `%s', resetting connection attempt \n",
459 GNUNET_i2s (&n->id), GST_plugins_a2s (n->address),
460 print_state (n->state));
461 455
462 GNUNET_STATISTICS_update (GST_stats, 456 GNUNET_STATISTICS_update (GST_stats,
463 gettext_noop 457 gettext_noop
@@ -468,7 +462,7 @@ reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
468 n->state = S_NOT_CONNECTED; 462 n->state = S_NOT_CONNECTED;
469 463
470 /* destroying address */ 464 /* destroying address */
471 GNUNET_ATS_address_destroyed (GST_ats, n->address, NULL); 465 GNUNET_ATS_address_destroyed (GST_ats, n->address, n->session);
472 466
473 /* request new address */ 467 /* request new address */
474 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) 468 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
@@ -505,7 +499,7 @@ change (struct NeighbourMapEntry *n, int state, int line)
505 case S_DISCONNECT: 499 case S_DISCONNECT:
506 break; 500 break;
507 case S_FAST_RECONNECT: 501 case S_FAST_RECONNECT:
508 if ((state == S_CONNECT_SENT) || (state == S_DISCONNECT)) 502 if ((state == S_CONNECTED) || (state == S_DISCONNECT))
509 allowed = GNUNET_YES; 503 allowed = GNUNET_YES;
510 break; 504 break;
511 default: 505 default:
@@ -597,7 +591,7 @@ send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf,
597 return GNUNET_SYSERR; 591 return GNUNET_SYSERR;
598 } 592 }
599 593
600 if ((session == NULL) && (address == NULL)) 594 if ((session == NULL) && (address->address_length == 0))
601 { 595 {
602 if (cont != NULL) 596 if (cont != NULL)
603 cont (cont_cls, target, GNUNET_SYSERR); 597 cont (cont_cls, target, GNUNET_SYSERR);
@@ -709,6 +703,17 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
709 if (NULL == mq) 703 if (NULL == mq)
710 return; /* no more messages */ 704 return; /* no more messages */
711 705
706 if (n->address == NULL)
707 {
708 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
709 "No address for peer `%s'\n",
710 GNUNET_i2s (&n->id));
711 transmit_send_continuation (mq, &n->id, GNUNET_SYSERR);
712 GNUNET_assert (n->transmission_task == GNUNET_SCHEDULER_NO_TASK);
713 n->transmission_task = GNUNET_SCHEDULER_add_now (&transmission_task, n);
714 return;
715 }
716
712 if (GST_plugins_find (n->address->transport_name) == NULL) 717 if (GST_plugins_find (n->address->transport_name) == NULL)
713 { 718 {
714 GNUNET_break (0); 719 GNUNET_break (0);
@@ -718,7 +723,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
718 n->is_active = mq; 723 n->is_active = mq;
719 mq->n = n; 724 mq->n = n;
720 725
721 if ( (n->session == NULL) && (NULL == n->address) ) 726 if ((n->address->address_length == 0) && (n->session == NULL))
722 { 727 {
723 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 728 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
724 "No address for peer `%s'\n", 729 "No address for peer `%s'\n",
@@ -855,8 +860,9 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
855 if (is_disconnecting (n)) 860 if (is_disconnecting (n))
856 return; 861 return;
857 862
863
858 /* send DISCONNECT MESSAGE */ 864 /* send DISCONNECT MESSAGE */
859 if ((previous_state == S_CONNECTED)|| is_connecting (n)) 865 if ((previous_state == S_CONNECTED) || is_connecting (n))
860 { 866 {
861 if (GNUNET_OK == 867 if (GNUNET_OK ==
862 send_disconnect (&n->id, n->address, 868 send_disconnect (&n->id, n->address,
@@ -915,6 +921,10 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
915 case S_FAST_RECONNECT: 921 case S_FAST_RECONNECT:
916 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), -1, 922 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), -1,
917 GNUNET_NO); 923 GNUNET_NO);
924 GNUNET_STATISTICS_update (GST_stats,
925 gettext_noop
926 ("# fast reconnects failed"),
927 1, GNUNET_NO);
918 disconnect_notify_cb (callback_cls, &n->id); 928 disconnect_notify_cb (callback_cls, &n->id);
919 default: 929 default:
920 break; 930 break;
@@ -1077,6 +1087,12 @@ GST_neighbours_stop ()
1077 disconnect_notify_cb = NULL; 1087 disconnect_notify_cb = NULL;
1078} 1088}
1079 1089
1090struct ContinutionContext
1091{
1092 struct GNUNET_HELLO_Address *address;
1093
1094 struct Session *session;
1095};
1080 1096
1081/** 1097/**
1082 * We tried to send a SESSION_CONNECT message to another peer. If this 1098 * We tried to send a SESSION_CONNECT message to another peer. If this
@@ -1090,34 +1106,53 @@ static void
1090send_connect_continuation (void *cls, const struct GNUNET_PeerIdentity *target, 1106send_connect_continuation (void *cls, const struct GNUNET_PeerIdentity *target,
1091 int success) 1107 int success)
1092{ 1108{
1093 struct GNUNET_HELLO_Address *address = cls; 1109 struct ContinutionContext * cc = cls;
1094 struct NeighbourMapEntry *n; 1110 struct NeighbourMapEntry *n = lookup_neighbour (&cc->address->peer);
1095 1111
1096 if (GNUNET_YES != success) 1112 if (GNUNET_YES != success)
1097 GNUNET_ATS_address_destroyed (GST_ats, address, NULL); 1113 GNUNET_ATS_address_destroyed (GST_ats, cc->address, NULL);
1114 //GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
1098 if ( (NULL == neighbours) || 1115 if ( (NULL == neighbours) ||
1099 (NULL == (n = lookup_neighbour (&address->peer))) || 1116 (NULL == n) ||
1100 (n->state == S_DISCONNECT) || 1117 (n->state == S_DISCONNECT))
1101 (GNUNET_YES == success) )
1102 { 1118 {
1103 GNUNET_HELLO_address_free (address); 1119 GNUNET_HELLO_address_free (cc->address);
1120 GNUNET_free (cc);
1104 return; 1121 return;
1105 } 1122 }
1123
1124 if ((GNUNET_YES == success) &&
1125 ((n->state == S_NOT_CONNECTED) || (n->state == S_CONNECT_SENT)))
1126 {
1127 change_state (n, S_CONNECT_SENT);
1128 GNUNET_HELLO_address_free (cc->address);
1129 GNUNET_free (cc);
1130 return;
1131 }
1132
1133 if ((GNUNET_NO == success) &&
1134 ((n->state == S_NOT_CONNECTED) || (n->state == S_CONNECT_SENT)))
1135 {
1106#if DEBUG_TRANSPORT 1136#if DEBUG_TRANSPORT
1107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1137 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1108 "Failed to send CONNECT_MSG to peer `%4s' with address '%s' session %p, asking ATS for new address \n", 1138 "Failed to send CONNECT_MSG to peer `%4s' with address '%s' session %p, asking ATS for new address \n",
1109 GNUNET_i2s (&n->id), 1139 GNUNET_i2s (&n->id),
1110 GST_plugins_a2s (n->address), 1140 GST_plugins_a2s (n->address),
1111 n->session); 1141 n->session);
1112#endif 1142#endif
1113 change_state (n, S_NOT_CONNECTED); 1143 change_state (n, S_NOT_CONNECTED);
1114 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) 1144 GNUNET_ATS_address_destroyed (GST_ats, cc->address, NULL);
1115 GNUNET_SCHEDULER_cancel (n->ats_suggest); 1145 //GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
1116 n->ats_suggest = 1146
1117 GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, &ats_suggest_cancel, 1147 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
1118 n); 1148 GNUNET_SCHEDULER_cancel (n->ats_suggest);
1119 GNUNET_ATS_suggest_address (GST_ats, &n->id); 1149 n->ats_suggest =
1120 GNUNET_HELLO_address_free (address); 1150 GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, &ats_suggest_cancel,
1151 n);
1152 GNUNET_ATS_suggest_address (GST_ats, &n->id);
1153 }
1154 GNUNET_HELLO_address_free (cc->address);
1155 GNUNET_free (cc);
1121} 1156}
1122 1157
1123 1158
@@ -1133,13 +1168,25 @@ send_switch_address_continuation (void *cls,
1133 const struct GNUNET_PeerIdentity *target, 1168 const struct GNUNET_PeerIdentity *target,
1134 int success) 1169 int success)
1135{ 1170{
1136 struct NeighbourMapEntry *n = cls; 1171 struct ContinutionContext * cc = cls;
1172 struct NeighbourMapEntry *n;
1137 1173
1138 GNUNET_assert (n != NULL); 1174 if (neighbours == NULL)
1139 if (is_disconnecting (n)) 1175 {
1176 GNUNET_HELLO_address_free (cc->address);
1177 GNUNET_free (cc);
1178 return; /* neighbour is going away */
1179 }
1180
1181 n = lookup_neighbour(&cc->address->peer);
1182 if ((n == NULL) || (is_disconnecting (n)))
1183 {
1184 GNUNET_HELLO_address_free (cc->address);
1185 GNUNET_free (cc);
1140 return; /* neighbour is going away */ 1186 return; /* neighbour is going away */
1187 }
1141 1188
1142 GNUNET_assert (n->state == S_CONNECTED); 1189 GNUNET_assert ((n->state == S_CONNECTED) || (n->state == S_FAST_RECONNECT));
1143 if (GNUNET_YES != success) 1190 if (GNUNET_YES != success)
1144 { 1191 {
1145#if DEBUG_TRANSPORT 1192#if DEBUG_TRANSPORT
@@ -1148,8 +1195,8 @@ send_switch_address_continuation (void *cls,
1148 GNUNET_i2s (&n->id), 1195 GNUNET_i2s (&n->id),
1149 GST_plugins_a2s (n->address), n->session); 1196 GST_plugins_a2s (n->address), n->session);
1150#endif 1197#endif
1151 1198 GNUNET_ATS_address_destroyed (GST_ats, cc->address, NULL);
1152 GNUNET_ATS_address_destroyed (GST_ats, n->address, NULL); 1199 //GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
1153 1200
1154 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) 1201 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
1155 GNUNET_SCHEDULER_cancel (n->ats_suggest); 1202 GNUNET_SCHEDULER_cancel (n->ats_suggest);
@@ -1157,10 +1204,53 @@ send_switch_address_continuation (void *cls,
1157 GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, 1204 GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel,
1158 n); 1205 n);
1159 GNUNET_ATS_suggest_address (GST_ats, &n->id); 1206 GNUNET_ATS_suggest_address (GST_ats, &n->id);
1207 GNUNET_HELLO_address_free (cc->address);
1208 GNUNET_free (cc);
1160 return; 1209 return;
1161 } 1210 }
1162 /* Tell ATS that switching addresses was successful */ 1211 /* Tell ATS that switching addresses was successful */
1163 GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES); 1212 switch (n->state) {
1213 case S_CONNECTED:
1214 GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES);
1215 break;
1216 case S_FAST_RECONNECT:
1217#if DEBUG_TRANSPORT
1218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1219 "Successful fast reconnect to peer `%s'\n", GNUNET_i2s (&n->id));
1220#endif
1221 change_state (n, S_CONNECTED);
1222 neighbours_connected++;
1223 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
1224 GNUNET_NO);
1225
1226 GST_validation_set_address_use (&n->id,
1227 cc->address,
1228 cc->session,
1229 GNUNET_YES);
1230
1231 GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, GNUNET_YES);
1232
1233 if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK)
1234 n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n);
1235
1236 /* Updating quotas */
1237 struct QuotaSetMessage q_msg;
1238 GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
1239#if DEBUG_TRANSPORT
1240 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1241 "Sending outbound quota of %u Bps for peer `%s' to all clients\n",
1242 ntohl (n->bandwidth_out.value__), GNUNET_i2s (peer));
1243#endif
1244 q_msg.header.size = htons (sizeof (struct QuotaSetMessage));
1245 q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA);
1246 q_msg.quota = n->bandwidth_out;
1247 q_msg.peer = (*target);
1248 GST_clients_broadcast (&q_msg.header, GNUNET_NO);
1249 default:
1250 break;
1251 }
1252 GNUNET_HELLO_address_free (cc->address);
1253 GNUNET_free (cc);
1164} 1254}
1165 1255
1166/** 1256/**
@@ -1176,11 +1266,30 @@ send_connect_ack_continuation (void *cls,
1176 const struct GNUNET_PeerIdentity *target, 1266 const struct GNUNET_PeerIdentity *target,
1177 int success) 1267 int success)
1178{ 1268{
1179 struct NeighbourMapEntry *n = cls; 1269 struct ContinutionContext * cc = cls;
1270 struct NeighbourMapEntry *n;
1271
1272 if (neighbours == NULL)
1273 {
1274 GNUNET_HELLO_address_free (cc->address);
1275 GNUNET_free (cc);
1276 return; /* neighbour is going away */
1277 }
1278
1279 n = lookup_neighbour(&cc->address->peer);
1280 if ((n == NULL) || (is_disconnecting (n)))
1281 {
1282 GNUNET_HELLO_address_free (cc->address);
1283 GNUNET_free (cc);
1284 return; /* neighbour is going away */
1285 }
1180 1286
1181 GNUNET_assert (n != NULL);
1182 if (GNUNET_YES == success) 1287 if (GNUNET_YES == success)
1288 {
1289 GNUNET_HELLO_address_free (cc->address);
1290 GNUNET_free (cc);
1183 return; /* sending successful */ 1291 return; /* sending successful */
1292 }
1184 1293
1185 /* sending failed, ask for next address */ 1294 /* sending failed, ask for next address */
1186#if DEBUG_TRANSPORT 1295#if DEBUG_TRANSPORT
@@ -1192,7 +1301,8 @@ send_connect_ack_continuation (void *cls,
1192#endif 1301#endif
1193 change_state (n, S_NOT_CONNECTED); 1302 change_state (n, S_NOT_CONNECTED);
1194 1303
1195 GNUNET_ATS_address_destroyed (GST_ats, n->address, NULL); 1304 GNUNET_ATS_address_destroyed (GST_ats, cc->address, NULL);
1305 //GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
1196 1306
1197 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) 1307 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
1198 GNUNET_SCHEDULER_cancel (n->ats_suggest); 1308 GNUNET_SCHEDULER_cancel (n->ats_suggest);
@@ -1200,8 +1310,10 @@ send_connect_ack_continuation (void *cls,
1200 GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, 1310 GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel,
1201 n); 1311 n);
1202 GNUNET_ATS_suggest_address (GST_ats, &n->id); 1312 GNUNET_ATS_suggest_address (GST_ats, &n->id);
1203}
1204 1313
1314 GNUNET_HELLO_address_free (cc->address);
1315 GNUNET_free (cc);
1316}
1205 1317
1206/** 1318/**
1207 * For an existing neighbour record, set the active connection to 1319 * For an existing neighbour record, set the active connection to
@@ -1229,6 +1341,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1229{ 1341{
1230 struct NeighbourMapEntry *n; 1342 struct NeighbourMapEntry *n;
1231 struct SessionConnectMessage connect_msg; 1343 struct SessionConnectMessage connect_msg;
1344 struct ContinutionContext * cc;
1232 size_t msg_len; 1345 size_t msg_len;
1233 size_t ret; 1346 size_t ret;
1234 1347
@@ -1294,7 +1407,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1294 GST_clients_broadcast (&q_msg.header, GNUNET_NO); 1407 GST_clients_broadcast (&q_msg.header, GNUNET_NO);
1295 return GNUNET_NO; 1408 return GNUNET_NO;
1296 } 1409 }
1297 if (n->state == S_CONNECTED) 1410 if (n->state == S_CONNECTED)
1298 { 1411 {
1299 /* mark old address as no longer used */ 1412 /* mark old address as no longer used */
1300 GNUNET_assert (NULL != n->address); 1413 GNUNET_assert (NULL != n->address);
@@ -1320,7 +1433,6 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1320 { 1433 {
1321 case S_NOT_CONNECTED: 1434 case S_NOT_CONNECTED:
1322 case S_CONNECT_SENT: 1435 case S_CONNECT_SENT:
1323 case S_FAST_RECONNECT:
1324 msg_len = sizeof (struct SessionConnectMessage); 1436 msg_len = sizeof (struct SessionConnectMessage);
1325 connect_msg.header.size = htons (msg_len); 1437 connect_msg.header.size = htons (msg_len);
1326 connect_msg.header.type = 1438 connect_msg.header.type =
@@ -1328,13 +1440,16 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1328 connect_msg.reserved = htonl (0); 1440 connect_msg.reserved = htonl (0);
1329 connect_msg.timestamp = 1441 connect_msg.timestamp =
1330 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); 1442 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
1331 change_state (n, S_CONNECT_SENT); 1443
1444 cc = GNUNET_malloc(sizeof (struct ContinutionContext));
1445 cc->session = session;
1446 cc->address = GNUNET_HELLO_address_copy (address);
1332 ret = 1447 ret =
1333 send_with_plugin (peer, (const char *) &connect_msg, msg_len, 1448 send_with_plugin (peer, (const char *) &connect_msg, msg_len,
1334 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, 1449 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
1335 address, GNUNET_YES, 1450 address, GNUNET_YES,
1336 &send_connect_continuation, 1451 &send_connect_continuation,
1337 GNUNET_HELLO_address_copy (address)); 1452 cc);
1338 return GNUNET_NO; 1453 return GNUNET_NO;
1339 case S_CONNECT_RECV: 1454 case S_CONNECT_RECV:
1340 /* We received a CONNECT message and asked ATS for an address */ 1455 /* We received a CONNECT message and asked ATS for an address */
@@ -1345,14 +1460,18 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1345 connect_msg.reserved = htonl (0); 1460 connect_msg.reserved = htonl (0);
1346 connect_msg.timestamp = 1461 connect_msg.timestamp =
1347 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); 1462 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
1463 cc = GNUNET_malloc(sizeof (struct ContinutionContext));
1464 cc->session = session;
1465 cc->address = GNUNET_HELLO_address_copy (address);
1348 ret = 1466 ret =
1349 send_with_plugin (&n->id, (const void *) &connect_msg, msg_len, 1467 send_with_plugin (&n->id, (const void *) &connect_msg, msg_len,
1350 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, 1468 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
1351 address, GNUNET_YES, 1469 address, GNUNET_YES,
1352 &send_connect_ack_continuation, n); 1470 &send_connect_ack_continuation, cc);
1353 return GNUNET_NO; 1471 return GNUNET_NO;
1354 case S_CONNECTED: 1472 case S_CONNECTED:
1355 /* connected peer is switching addresses */ 1473 case S_FAST_RECONNECT:
1474 /* connected peer is switching addresses or tries fast reconnect*/
1356 GST_validation_set_address_use (&n->id, 1475 GST_validation_set_address_use (&n->id,
1357 n->address, 1476 n->address,
1358 n->session, 1477 n->session,
@@ -1364,11 +1483,14 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1364 connect_msg.reserved = htonl (0); 1483 connect_msg.reserved = htonl (0);
1365 connect_msg.timestamp = 1484 connect_msg.timestamp =
1366 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); 1485 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
1486 cc = GNUNET_malloc(sizeof (struct ContinutionContext));
1487 cc->session = session;
1488 cc->address = GNUNET_HELLO_address_copy (address);
1367 ret = 1489 ret =
1368 send_with_plugin (peer, (const char *) &connect_msg, msg_len, 1490 send_with_plugin (peer, (const char *) &connect_msg, msg_len,
1369 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, 1491 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
1370 address, GNUNET_YES, 1492 address, GNUNET_YES,
1371 &send_switch_address_continuation, n); 1493 &send_switch_address_continuation, cc);
1372 if (ret == GNUNET_SYSERR) 1494 if (ret == GNUNET_SYSERR)
1373 { 1495 {
1374 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1496 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1511,7 +1633,6 @@ GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target)
1511 return GNUNET_YES; 1633 return GNUNET_YES;
1512} 1634}
1513 1635
1514
1515/** 1636/**
1516 * A session was terminated. Take note. 1637 * A session was terminated. Take note.
1517 * 1638 *
@@ -1541,22 +1662,34 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
1541 if (session != n->session) 1662 if (session != n->session)
1542 return; /* doesn't affect us */ 1663 return; /* doesn't affect us */
1543 if (n->state == S_CONNECTED) 1664 if (n->state == S_CONNECTED)
1665 {
1544 GST_validation_set_address_use (&n->id, 1666 GST_validation_set_address_use (&n->id,
1545 n->address, 1667 n->address,
1546 n->session, 1668 n->session,
1547 GNUNET_NO); 1669 GNUNET_NO);
1548 n->session = NULL; 1670 GNUNET_ATS_address_in_use (GST_ats,n->address, n->session, GNUNET_NO);
1671 }
1672
1673
1674 //GNUNET_ATS_address_destroyed(GST_ats, n->address, n->session);
1675
1549 if (NULL != n->address) 1676 if (NULL != n->address)
1550 { 1677 {
1551 GNUNET_HELLO_address_free (n->address); 1678 GNUNET_HELLO_address_free (n->address);
1552 n->address = NULL; 1679 n->address = NULL;
1553 } 1680 }
1681 n->session = NULL;
1554 1682
1555 /* not connected anymore anyway, shouldn't matter */ 1683 /* not connected anymore anyway, shouldn't matter */
1556 if ((S_CONNECTED != n->state) && (!is_connecting (n))) 1684 if ((S_CONNECTED != n->state) && (!is_connecting (n)))
1557 return; 1685 return;
1558 change_state (n, S_FAST_RECONNECT);
1559 1686
1687 /* connected, try fast reconnect */
1688#if DEBUG_TRANSPORT
1689 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1690 "Trying fast reconnect to peer `%s'\n", GNUNET_i2s (peer));
1691#endif
1692 change_state (n, S_FAST_RECONNECT);
1560 GNUNET_assert (neighbours_connected > 0); 1693 GNUNET_assert (neighbours_connected > 0);
1561 neighbours_connected--; 1694 neighbours_connected--;
1562 1695