aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_neighbours.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-19 01:08:03 +0000
committerChristian Grothoff <christian@grothoff.org>2015-01-19 01:08:03 +0000
commitf735158d94616b75ade351a3cce226483b8af55e (patch)
tree1cd9732b99cc6437fec7751b8f3c9ef28f0371c9 /src/transport/gnunet-service-transport_neighbours.c
parentd769049a7db56037ea4aff3d9d8a8d42a373ec9c (diff)
downloadgnunet-f735158d94616b75ade351a3cce226483b8af55e.tar.gz
gnunet-f735158d94616b75ade351a3cce226483b8af55e.zip
-towards improved ATS API, adding return value with address record when adding address, adding new subsystem with peer-to-address map to transport; causes various new assertions to fail, but no major regression -- not finished
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c371
1 files changed, 198 insertions, 173 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 1bf1fd754..40bad6d75 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2010-2013 Christian Grothoff (and other contributing authors) 3 (C) 2010-2015 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -25,13 +25,14 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_ats_service.h" 27#include "gnunet_ats_service.h"
28#include "gnunet-service-transport_ats.h"
29#include "gnunet-service-transport_blacklist.h"
30#include "gnunet-service-transport_clients.h"
28#include "gnunet-service-transport_neighbours.h" 31#include "gnunet-service-transport_neighbours.h"
29#include "gnunet-service-transport_plugins.h" 32#include "gnunet-service-transport_plugins.h"
30#include "gnunet-service-transport_validation.h" 33#include "gnunet-service-transport_validation.h"
31#include "gnunet-service-transport_clients.h"
32#include "gnunet-service-transport.h" 34#include "gnunet-service-transport.h"
33#include "gnunet_peerinfo_service.h" 35#include "gnunet_peerinfo_service.h"
34#include "gnunet-service-transport_blacklist.h"
35#include "gnunet_constants.h" 36#include "gnunet_constants.h"
36#include "transport.h" 37#include "transport.h"
37 38
@@ -255,8 +256,6 @@ struct MessageQueue
255}; 256};
256 257
257 258
258
259
260/** 259/**
261 * A possible address we could use to communicate with a neighbour. 260 * A possible address we could use to communicate with a neighbour.
262 */ 261 */
@@ -301,6 +300,7 @@ struct NeighbourAddress
301 uint32_t keep_alive_nonce; 300 uint32_t keep_alive_nonce;
302}; 301};
303 302
303
304/** 304/**
305 * Entry in neighbours. 305 * Entry in neighbours.
306 */ 306 */
@@ -344,12 +344,12 @@ struct NeighbourMapEntry
344 * Main task that drives this peer (timeouts, keepalives, etc.). 344 * Main task that drives this peer (timeouts, keepalives, etc.).
345 * Always runs the 'master_task'. 345 * Always runs the 'master_task'.
346 */ 346 */
347 struct GNUNET_SCHEDULER_Task * task; 347 struct GNUNET_SCHEDULER_Task *task;
348 348
349 /** 349 /**
350 * Task to disconnect neighbour after we received a DISCONNECT message 350 * Task to disconnect neighbour after we received a DISCONNECT message
351 */ 351 */
352 struct GNUNET_SCHEDULER_Task * delayed_disconnect_task; 352 struct GNUNET_SCHEDULER_Task *delayed_disconnect_task;
353 353
354 /** 354 /**
355 * At what time should we sent the next keep-alive message? 355 * At what time should we sent the next keep-alive message?
@@ -480,7 +480,7 @@ struct BlackListCheckContext
480 480
481 481
482/** 482/**
483 * Hash map from peer identities to the respective 'struct NeighbourMapEntry'. 483 * Hash map from peer identities to the respective `struct NeighbourMapEntry`.
484 */ 484 */
485static struct GNUNET_CONTAINER_MultiPeerMap *neighbours; 485static struct GNUNET_CONTAINER_MultiPeerMap *neighbours;
486 486
@@ -541,9 +541,15 @@ static unsigned long long bytes_in_send_queue;
541 */ 541 */
542static struct GNUNET_SCHEDULER_Task * util_transmission_tk; 542static struct GNUNET_SCHEDULER_Task * util_transmission_tk;
543 543
544 544/**
545 * FIXME
546 */
545static struct GNUNET_CONTAINER_MultiPeerMap *registered_quota_notifications; 547static struct GNUNET_CONTAINER_MultiPeerMap *registered_quota_notifications;
546 548
549
550/**
551 * FIXME
552 */
547static char * 553static char *
548print_ack_state (enum GST_ACK_State s) 554print_ack_state (enum GST_ACK_State s)
549{ 555{
@@ -589,6 +595,7 @@ test_connected (struct NeighbourMapEntry *n)
589 return GNUNET_TRANSPORT_is_connected (n->state); 595 return GNUNET_TRANSPORT_is_connected (n->state);
590} 596}
591 597
598
592/** 599/**
593 * Send information about a new outbound quota to our clients. 600 * Send information about a new outbound quota to our clients.
594 * 601 *
@@ -701,9 +708,10 @@ set_timeout (struct NeighbourMapEntry *n,
701 struct GNUNET_TIME_Absolute timeout) 708 struct GNUNET_TIME_Absolute timeout)
702{ 709{
703 n->timeout = timeout; 710 n->timeout = timeout;
704 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Neighbour `%s' changed timeout %s\n", 711 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
705 GNUNET_i2s (&n->id), 712 "Neighbour `%s' changed timeout %s\n",
706 GNUNET_STRINGS_absolute_time_to_string (timeout)); 713 GNUNET_i2s (&n->id),
714 GNUNET_STRINGS_absolute_time_to_string (timeout));
707 neighbour_change_cb (callback_cls, 715 neighbour_change_cb (callback_cls,
708 &n->id, 716 &n->id,
709 n->primary_address.address, 717 n->primary_address.address,
@@ -732,6 +740,7 @@ set_alternative_address (struct NeighbourMapEntry *n,
732 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) 740 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
733{ 741{
734 struct GNUNET_TRANSPORT_PluginFunctions *papi; 742 struct GNUNET_TRANSPORT_PluginFunctions *papi;
743
735 if (NULL == (papi = GST_plugins_find (address->transport_name))) 744 if (NULL == (papi = GST_plugins_find (address->transport_name)))
736 { 745 {
737 GNUNET_break (0); 746 GNUNET_break (0);
@@ -750,14 +759,19 @@ set_alternative_address (struct NeighbourMapEntry *n,
750 { 759 {
751 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 760 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
752 "Failed to obtain new session for peer `%s' and address '%s'\n", 761 "Failed to obtain new session for peer `%s' and address '%s'\n",
753 GNUNET_i2s (&address->peer), GST_plugins_a2s (address)); 762 GNUNET_i2s (&address->peer),
754 GNUNET_ATS_address_destroyed (GST_ats, address, NULL); 763 GST_plugins_a2s (address));
764 GNUNET_STATISTICS_update (GST_stats,
765 gettext_noop ("# session creation failed"),
766 1,
767 GNUNET_NO);
755 return; 768 return;
756 } 769 }
757 770 GST_ats_new_session (address, session);
758 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Neighbour `%s' configured alternative address %s\n", 771 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
759 GNUNET_i2s (&n->id), 772 "Neighbour `%s' configured alternative address %s\n",
760 GST_plugins_a2s(address)); 773 GNUNET_i2s (&n->id),
774 GST_plugins_a2s(address));
761 775
762 n->alternative_address.address = GNUNET_HELLO_address_copy (address); 776 n->alternative_address.address = GNUNET_HELLO_address_copy (address);
763 n->alternative_address.bandwidth_in = bandwidth_in; 777 n->alternative_address.bandwidth_in = bandwidth_in;
@@ -802,8 +816,13 @@ set_primary_address (struct NeighbourMapEntry *n,
802 if (is_active != n->primary_address.ats_active) 816 if (is_active != n->primary_address.ats_active)
803 { 817 {
804 n->primary_address.ats_active = is_active; 818 n->primary_address.ats_active = is_active;
805 GNUNET_ATS_address_in_use (GST_ats, n->primary_address.address, n->primary_address.session, is_active); 819 GNUNET_ATS_address_in_use (GST_ats,
806 GST_validation_set_address_use (n->primary_address.address, n->primary_address.session, is_active); 820 n->primary_address.address,
821 n->primary_address.session,
822 is_active);
823 GST_validation_set_address_use (n->primary_address.address,
824 n->primary_address.session,
825 is_active);
807 } 826 }
808 if (GNUNET_YES == is_active) 827 if (GNUNET_YES == is_active)
809 { 828 {
@@ -820,10 +839,13 @@ set_primary_address (struct NeighbourMapEntry *n,
820 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 839 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
821 "Failed to obtain new session for peer `%s' and address '%s'\n", 840 "Failed to obtain new session for peer `%s' and address '%s'\n",
822 GNUNET_i2s (&address->peer), GST_plugins_a2s (address)); 841 GNUNET_i2s (&address->peer), GST_plugins_a2s (address));
823 GNUNET_ATS_address_destroyed (GST_ats, address, NULL); 842 GNUNET_STATISTICS_update (GST_stats,
843 gettext_noop ("# session creation failed"),
844 1,
845 GNUNET_NO);
824 return; 846 return;
825 } 847 }
826 848 GST_ats_new_session (address, session);
827 n->primary_address.address = GNUNET_HELLO_address_copy (address); 849 n->primary_address.address = GNUNET_HELLO_address_copy (address);
828 n->primary_address.bandwidth_in = bandwidth_in; 850 n->primary_address.bandwidth_in = bandwidth_in;
829 n->primary_address.bandwidth_out = bandwidth_out; 851 n->primary_address.bandwidth_out = bandwidth_out;
@@ -833,24 +855,31 @@ set_primary_address (struct NeighbourMapEntry *n,
833 if (GNUNET_YES == is_active) 855 if (GNUNET_YES == is_active)
834 { 856 {
835 /* Telling ATS about new session */ 857 /* Telling ATS about new session */
836 GNUNET_ATS_address_in_use (GST_ats, n->primary_address.address, n->primary_address.session, GNUNET_YES); 858 GNUNET_ATS_address_in_use (GST_ats,
837 GST_validation_set_address_use (n->primary_address.address, n->primary_address.session, GNUNET_YES); 859 n->primary_address.address,
860 n->primary_address.session,
861 GNUNET_YES);
862 GST_validation_set_address_use (n->primary_address.address,
863 n->primary_address.session,
864 GNUNET_YES);
838 GST_neighbours_set_incoming_quota (&address->peer, bandwidth_in); 865 GST_neighbours_set_incoming_quota (&address->peer, bandwidth_in);
839 send_outbound_quota (&address->peer, bandwidth_out); 866 send_outbound_quota (&address->peer, bandwidth_out);
840 } 867 }
841 868
842 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Neighbour `%s' switched to address `%s'\n", 869 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
843 GNUNET_i2s (&n->id), 870 "Neighbour `%s' switched to address `%s'\n",
844 GST_plugins_a2s(address)); 871 GNUNET_i2s (&n->id),
872 GST_plugins_a2s(address));
845 873
846 neighbour_change_cb (callback_cls, 874 neighbour_change_cb (callback_cls,
847 &n->id, 875 &n->id,
848 n->primary_address.address, 876 n->primary_address.address,
849 n->state, n->timeout, 877 n->state, n->timeout,
850 n->primary_address.bandwidth_in, 878 n->primary_address.bandwidth_in,
851 n->primary_address.bandwidth_out); 879 n->primary_address.bandwidth_out);
852} 880}
853 881
882
854/** 883/**
855 * Clear the primary address of a neighbour since this address is not 884 * Clear the primary address of a neighbour since this address is not
856 * valid anymore and notify monitoring about it 885 * valid anymore and notify monitoring about it
@@ -865,13 +894,14 @@ unset_primary_address (struct NeighbourMapEntry *n)
865 894
866 /* Notify monitoring about it */ 895 /* Notify monitoring about it */
867 neighbour_change_cb (callback_cls, 896 neighbour_change_cb (callback_cls,
868 &n->id, 897 &n->id,
869 NULL, 898 NULL,
870 n->state, n->timeout, 899 n->state, n->timeout,
871 n->primary_address.bandwidth_in, 900 n->primary_address.bandwidth_in,
872 n->primary_address.bandwidth_out); 901 n->primary_address.bandwidth_out);
873} 902}
874 903
904
875/** 905/**
876 * Clear the alternative address of a neighbour since this address is not 906 * Clear the alternative address of a neighbour since this address is not
877 * valid anymore 907 * valid anymore
@@ -885,6 +915,7 @@ unset_alternative_address (struct NeighbourMapEntry *n)
885 free_address (&n->alternative_address); 915 free_address (&n->alternative_address);
886} 916}
887 917
918
888/** 919/**
889 * Free a neighbour map entry. 920 * Free a neighbour map entry.
890 * 921 *
@@ -937,6 +968,8 @@ free_neighbour (struct NeighbourMapEntry *n,
937 free_address (&n->alternative_address); 968 free_address (&n->alternative_address);
938 969
939 /* cut all transport-level connection for this peer */ 970 /* cut all transport-level connection for this peer */
971 // FIXME: might want to revisit this; maybe just
972 // shorten session timeout on plugin level?
940 if ((GNUNET_NO == keep_sessions) && 973 if ((GNUNET_NO == keep_sessions) &&
941 (NULL != backup_primary) && 974 (NULL != backup_primary) &&
942 (NULL != (papi = GST_plugins_find (backup_primary->transport_name)))) 975 (NULL != (papi = GST_plugins_find (backup_primary->transport_name))))
@@ -1369,7 +1402,7 @@ send_keepalive (struct NeighbourMapEntry *n)
1369 */ 1402 */
1370void 1403void
1371GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour, 1404GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour,
1372 const struct GNUNET_MessageHeader *m) 1405 const struct GNUNET_MessageHeader *m)
1373{ 1406{
1374 struct NeighbourMapEntry *n; 1407 struct NeighbourMapEntry *n;
1375 const struct SessionKeepAliveMessage *msg_in; 1408 const struct SessionKeepAliveMessage *msg_in;
@@ -1422,7 +1455,7 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour,
1422 */ 1455 */
1423void 1456void
1424GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour, 1457GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour,
1425 const struct GNUNET_MessageHeader *m) 1458 const struct GNUNET_MessageHeader *m)
1426{ 1459{
1427 struct NeighbourMapEntry *n; 1460 struct NeighbourMapEntry *n;
1428 const struct SessionKeepAliveMessage *msg; 1461 const struct SessionKeepAliveMessage *msg;
@@ -1505,8 +1538,9 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour,
1505 else 1538 else
1506 latency = n->latency.rel_value_us; 1539 latency = n->latency.rel_value_us;
1507 ats.value = htonl (latency); 1540 ats.value = htonl (latency);
1508 GST_ats_update_metrics (&n->id, n->primary_address.address, 1541 GST_ats_update_metrics (n->primary_address.address,
1509 n->primary_address.session, &ats, 1); 1542 n->primary_address.session,
1543 &ats, 1);
1510} 1544}
1511 1545
1512 1546
@@ -1655,12 +1689,13 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg,
1655 n->task = GNUNET_SCHEDULER_add_now (&master_task, n); 1689 n->task = GNUNET_SCHEDULER_add_now (&master_task, n);
1656} 1690}
1657 1691
1692
1658static void 1693static void
1659send_session_connect_cont (void *cls, 1694send_session_connect_cont (void *cls,
1660 const struct GNUNET_PeerIdentity *target, 1695 const struct GNUNET_PeerIdentity *target,
1661 int result, 1696 int result,
1662 size_t size_payload, 1697 size_t size_payload,
1663 size_t size_on_wire) 1698 size_t size_on_wire)
1664{ 1699{
1665 struct NeighbourMapEntry *n; 1700 struct NeighbourMapEntry *n;
1666 1701
@@ -1686,26 +1721,20 @@ send_session_connect_cont (void *cls,
1686 return; 1721 return;
1687 1722
1688 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1723 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1689 _("Failed to send SYN message to peer `%s' using address `%s' session %p\n"), 1724 _("Failed to send SYN message to peer `%s' using address `%s' session %p\n"),
1690 GNUNET_i2s (target), 1725 GNUNET_i2s (target),
1691 GST_plugins_a2s (n->primary_address.address), 1726 GST_plugins_a2s (n->primary_address.address),
1692 n->primary_address.session); 1727 n->primary_address.session);
1693 1728
1694 switch (n->state) { 1729 switch (n->state) {
1695 case GNUNET_TRANSPORT_PS_SYN_SENT: 1730 case GNUNET_TRANSPORT_PS_SYN_SENT:
1696 /* Remove address and request and additional one */ 1731 /* Remove address and request and additional one */
1697 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address,
1698 n->primary_address.session);
1699 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, NULL );
1700 unset_primary_address (n); 1732 unset_primary_address (n);
1701 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, 1733 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS,
1702 GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT)); 1734 GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT));
1703 break; 1735 break;
1704 case GNUNET_TRANSPORT_PS_RECONNECT_SENT: 1736 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
1705 /* Remove address and request and additional one */ 1737 /* Remove address and request and additional one */
1706 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address,
1707 n->primary_address.session);
1708 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, NULL );
1709 unset_primary_address (n); 1738 unset_primary_address (n);
1710 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS, 1739 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS,
1711 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); 1740 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
@@ -1714,10 +1743,6 @@ send_session_connect_cont (void *cls,
1714 /* Remove address and request and go back to primary address */ 1743 /* Remove address and request and go back to primary address */
1715 GNUNET_STATISTICS_update (GST_stats, gettext_noop 1744 GNUNET_STATISTICS_update (GST_stats, gettext_noop
1716 ("# Failed attempts to switch addresses (failed to send SYN CONT)"), 1, GNUNET_NO); 1745 ("# Failed attempts to switch addresses (failed to send SYN CONT)"), 1, GNUNET_NO);
1717 GNUNET_ATS_address_destroyed (GST_ats, n->alternative_address.address,
1718 n->alternative_address.session);
1719 GNUNET_ATS_address_destroyed (GST_ats, n->alternative_address.address,
1720 NULL );
1721 unset_alternative_address (n); 1746 unset_alternative_address (n);
1722 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, 1747 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED,
1723 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); 1748 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
@@ -1756,6 +1781,8 @@ send_syn (struct NeighbourAddress *na)
1756 GNUNET_break (0); 1781 GNUNET_break (0);
1757 return; 1782 return;
1758 } 1783 }
1784 GST_ats_new_session (na->address,
1785 na->session);
1759 GNUNET_STATISTICS_update (GST_stats, 1786 GNUNET_STATISTICS_update (GST_stats,
1760 gettext_noop 1787 gettext_noop
1761 ("# SYN messages sent"), 1788 ("# SYN messages sent"),
@@ -1811,8 +1838,6 @@ send_syn (struct NeighbourAddress *na)
1811 disconnect_neighbour (n); 1838 disconnect_neighbour (n);
1812 break; 1839 break;
1813 } 1840 }
1814 GNUNET_ATS_address_destroyed (GST_ats, na->address, na->session);
1815 GNUNET_ATS_address_destroyed (GST_ats, na->address, NULL);
1816 } 1841 }
1817 GST_neighbours_notify_data_sent (&na->address->peer, 1842 GST_neighbours_notify_data_sent (&na->address->peer,
1818 na->address, 1843 na->address,
@@ -1855,12 +1880,6 @@ send_session_connect_ack_cont (void *cls,
1855 GST_plugins_a2s (n->primary_address.address), 1880 GST_plugins_a2s (n->primary_address.address),
1856 n->primary_address.session); 1881 n->primary_address.session);
1857 1882
1858 /* Failed to send SYN_ACK message with this address */
1859 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address,
1860 n->primary_address.session);
1861 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address,
1862 NULL);
1863
1864 /* Remove address and request and additional one */ 1883 /* Remove address and request and additional one */
1865 unset_primary_address (n); 1884 unset_primary_address (n);
1866 n->ack_state = ACK_SEND_SYN_ACK; 1885 n->ack_state = ACK_SEND_SYN_ACK;
@@ -1903,6 +1922,7 @@ send_connect_ack_message (const struct GNUNET_HELLO_Address *address,
1903 GNUNET_break (0); 1922 GNUNET_break (0);
1904 return; 1923 return;
1905 } 1924 }
1925 GST_ats_new_session (address, session);
1906 GNUNET_STATISTICS_update (GST_stats, 1926 GNUNET_STATISTICS_update (GST_stats,
1907 gettext_noop 1927 gettext_noop
1908 ("# SYN_ACK messages sent"), 1928 ("# SYN_ACK messages sent"),
@@ -1929,17 +1949,6 @@ send_connect_ack_message (const struct GNUNET_HELLO_Address *address,
1929 GNUNET_break (0); 1949 GNUNET_break (0);
1930 return; 1950 return;
1931 } 1951 }
1932 /* Hard failure to send the SYN_ACK message with this address:
1933 Destroy session (and address) */
1934 if (GNUNET_YES == GNUNET_HELLO_address_check_option(address,
1935 GNUNET_HELLO_ADDRESS_INFO_INBOUND))
1936 {
1937 GNUNET_ATS_address_destroyed (GST_ats, address, session);
1938 GNUNET_ATS_address_destroyed (GST_ats, address, NULL);
1939 }
1940 else
1941 GNUNET_ATS_address_destroyed (GST_ats, address, session);
1942
1943 /* Remove address and request and additional one */ 1952 /* Remove address and request and additional one */
1944 unset_primary_address (n); 1953 unset_primary_address (n);
1945 n->ack_state = ACK_SEND_SYN_ACK; 1954 n->ack_state = ACK_SEND_SYN_ACK;
@@ -1973,7 +1982,9 @@ find_notification_request (void *cls, const struct GNUNET_PeerIdentity *key, voi
1973 struct QuotaNotificationRequest *qnr = value; 1982 struct QuotaNotificationRequest *qnr = value;
1974 1983
1975 if ((qnr->session == qnr_ctx->session) && 1984 if ((qnr->session == qnr_ctx->session) &&
1976 (0 == memcmp (&qnr->peer, &qnr_ctx->peer, sizeof (struct GNUNET_PeerIdentity))) && 1985 (0 == memcmp (&qnr->peer,
1986 &qnr_ctx->peer,
1987 sizeof (struct GNUNET_PeerIdentity))) &&
1977 (0 == strcmp(qnr_ctx->plugin, qnr->plugin))) 1988 (0 == strcmp(qnr_ctx->plugin, qnr->plugin)))
1978 { 1989 {
1979 qnr_ctx->res = value; 1990 qnr_ctx->res = value;
@@ -1982,10 +1993,12 @@ find_notification_request (void *cls, const struct GNUNET_PeerIdentity *key, voi
1982 return GNUNET_YES; 1993 return GNUNET_YES;
1983} 1994}
1984 1995
1996
1985void 1997void
1986GST_neighbours_register_quota_notification(void *cls, 1998GST_neighbours_register_quota_notification (void *cls,
1987 const struct GNUNET_PeerIdentity *peer, const char *plugin, 1999 const struct GNUNET_PeerIdentity *peer,
1988 struct Session *session) 2000 const char *plugin,
2001 struct Session *session)
1989{ 2002{
1990 struct QuotaNotificationRequest *qnr; 2003 struct QuotaNotificationRequest *qnr;
1991 struct QNR_LookContext qnr_ctx; 2004 struct QNR_LookContext qnr_ctx;
@@ -2024,7 +2037,9 @@ GST_neighbours_register_quota_notification(void *cls,
2024 2037
2025void 2038void
2026GST_neighbours_unregister_quota_notification(void *cls, 2039GST_neighbours_unregister_quota_notification(void *cls,
2027 const struct GNUNET_PeerIdentity *peer, const char *plugin, struct Session *session) 2040 const struct GNUNET_PeerIdentity *peer,
2041 const char *plugin,
2042 struct Session *session)
2028{ 2043{
2029 struct QNR_LookContext qnr_ctx; 2044 struct QNR_LookContext qnr_ctx;
2030 2045
@@ -2056,8 +2071,11 @@ GST_neighbours_unregister_quota_notification(void *cls,
2056 GNUNET_free (qnr_ctx.res); 2071 GNUNET_free (qnr_ctx.res);
2057} 2072}
2058 2073
2074
2059static int 2075static int
2060notification_cb(void *cls, const struct GNUNET_PeerIdentity *key, void *value) 2076notification_cb (void *cls,
2077 const struct GNUNET_PeerIdentity *key,
2078 void *value)
2061{ 2079{
2062 /* struct NeighbourMapEntry *n = cls; */ 2080 /* struct NeighbourMapEntry *n = cls; */
2063 struct QuotaNotificationRequest *qnr = value; 2081 struct QuotaNotificationRequest *qnr = value;
@@ -2082,9 +2100,11 @@ notification_cb(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
2082 return GNUNET_OK; 2100 return GNUNET_OK;
2083} 2101}
2084 2102
2103
2085static int 2104static int
2086free_notification_cb(void *cls, const struct GNUNET_PeerIdentity *key, 2105free_notification_cb (void *cls,
2087 void *value) 2106 const struct GNUNET_PeerIdentity *key,
2107 void *value)
2088{ 2108{
2089 /* struct NeighbourMapEntry *n = cls; */ 2109 /* struct NeighbourMapEntry *n = cls; */
2090 struct QuotaNotificationRequest *qnr = value; 2110 struct QuotaNotificationRequest *qnr = value;
@@ -2097,8 +2117,9 @@ free_notification_cb(void *cls, const struct GNUNET_PeerIdentity *key,
2097 return GNUNET_OK; 2117 return GNUNET_OK;
2098} 2118}
2099 2119
2120
2100static void 2121static void
2101inbound_bw_tracker_update(void *cls) 2122inbound_bw_tracker_update (void *cls)
2102{ 2123{
2103 struct NeighbourMapEntry *n = cls; 2124 struct NeighbourMapEntry *n = cls;
2104 2125
@@ -2144,18 +2165,44 @@ setup_neighbour (const struct GNUNET_PeerIdentity *peer)
2144} 2165}
2145 2166
2146 2167
2168/**
2169 * FIXME
2170 */
2147struct BlacklistCheckSwitchContext 2171struct BlacklistCheckSwitchContext
2148{ 2172{
2173 /**
2174 * FIXME
2175 */
2149 struct BlacklistCheckSwitchContext *prev; 2176 struct BlacklistCheckSwitchContext *prev;
2150 struct BlacklistCheckSwitchContext *next;
2151 2177
2178 /**
2179 * FIXME
2180 */
2181 struct BlacklistCheckSwitchContext *next;
2152 2182
2183 /**
2184 * FIXME
2185 */
2153 struct GST_BlacklistCheck *blc; 2186 struct GST_BlacklistCheck *blc;
2154 2187
2188 /**
2189 * FIXME
2190 */
2155 struct GNUNET_HELLO_Address *address; 2191 struct GNUNET_HELLO_Address *address;
2192
2193 /**
2194 * FIXME
2195 */
2156 struct Session *session; 2196 struct Session *session;
2157 2197
2198 /**
2199 * FIXME
2200 */
2158 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in; 2201 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
2202
2203 /**
2204 * FIXME
2205 */
2159 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out; 2206 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
2160}; 2207};
2161 2208
@@ -2465,18 +2512,13 @@ switch_address_bl_check_cont (void *cls,
2465 GNUNET_i2s (&blc_ctx->address->peer)); 2512 GNUNET_i2s (&blc_ctx->address->peer));
2466 } 2513 }
2467 2514
2468 /* This address is blacklisted, delete address and session (if existing) in ATS */ 2515 /* This address is blacklisted, delete session */
2469 GNUNET_ATS_address_destroyed (GST_ats, blc_ctx->address, blc_ctx->session); 2516 /* FIXME: tell plugin to force killing session here and now! */
2470
2471 if ( (GNUNET_YES == (GNUNET_HELLO_address_check_option (blc_ctx->address,
2472 GNUNET_HELLO_ADDRESS_INFO_INBOUND))) && (NULL != blc_ctx->session))
2473 {
2474 /* This is an inbound address, destroy full address */
2475 GNUNET_ATS_address_destroyed (GST_ats, blc_ctx->address, NULL );
2476 }
2477 2517
2478 /* Remove blacklist check and clean up */ 2518 /* Remove blacklist check and clean up */
2479 GNUNET_CONTAINER_DLL_remove (pending_bc_head, pending_bc_tail, blc_ctx); 2519 GNUNET_CONTAINER_DLL_remove (pending_bc_head,
2520 pending_bc_tail,
2521 blc_ctx);
2480 GNUNET_HELLO_address_free (blc_ctx->address); 2522 GNUNET_HELLO_address_free (blc_ctx->address);
2481 GNUNET_free (blc_ctx); 2523 GNUNET_free (blc_ctx);
2482 return; 2524 return;
@@ -2484,10 +2526,17 @@ switch_address_bl_check_cont (void *cls,
2484 2526
2485 if (NULL == blc_ctx->session) 2527 if (NULL == blc_ctx->session)
2486 { 2528 {
2487 blc_ctx->session = papi->get_session (papi->cls, blc_ctx->address); 2529 blc_ctx->session = papi->get_session (papi->cls,
2530 blc_ctx->address);
2488 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2531 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2489 "Obtained new session for peer `%s' and address '%s': %p\n", 2532 "Obtained new session for peer `%s' and address '%s': %p\n",
2490 GNUNET_i2s (&blc_ctx->address->peer), GST_plugins_a2s (blc_ctx->address), blc_ctx->session); 2533 GNUNET_i2s (&blc_ctx->address->peer),
2534 GST_plugins_a2s (blc_ctx->address),
2535 blc_ctx->session);
2536 if (NULL != blc_ctx->session)
2537 GST_ats_new_session (blc_ctx->address,
2538 blc_ctx->session);
2539
2491 } 2540 }
2492 if (NULL == blc_ctx->session) 2541 if (NULL == blc_ctx->session)
2493 { 2542 {
@@ -2497,9 +2546,9 @@ switch_address_bl_check_cont (void *cls,
2497 GNUNET_i2s (&blc_ctx->address->peer), 2546 GNUNET_i2s (&blc_ctx->address->peer),
2498 GST_plugins_a2s (blc_ctx->address)); 2547 GST_plugins_a2s (blc_ctx->address));
2499 /* Delete address in ATS */ 2548 /* Delete address in ATS */
2500 GNUNET_ATS_address_destroyed (GST_ats, blc_ctx->address, NULL); 2549 GNUNET_CONTAINER_DLL_remove (pending_bc_head,
2501 2550 pending_bc_tail,
2502 GNUNET_CONTAINER_DLL_remove (pending_bc_head, pending_bc_tail, blc_ctx); 2551 blc_ctx);
2503 GNUNET_HELLO_address_free (blc_ctx->address); 2552 GNUNET_HELLO_address_free (blc_ctx->address);
2504 GNUNET_free (blc_ctx); 2553 GNUNET_free (blc_ctx);
2505 return; 2554 return;
@@ -2721,21 +2770,15 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
2721 if (NULL == (GST_plugins_find (address->transport_name))) 2770 if (NULL == (GST_plugins_find (address->transport_name)))
2722 { 2771 {
2723 /* we don't have the plugin for this address */ 2772 /* we don't have the plugin for this address */
2724 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2773 GNUNET_break (0);
2725 "Plugin `%s' is unknown, suggestion for peer %s ignored\n",
2726 address->transport_name,
2727 GNUNET_i2s (peer));
2728 GNUNET_ATS_address_destroyed (GST_ats, address, NULL);
2729 return; 2774 return;
2730 } 2775 }
2731 if ((NULL == session) && 2776 if ((NULL == session) &&
2732 (GNUNET_HELLO_address_check_option (address, GNUNET_HELLO_ADDRESS_INFO_INBOUND))) 2777 (GNUNET_HELLO_address_check_option (address,
2778 GNUNET_HELLO_ADDRESS_INFO_INBOUND)))
2733 { 2779 {
2734 /* This is a inbound address and we do not have a session to use! */ 2780 /* This is a inbound address and we do not have a session to use! */
2735 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2781 GNUNET_break (0);
2736 "Inbound address without session `%s'! Destroying address...\n",
2737 GST_plugins_a2s (address));
2738 GNUNET_ATS_address_destroyed (GST_ats, address, NULL);
2739 return; 2782 return;
2740 } 2783 }
2741 2784
@@ -2766,6 +2809,15 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
2766} 2809}
2767 2810
2768 2811
2812/**
2813 * Function called to send network utilization data to ATS for
2814 * each active connection.
2815 *
2816 * @param cls NULL
2817 * @param key peer we send utilization data for
2818 * @param value the `struct NeighbourMapEntry *` with data to send
2819 * @return #GNUNET_OK (continue to iterate)
2820 */
2769static int 2821static int
2770send_utilization_data (void *cls, 2822send_utilization_data (void *cls,
2771 const struct GNUNET_PeerIdentity *key, 2823 const struct GNUNET_PeerIdentity *key,
@@ -2779,6 +2831,8 @@ send_utilization_data (void *cls,
2779 uint32_t bps_out; 2831 uint32_t bps_out;
2780 struct GNUNET_TIME_Relative delta; 2832 struct GNUNET_TIME_Relative delta;
2781 2833
2834 if (GNUNET_TRANSPORT_PS_CONNECTED != n->state)
2835 return GNUNET_OK;
2782 delta = GNUNET_TIME_absolute_get_difference (n->last_util_transmission, 2836 delta = GNUNET_TIME_absolute_get_difference (n->last_util_transmission,
2783 GNUNET_TIME_absolute_get ()); 2837 GNUNET_TIME_absolute_get ());
2784 2838
@@ -2817,8 +2871,9 @@ send_utilization_data (void *cls,
2817 atsi[3].type = htonl (GNUNET_ATS_UTILIZATION_PAYLOAD_IN); 2871 atsi[3].type = htonl (GNUNET_ATS_UTILIZATION_PAYLOAD_IN);
2818 atsi[3].value = htonl (bps_pl_in); 2872 atsi[3].value = htonl (bps_pl_in);
2819 2873
2820 GST_ats_update_metrics (key, n->primary_address.address, 2874 GST_ats_update_metrics (n->primary_address.address,
2821 n->primary_address.session, atsi, 4); 2875 n->primary_address.session,
2876 atsi, 4);
2822 n->util_payload_bytes_recv = 0; 2877 n->util_payload_bytes_recv = 0;
2823 n->util_payload_bytes_sent = 0; 2878 n->util_payload_bytes_sent = 0;
2824 n->util_total_bytes_recv = 0; 2879 n->util_total_bytes_recv = 0;
@@ -2952,12 +3007,6 @@ master_task (void *cls,
2952 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3007 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2953 "Connection to `%s' timed out waiting for other peer to send SYN_ACK\n", 3008 "Connection to `%s' timed out waiting for other peer to send SYN_ACK\n",
2954 GNUNET_i2s (&n->id)); 3009 GNUNET_i2s (&n->id));
2955 /* We could not send to this address, delete address and session */
2956 if (NULL != n->primary_address.session)
2957 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address,
2958 n->primary_address.session);
2959 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, NULL);
2960
2961 /* Remove address and request and additional one */ 3010 /* Remove address and request and additional one */
2962 unset_primary_address (n); 3011 unset_primary_address (n);
2963 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, 3012 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS,
@@ -3023,8 +3072,10 @@ master_task (void *cls,
3023 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3072 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3024 "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs (after trying to SYN on alternative address)\n", 3073 "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs (after trying to SYN on alternative address)\n",
3025 GNUNET_i2s (&n->id)); 3074 GNUNET_i2s (&n->id));
3026 GNUNET_STATISTICS_update (GST_stats, gettext_noop 3075 GNUNET_STATISTICS_update (GST_stats,
3027 ("# Failed attempts to switch addresses (no response)"), 1, GNUNET_NO); 3076 gettext_noop ("# Failed attempts to switch addresses (no response)"),
3077 1,
3078 GNUNET_NO);
3028 disconnect_neighbour (n); 3079 disconnect_neighbour (n);
3029 return; 3080 return;
3030 } 3081 }
@@ -3161,17 +3212,12 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag
3161 n->primary_address.bandwidth_in, 3212 n->primary_address.bandwidth_in,
3162 n->primary_address.bandwidth_out); 3213 n->primary_address.bandwidth_out);
3163 /* Tell ATS that the outbound session we created to send SYN was successful */ 3214 /* Tell ATS that the outbound session we created to send SYN was successful */
3164 // FIXME: shouldn't ATS already know about *outbound* sessions
3165 // in particular?
3166 GST_ats_add_address (n->primary_address.address,
3167 n->primary_address.session,
3168 NULL, 0);
3169 set_primary_address (n, 3215 set_primary_address (n,
3170 n->primary_address.address, 3216 n->primary_address.address,
3171 n->primary_address.session, 3217 n->primary_address.session,
3172 n->primary_address.bandwidth_in, 3218 n->primary_address.bandwidth_in,
3173 n->primary_address.bandwidth_out, 3219 n->primary_address.bandwidth_out,
3174 GNUNET_YES); 3220 GNUNET_YES);
3175 send_session_ack_message (n); 3221 send_session_ack_message (n);
3176 break; 3222 break;
3177 case GNUNET_TRANSPORT_PS_SYN_RECV_ATS: 3223 case GNUNET_TRANSPORT_PS_SYN_RECV_ATS:
@@ -3202,13 +3248,9 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag
3202 case GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT: 3248 case GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT:
3203 /* new address worked; adopt it and go back to connected! */ 3249 /* new address worked; adopt it and go back to connected! */
3204 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, 3250 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED,
3205 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT)); 3251 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT));
3206 GNUNET_break (GNUNET_NO == n->alternative_address.ats_active); 3252 GNUNET_break (GNUNET_NO == n->alternative_address.ats_active);
3207 3253
3208 /* Notify about session... perhaps we obtained it */
3209 // FIXME: why is this needed?
3210 GST_ats_add_address (n->alternative_address.address,
3211 n->alternative_address.session, NULL, 0);
3212 /* Set primary addresses */ 3254 /* Set primary addresses */
3213 set_primary_address (n, n->alternative_address.address, 3255 set_primary_address (n, n->alternative_address.address,
3214 n->alternative_address.session, n->alternative_address.bandwidth_in, 3256 n->alternative_address.session, n->alternative_address.bandwidth_in,
@@ -3309,7 +3351,6 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
3309 GNUNET_i2s (peer)); 3351 GNUNET_i2s (peer));
3310 3352
3311 /* Destroy the address since it cannot be used */ 3353 /* Destroy the address since it cannot be used */
3312 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, NULL);
3313 unset_primary_address (n); 3354 unset_primary_address (n);
3314 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, 3355 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS,
3315 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); 3356 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
@@ -3337,9 +3378,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
3337 GST_plugins_a2s (n->primary_address.address), 3378 GST_plugins_a2s (n->primary_address.address),
3338 n->primary_address.session, 3379 n->primary_address.session,
3339 GNUNET_i2s (peer)); 3380 GNUNET_i2s (peer));
3340
3341 /* Destroy the address since it cannot be used */ 3381 /* Destroy the address since it cannot be used */
3342 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, NULL);
3343 unset_primary_address (n); 3382 unset_primary_address (n);
3344 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS, 3383 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS,
3345 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); 3384 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
@@ -3358,13 +3397,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
3358 n->alternative_address.session); 3397 n->alternative_address.session);
3359 3398
3360 /* Destroy the inbound address since it cannot be used */ 3399 /* Destroy the inbound address since it cannot be used */
3361 if (GNUNET_YES
3362 == GNUNET_HELLO_address_check_option (n->primary_address.address,
3363 GNUNET_HELLO_ADDRESS_INFO_INBOUND))
3364 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, NULL);
3365 free_address (&n->primary_address); 3400 free_address (&n->primary_address);
3366
3367
3368 n->primary_address = n->alternative_address; 3401 n->primary_address = n->alternative_address;
3369 memset (&n->alternative_address, 0, sizeof (struct NeighbourAddress)); 3402 memset (&n->alternative_address, 0, sizeof (struct NeighbourAddress));
3370 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_SENT, 3403 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_SENT,
@@ -3487,20 +3520,13 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
3487 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, 3520 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED,
3488 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT)); 3521 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT));
3489 3522
3490 /* Add session to ATS since no session was given (NULL) and we may have
3491 * obtained a new session */
3492 // FIXME: likely not the best place to do this...
3493 GST_ats_add_address (n->primary_address.address,
3494 n->primary_address.session,
3495 NULL, 0);
3496
3497 /* Set primary address to used */ 3523 /* Set primary address to used */
3498 set_primary_address (n, 3524 set_primary_address (n,
3499 n->primary_address.address, 3525 n->primary_address.address,
3500 n->primary_address.session, 3526 n->primary_address.session,
3501 n->primary_address.bandwidth_in, 3527 n->primary_address.bandwidth_in,
3502 n->primary_address.bandwidth_out, 3528 n->primary_address.bandwidth_out,
3503 GNUNET_YES); 3529 GNUNET_YES);
3504 return GNUNET_OK; 3530 return GNUNET_OK;
3505} 3531}
3506 3532
@@ -3554,8 +3580,10 @@ GST_neighbours_set_incoming_quota (const struct GNUNET_PeerIdentity *neighbour,
3554 disconnect_neighbour (n); 3580 disconnect_neighbour (n);
3555} 3581}
3556 3582
3557void delayed_disconnect (void *cls, 3583
3558 const struct GNUNET_SCHEDULER_TaskContext* tc) 3584static void
3585delayed_disconnect (void *cls,
3586 const struct GNUNET_SCHEDULER_TaskContext* tc)
3559{ 3587{
3560 struct NeighbourMapEntry *n = cls; 3588 struct NeighbourMapEntry *n = cls;
3561 3589
@@ -3563,11 +3591,6 @@ void delayed_disconnect (void *cls,
3563 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3591 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3564 "Disconnecting by request from peer %s\n", 3592 "Disconnecting by request from peer %s\n",
3565 GNUNET_i2s (&n->id)); 3593 GNUNET_i2s (&n->id));
3566
3567 if (NULL != n->primary_address.address)
3568 GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address,
3569 n->primary_address.session);
3570
3571 free_neighbour (n, GNUNET_NO); 3594 free_neighbour (n, GNUNET_NO);
3572} 3595}
3573 3596
@@ -3871,16 +3894,18 @@ GST_neighbours_stop ()
3871 GNUNET_SCHEDULER_cancel (util_transmission_tk); 3894 GNUNET_SCHEDULER_cancel (util_transmission_tk);
3872 util_transmission_tk = NULL; 3895 util_transmission_tk = NULL;
3873 } 3896 }
3874 3897 GNUNET_CONTAINER_multipeermap_iterate (neighbours,
3875 GNUNET_CONTAINER_multipeermap_iterate (neighbours, &disconnect_all_neighbours, 3898 &disconnect_all_neighbours,
3876 NULL ); 3899 NULL);
3877 GNUNET_CONTAINER_multipeermap_destroy (neighbours); 3900 GNUNET_CONTAINER_multipeermap_destroy (neighbours);
3878 3901
3879 next = pending_bc_head; 3902 next = pending_bc_head;
3880 for (cur = next; NULL != cur; cur = next ) 3903 for (cur = next; NULL != cur; cur = next)
3881 { 3904 {
3882 next = cur->next; 3905 next = cur->next;
3883 GNUNET_CONTAINER_DLL_remove (pending_bc_head, pending_bc_tail, cur); 3906 GNUNET_CONTAINER_DLL_remove (pending_bc_head,
3907 pending_bc_tail,
3908 cur);
3884 3909
3885 if (NULL != cur->blc) 3910 if (NULL != cur->blc)
3886 { 3911 {
@@ -3893,7 +3918,7 @@ GST_neighbours_stop ()
3893 } 3918 }
3894 3919
3895 GNUNET_CONTAINER_multipeermap_iterate (registered_quota_notifications, 3920 GNUNET_CONTAINER_multipeermap_iterate (registered_quota_notifications,
3896 &free_notification_cb, NULL); 3921 &free_notification_cb, NULL);
3897 GNUNET_CONTAINER_multipeermap_destroy (registered_quota_notifications); 3922 GNUNET_CONTAINER_multipeermap_destroy (registered_quota_notifications);
3898 registered_quota_notifications = NULL; 3923 registered_quota_notifications = NULL;
3899 3924