aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-10-27 20:05:37 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-10-27 20:05:37 +0000
commit0690db8cd6b2cd4fb6178a879479ffac72328a0f (patch)
tree735fdfd8308acbcf040ebc826049b45f4e762827 /src
parent78eb3927110c2928aaf796efe7b362163455d92a (diff)
downloadgnunet-0690db8cd6b2cd4fb6178a879479ffac72328a0f.tar.gz
gnunet-0690db8cd6b2cd4fb6178a879479ffac72328a0f.zip
implemented ATS_suggest timeout
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-service-transport_neighbours_3way.c61
1 files changed, 45 insertions, 16 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours_3way.c b/src/transport/gnunet-service-transport_neighbours_3way.c
index fd3ad37f9..075e6239f 100644
--- a/src/transport/gnunet-service-transport_neighbours_3way.c
+++ b/src/transport/gnunet-service-transport_neighbours_3way.c
@@ -284,6 +284,8 @@ struct NeighbourMapEntry
284 */ 284 */
285 struct GNUNET_TIME_Absolute connect_ts; 285 struct GNUNET_TIME_Absolute connect_ts;
286 286
287 GNUNET_SCHEDULER_TaskIdentifier ats_suggest;
288
287 /** 289 /**
288 * How often has the other peer (recently) violated the inbound 290 * How often has the other peer (recently) violated the inbound
289 * traffic limit? Incremented by 10 per violation, decremented by 1 291 * traffic limit? Incremented by 10 per violation, decremented by 1
@@ -774,6 +776,11 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
774 GNUNET_assert (GNUNET_YES == 776 GNUNET_assert (GNUNET_YES ==
775 GNUNET_CONTAINER_multihashmap_remove (neighbours, 777 GNUNET_CONTAINER_multihashmap_remove (neighbours,
776 &n->id.hashPubKey, n)); 778 &n->id.hashPubKey, n));
779 if (GNUNET_SCHEDULER_NO_TASK != n->ats_suggest)
780 {
781 GNUNET_SCHEDULER_cancel (n->ats_suggest);
782 n->ats_suggest = GNUNET_SCHEDULER_NO_TASK;
783 }
777 if (GNUNET_SCHEDULER_NO_TASK != n->timeout_task) 784 if (GNUNET_SCHEDULER_NO_TASK != n->timeout_task)
778 { 785 {
779 GNUNET_SCHEDULER_cancel (n->timeout_task); 786 GNUNET_SCHEDULER_cancel (n->timeout_task);
@@ -880,6 +887,22 @@ disconnect_all_neighbours (void *cls, const GNUNET_HashCode * key, void *value)
880} 887}
881 888
882 889
890static void
891ats_suggest_cancel (void *cls,
892 const struct GNUNET_SCHEDULER_TaskContext *tc)
893{
894 struct NeighbourMapEntry *n = cls;
895
896 n->ats_suggest = GNUNET_SCHEDULER_NO_TASK;
897
898 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
899 " ATS did not suggested address to connect to peer `%s'\n",
900 GNUNET_i2s (&n->id));
901
902 disconnect_neighbour(n);
903}
904
905
883/** 906/**
884 * Cleanup the neighbours subsystem. 907 * Cleanup the neighbours subsystem.
885 */ 908 */
@@ -939,6 +962,9 @@ send_connect_continuation (void *cls,
939 n->addrlen, 962 n->addrlen,
940 NULL); 963 NULL);
941 964
965 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
966 GNUNET_SCHEDULER_cancel(n->ats_suggest);
967 n->ats_suggest = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, ats_suggest_cancel, n);
942 GNUNET_ATS_suggest_address(GST_ats, &n->id); 968 GNUNET_ATS_suggest_address(GST_ats, &n->id);
943 return; 969 return;
944 } 970 }
@@ -978,13 +1004,6 @@ send_switch_address_continuation (void *cls,
978 n->session); 1004 n->session);
979#endif 1005#endif
980 1006
981 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Do not forget to fix this!\n");
982 /* FIXME: We have to change the state away from connected:
983 * If ATS can not suggest another address we do not get a callback
984 * but we still think we are connected
985 */
986 //change_state(n, S_NOT_CONNECTED);
987
988 GNUNET_ATS_address_destroyed (GST_ats, 1007 GNUNET_ATS_address_destroyed (GST_ats,
989 &n->id, 1008 &n->id,
990 n->plugin_name, 1009 n->plugin_name,
@@ -992,6 +1011,9 @@ send_switch_address_continuation (void *cls,
992 n->addrlen, 1011 n->addrlen,
993 NULL); 1012 NULL);
994 1013
1014 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
1015 GNUNET_SCHEDULER_cancel(n->ats_suggest);
1016 n->ats_suggest = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, ats_suggest_cancel, n);
995 GNUNET_ATS_suggest_address(GST_ats, &n->id); 1017 GNUNET_ATS_suggest_address(GST_ats, &n->id);
996 return; 1018 return;
997 } 1019 }
@@ -1037,6 +1059,9 @@ send_connect_ack_continuation (void *cls,
1037 n->addrlen, 1059 n->addrlen,
1038 NULL); 1060 NULL);
1039 1061
1062 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
1063 GNUNET_SCHEDULER_cancel(n->ats_suggest);
1064 n->ats_suggest = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, ats_suggest_cancel, n);
1040 GNUNET_ATS_suggest_address(GST_ats, &n->id); 1065 GNUNET_ATS_suggest_address(GST_ats, &n->id);
1041} 1066}
1042 1067
@@ -1056,7 +1081,7 @@ send_connect_ack_continuation (void *cls,
1056 * connection is not up (yet) 1081 * connection is not up (yet)
1057 */ 1082 */
1058int 1083int
1059GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, 1084GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1060 const char *plugin_name, const void *address, 1085 const char *plugin_name, const void *address,
1061 size_t address_len, struct Session *session, 1086 size_t address_len, struct Session *session,
1062 const struct GNUNET_ATS_Information 1087 const struct GNUNET_ATS_Information
@@ -1253,10 +1278,13 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
1253 "Asking ATS for suggested address to connect to peer `%s'\n", 1278 "Asking ATS for suggested address to connect to peer `%s'\n",
1254 GNUNET_i2s (&n->id)); 1279 GNUNET_i2s (&n->id));
1255#endif 1280#endif
1281
1282 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
1283 GNUNET_SCHEDULER_cancel(n->ats_suggest);
1284 n->ats_suggest = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, ats_suggest_cancel, n);
1256 GNUNET_ATS_suggest_address (GST_ats, &n->id); 1285 GNUNET_ATS_suggest_address (GST_ats, &n->id);
1257} 1286}
1258 1287
1259
1260/** 1288/**
1261 * Test if we're connected to the given peer. 1289 * Test if we're connected to the given peer.
1262 * 1290 *
@@ -1313,15 +1341,15 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
1313 if ((!is_connected(n)) && (!is_connecting(n))) 1341 if ((!is_connected(n)) && (!is_connecting(n)))
1314 return; 1342 return;
1315 1343
1316 // FIXME: switch address what is the state
1317 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Do not forget to fix this!\n");
1318
1319 /* We are connected, so ask ATS to switch addresses */ 1344 /* We are connected, so ask ATS to switch addresses */
1320 GNUNET_SCHEDULER_cancel (n->timeout_task); 1345 GNUNET_SCHEDULER_cancel (n->timeout_task);
1321 n->timeout_task = 1346 n->timeout_task =
1322 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT, 1347 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT,
1323 &neighbour_timeout_task, n); 1348 &neighbour_timeout_task, n);
1324 /* try QUICKLY to re-establish a connection, reduce timeout! */ 1349 /* try QUICKLY to re-establish a connection, reduce timeout! */
1350 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
1351 GNUNET_SCHEDULER_cancel(n->ats_suggest);
1352 n->ats_suggest = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, ats_suggest_cancel, n);
1325 GNUNET_ATS_suggest_address (GST_ats, peer); 1353 GNUNET_ATS_suggest_address (GST_ats, peer);
1326} 1354}
1327 1355
@@ -1869,14 +1897,14 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
1869 } 1897 }
1870// FIXME check this 1898// FIXME check this
1871// if (n->state != S_CONNECT_RECV) 1899// if (n->state != S_CONNECT_RECV)
1872 if (is_connecting(n)) 1900/* if (is_connecting(n))
1873 { 1901 {
1874 send_disconnect (n); 1902 send_disconnect (n);
1875 change_state (n, S_DISCONNECT); 1903 change_state (n, S_DISCONNECT);
1876 GNUNET_break (0); 1904 GNUNET_break (0);
1877 return; 1905 return;
1878 } 1906 }
1879 1907*/
1880 if (is_connected(n)) 1908 if (is_connected(n))
1881 return; 1909 return;
1882 1910
@@ -1978,14 +2006,15 @@ handle_connect_blacklist_cont (void *cls,
1978 } 2006 }
1979 2007
1980 GNUNET_free (bcc); 2008 GNUNET_free (bcc);
1981 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1982 "Blacklist check due to CONNECT message: `%s'\n");
1983/* 2009/*
1984 if (n->state != S_NOT_CONNECTED) 2010 if (n->state != S_NOT_CONNECTED)
1985 return;*/ 2011 return;*/
1986 change_state (n, S_CONNECT_RECV); 2012 change_state (n, S_CONNECT_RECV);
1987 2013
1988 /* Ask ATS for an address to connect via that address */ 2014 /* Ask ATS for an address to connect via that address */
2015 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
2016 GNUNET_SCHEDULER_cancel(n->ats_suggest);
2017 n->ats_suggest = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, ats_suggest_cancel, n);
1989 GNUNET_ATS_suggest_address(GST_ats, peer); 2018 GNUNET_ATS_suggest_address(GST_ats, peer);
1990} 2019}
1991 2020