aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_neighbours.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-03 15:28:00 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-03 15:28:00 +0000
commitb4e898498bebd50dfceaaa939d28eb5150aa9984 (patch)
tree593188101e20d2d068fc558c619fd7ee91ac43ee /src/transport/gnunet-service-transport_neighbours.c
parent2a55e796b7266d9aede88f867de0c9434d6cc7bf (diff)
downloadgnunet-b4e898498bebd50dfceaaa939d28eb5150aa9984.tar.gz
gnunet-b4e898498bebd50dfceaaa939d28eb5150aa9984.zip
never destroy sessions on free_neighbour(), they should be destroyed by their own timeout
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c153
1 files changed, 79 insertions, 74 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 5fe2f5645..2ec446b82 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -977,16 +977,11 @@ unset_alternative_address (struct NeighbourMapEntry *n)
977 * Free a neighbour map entry. 977 * Free a neighbour map entry.
978 * 978 *
979 * @param n entry to free 979 * @param n entry to free
980 * @param keep_sessions #GNUNET_NO to tell plugin to terminate sessions,
981 * #GNUNET_YES to keep all sessions
982 */ 980 */
983static void 981static void
984free_neighbour (struct NeighbourMapEntry *n, 982free_neighbour (struct NeighbourMapEntry *n)
985 int keep_sessions)
986{ 983{
987 struct MessageQueue *mq; 984 struct MessageQueue *mq;
988 struct GNUNET_TRANSPORT_PluginFunctions *papi;
989 struct GNUNET_HELLO_Address *backup_primary;
990 985
991 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 986 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
992 "Freeing neighbour state of peer `%s'\n", 987 "Freeing neighbour state of peer `%s'\n",
@@ -1015,25 +1010,10 @@ free_neighbour (struct NeighbourMapEntry *n,
1015 /* Mark peer as disconnected */ 1010 /* Mark peer as disconnected */
1016 set_state (n, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED); 1011 set_state (n, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED);
1017 1012
1018 if (NULL != n->primary_address.address)
1019 backup_primary = GNUNET_HELLO_address_copy (n->primary_address.address);
1020 else
1021 backup_primary = NULL;
1022
1023 /* free addresses and mark as unused */ 1013 /* free addresses and mark as unused */
1024 unset_primary_address (n); 1014 unset_primary_address (n);
1025 free_address (&n->alternative_address); 1015 free_address (&n->alternative_address);
1026 1016
1027 /* cut all transport-level connection for this peer */
1028 // FIXME: might want to revisit this; maybe just
1029 // shorten session timeout on plugin level?
1030 if ((GNUNET_NO == keep_sessions) &&
1031 (NULL != backup_primary) &&
1032 (NULL != (papi = GST_plugins_find (backup_primary->transport_name))))
1033 papi->disconnect_peer (papi->cls, &n->id);
1034
1035 if (NULL != backup_primary)
1036 GNUNET_HELLO_address_free (backup_primary);
1037 GNUNET_assert (GNUNET_YES == 1017 GNUNET_assert (GNUNET_YES ==
1038 GNUNET_CONTAINER_multipeermap_remove (neighbours, 1018 GNUNET_CONTAINER_multipeermap_remove (neighbours,
1039 &n->id, n)); 1019 &n->id, n));
@@ -1211,7 +1191,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
1211 case GNUNET_TRANSPORT_PS_NOT_CONNECTED: 1191 case GNUNET_TRANSPORT_PS_NOT_CONNECTED:
1212 case GNUNET_TRANSPORT_PS_INIT_ATS: 1192 case GNUNET_TRANSPORT_PS_INIT_ATS:
1213 /* other peer is completely unaware of us, no need to send DISCONNECT */ 1193 /* other peer is completely unaware of us, no need to send DISCONNECT */
1214 free_neighbour (n, GNUNET_NO); 1194 free_neighbour (n);
1215 return; 1195 return;
1216 case GNUNET_TRANSPORT_PS_SYN_SENT: 1196 case GNUNET_TRANSPORT_PS_SYN_SENT:
1217 send_disconnect (n); 1197 send_disconnect (n);
@@ -1219,7 +1199,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
1219 break; 1199 break;
1220 case GNUNET_TRANSPORT_PS_SYN_RECV_ATS: 1200 case GNUNET_TRANSPORT_PS_SYN_RECV_ATS:
1221 /* we never ACK'ed the other peer's request, no need to send DISCONNECT */ 1201 /* we never ACK'ed the other peer's request, no need to send DISCONNECT */
1222 free_neighbour (n, GNUNET_NO); 1202 free_neighbour (n);
1223 return; 1203 return;
1224 case GNUNET_TRANSPORT_PS_SYN_RECV_ACK: 1204 case GNUNET_TRANSPORT_PS_SYN_RECV_ACK:
1225 /* we DID ACK the other peer's request, must send DISCONNECT */ 1205 /* we DID ACK the other peer's request, must send DISCONNECT */
@@ -1242,7 +1222,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
1242 case GNUNET_TRANSPORT_PS_RECONNECT_ATS: 1222 case GNUNET_TRANSPORT_PS_RECONNECT_ATS:
1243 /* Disconnecting while waiting for an ATS address to reconnect, 1223 /* Disconnecting while waiting for an ATS address to reconnect,
1244 * cannot send DISCONNECT */ 1224 * cannot send DISCONNECT */
1245 free_neighbour (n, GNUNET_NO); 1225 free_neighbour (n);
1246 return; 1226 return;
1247 case GNUNET_TRANSPORT_PS_DISCONNECT: 1227 case GNUNET_TRANSPORT_PS_DISCONNECT:
1248 /* already disconnected, ignore */ 1228 /* already disconnected, ignore */
@@ -1398,8 +1378,11 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
1398 mq->message_buf_size, n->primary_address.session); 1378 mq->message_buf_size, n->primary_address.session);
1399 1379
1400 (void) send_with_session (n, 1380 (void) send_with_session (n,
1401 mq->message_buf, mq->message_buf_size, 1381 mq->message_buf,
1402 0 /* priority */, timeout, GNUNET_NO, 1382 mq->message_buf_size,
1383 0 /* priority */,
1384 timeout,
1385 GNUNET_NO,
1403 &transmit_send_continuation, mq); 1386 &transmit_send_continuation, mq);
1404} 1387}
1405 1388
@@ -1699,12 +1682,15 @@ GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity
1699 * @param msg_size number of bytes in msg 1682 * @param msg_size number of bytes in msg
1700 * @param timeout when to fail with timeout 1683 * @param timeout when to fail with timeout
1701 * @param cont function to call when done 1684 * @param cont function to call when done
1702 * @param cont_cls closure for 'cont' 1685 * @param cont_cls closure for @a cont
1703 */ 1686 */
1704void 1687void
1705GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg, 1688GST_neighbours_send (const struct GNUNET_PeerIdentity *target,
1706 size_t msg_size, struct GNUNET_TIME_Relative timeout, 1689 const void *msg,
1707 GST_NeighbourSendContinuation cont, void *cont_cls) 1690 size_t msg_size,
1691 struct GNUNET_TIME_Relative timeout,
1692 GST_NeighbourSendContinuation cont,
1693 void *cont_cls)
1708{ 1694{
1709 struct NeighbourMapEntry *n; 1695 struct NeighbourMapEntry *n;
1710 struct MessageQueue *mq; 1696 struct MessageQueue *mq;
@@ -1748,6 +1734,9 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg,
1748} 1734}
1749 1735
1750 1736
1737/**
1738 * FIXME
1739 */
1751static void 1740static void
1752send_session_connect_cont (void *cls, 1741send_session_connect_cont (void *cls,
1753 const struct GNUNET_PeerIdentity *target, 1742 const struct GNUNET_PeerIdentity *target,
@@ -1786,13 +1775,13 @@ send_session_connect_cont (void *cls,
1786 1775
1787 switch (n->state) { 1776 switch (n->state) {
1788 case GNUNET_TRANSPORT_PS_SYN_SENT: 1777 case GNUNET_TRANSPORT_PS_SYN_SENT:
1789 /* Remove address and request and additional one */ 1778 /* Remove address and request an additional one */
1790 unset_primary_address (n); 1779 unset_primary_address (n);
1791 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, 1780 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS,
1792 GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT)); 1781 GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT));
1793 break; 1782 break;
1794 case GNUNET_TRANSPORT_PS_RECONNECT_SENT: 1783 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
1795 /* Remove address and request and additional one */ 1784 /* Remove address and request an additional one */
1796 unset_primary_address (n); 1785 unset_primary_address (n);
1797 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS, 1786 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS,
1798 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); 1787 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
@@ -1879,7 +1868,7 @@ send_syn (struct NeighbourAddress *na)
1879 Destroy address and session */ 1868 Destroy address and session */
1880 break; 1869 break;
1881 case GNUNET_TRANSPORT_PS_RECONNECT_SENT: 1870 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
1882 /* Remove address and request and additional one */ 1871 /* Remove address and request an additional one */
1883 unset_primary_address (n); 1872 unset_primary_address (n);
1884 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS, 1873 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS,
1885 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); 1874 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
@@ -1887,7 +1876,7 @@ send_syn (struct NeighbourAddress *na)
1887 case GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT: 1876 case GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT:
1888 GNUNET_STATISTICS_update (GST_stats, gettext_noop 1877 GNUNET_STATISTICS_update (GST_stats, gettext_noop
1889 ("# Failed attempts to switch addresses (failed to send SYN)"), 1, GNUNET_NO); 1878 ("# Failed attempts to switch addresses (failed to send SYN)"), 1, GNUNET_NO);
1890 /* Remove address and request and additional one */ 1879 /* Remove address and request an additional one */
1891 unset_alternative_address (n); 1880 unset_alternative_address (n);
1892 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, 1881 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED,
1893 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); 1882 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
@@ -1903,12 +1892,15 @@ send_syn (struct NeighbourAddress *na)
1903} 1892}
1904 1893
1905 1894
1895/**
1896 * FIXME.
1897 */
1906static void 1898static void
1907send_session_connect_ack_cont (void *cls, 1899send_session_connect_ack_cont (void *cls,
1908 const struct GNUNET_PeerIdentity *target, 1900 const struct GNUNET_PeerIdentity *target,
1909 int result, 1901 int result,
1910 size_t size_payload, 1902 size_t size_payload,
1911 size_t size_on_wire) 1903 size_t size_on_wire)
1912{ 1904{
1913 struct NeighbourMapEntry *n; 1905 struct NeighbourMapEntry *n;
1914 1906
@@ -1941,7 +1933,7 @@ send_session_connect_ack_cont (void *cls,
1941 unset_primary_address (n); 1933 unset_primary_address (n);
1942 n->ack_state = ACK_SEND_SYN_ACK; 1934 n->ack_state = ACK_SEND_SYN_ACK;
1943 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_SYN_RECV_ATS, 1935 set_state_and_timeout (n, GNUNET_TRANSPORT_PS_SYN_RECV_ATS,
1944 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); 1936 GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
1945 return; 1937 return;
1946} 1938}
1947 1939
@@ -2017,6 +2009,9 @@ send_connect_ack_message (const struct GNUNET_HELLO_Address *address,
2017} 2009}
2018 2010
2019 2011
2012/**
2013 * FIXME
2014 */
2020static void 2015static void
2021inbound_bw_tracker_update (void *cls) 2016inbound_bw_tracker_update (void *cls)
2022{ 2017{
@@ -2203,7 +2198,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
2203 case GNUNET_TRANSPORT_PS_NOT_CONNECTED: 2198 case GNUNET_TRANSPORT_PS_NOT_CONNECTED:
2204 /* this should not be possible */ 2199 /* this should not be possible */
2205 GNUNET_break (0); 2200 GNUNET_break (0);
2206 free_neighbour (n, GNUNET_NO); 2201 free_neighbour (n);
2207 break; 2202 break;
2208 case GNUNET_TRANSPORT_PS_INIT_ATS: 2203 case GNUNET_TRANSPORT_PS_INIT_ATS:
2209 case GNUNET_TRANSPORT_PS_SYN_SENT: 2204 case GNUNET_TRANSPORT_PS_SYN_SENT:
@@ -2223,7 +2218,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
2223 return; /* already connected */ 2218 return; /* already connected */
2224 case GNUNET_TRANSPORT_PS_DISCONNECT: 2219 case GNUNET_TRANSPORT_PS_DISCONNECT:
2225 /* get rid of remains, ready to re-try immediately */ 2220 /* get rid of remains, ready to re-try immediately */
2226 free_neighbour (n, GNUNET_NO); 2221 free_neighbour (n);
2227 break; 2222 break;
2228 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED: 2223 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED:
2229 /* should not be possible */ 2224 /* should not be possible */
@@ -2234,7 +2229,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
2234 "Unhandled state `%s'\n", 2229 "Unhandled state `%s'\n",
2235 GNUNET_TRANSPORT_ps2s (n->state)); 2230 GNUNET_TRANSPORT_ps2s (n->state));
2236 GNUNET_break (0); 2231 GNUNET_break (0);
2237 free_neighbour (n, GNUNET_NO); 2232 free_neighbour (n);
2238 break; 2233 break;
2239 } 2234 }
2240 } 2235 }
@@ -2363,8 +2358,8 @@ GST_neighbours_handle_session_syn (const struct GNUNET_MessageHeader *message,
2363 n->primary_address.session, ts); 2358 n->primary_address.session, ts);
2364 break; 2359 break;
2365 case GNUNET_TRANSPORT_PS_DISCONNECT: 2360 case GNUNET_TRANSPORT_PS_DISCONNECT:
2366 /* Get rid of remains without terminating sessions, ready to re-try */ 2361 /* Get rid of remains and re-try */
2367 free_neighbour (n, GNUNET_YES); 2362 free_neighbour (n);
2368 n = setup_neighbour (peer); 2363 n = setup_neighbour (peer);
2369 /* Remember the SYN time stamp for ACK message */ 2364 /* Remember the SYN time stamp for ACK message */
2370 n->ack_state = ACK_SEND_SYN_ACK; 2365 n->ack_state = ACK_SEND_SYN_ACK;
@@ -2543,7 +2538,7 @@ switch_address_bl_check_cont (void *cls,
2543 { 2538 {
2544 case GNUNET_TRANSPORT_PS_NOT_CONNECTED: 2539 case GNUNET_TRANSPORT_PS_NOT_CONNECTED:
2545 GNUNET_break (0); 2540 GNUNET_break (0);
2546 free_neighbour (n, GNUNET_NO); 2541 free_neighbour (n);
2547 return; 2542 return;
2548 case GNUNET_TRANSPORT_PS_INIT_ATS: 2543 case GNUNET_TRANSPORT_PS_INIT_ATS:
2549 /* We requested an address and ATS suggests one: 2544 /* We requested an address and ATS suggests one:
@@ -3028,7 +3023,7 @@ master_task (void *cls,
3028 case GNUNET_TRANSPORT_PS_NOT_CONNECTED: 3023 case GNUNET_TRANSPORT_PS_NOT_CONNECTED:
3029 /* invalid state for master task, clean up */ 3024 /* invalid state for master task, clean up */
3030 GNUNET_break (0); 3025 GNUNET_break (0);
3031 free_neighbour (n, GNUNET_NO); 3026 free_neighbour (n);
3032 return; 3027 return;
3033 case GNUNET_TRANSPORT_PS_INIT_ATS: 3028 case GNUNET_TRANSPORT_PS_INIT_ATS:
3034 if (0 == delay.rel_value_us) 3029 if (0 == delay.rel_value_us)
@@ -3036,7 +3031,7 @@ master_task (void *cls,
3036 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3031 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3037 "Connection to `%s' timed out waiting for ATS to provide address\n", 3032 "Connection to `%s' timed out waiting for ATS to provide address\n",
3038 GNUNET_i2s (&n->id)); 3033 GNUNET_i2s (&n->id));
3039 free_neighbour (n, GNUNET_NO); 3034 free_neighbour (n);
3040 return; 3035 return;
3041 } 3036 }
3042 break; 3037 break;
@@ -3059,7 +3054,7 @@ master_task (void *cls,
3059 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3054 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3060 "Connection to `%s' timed out waiting ATS to provide address to use for SYN_ACK\n", 3055 "Connection to `%s' timed out waiting ATS to provide address to use for SYN_ACK\n",
3061 GNUNET_i2s (&n->id)); 3056 GNUNET_i2s (&n->id));
3062 free_neighbour (n, GNUNET_NO); 3057 free_neighbour (n);
3063 return; 3058 return;
3064 } 3059 }
3065 break; 3060 break;
@@ -3125,7 +3120,7 @@ master_task (void *cls,
3125 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3120 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3126 "Cleaning up connection to `%s' after sending DISCONNECT\n", 3121 "Cleaning up connection to `%s' after sending DISCONNECT\n",
3127 GNUNET_i2s (&n->id)); 3122 GNUNET_i2s (&n->id));
3128 free_neighbour (n, GNUNET_NO); 3123 free_neighbour (n);
3129 return; 3124 return;
3130 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED: 3125 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED:
3131 /* how did we get here!? */ 3126 /* how did we get here!? */
@@ -3225,7 +3220,7 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag
3225 { 3220 {
3226 case GNUNET_TRANSPORT_PS_NOT_CONNECTED: 3221 case GNUNET_TRANSPORT_PS_NOT_CONNECTED:
3227 GNUNET_break (0); 3222 GNUNET_break (0);
3228 free_neighbour (n, GNUNET_NO); 3223 free_neighbour (n);
3229 return GNUNET_SYSERR; 3224 return GNUNET_SYSERR;
3230 case GNUNET_TRANSPORT_PS_INIT_ATS: 3225 case GNUNET_TRANSPORT_PS_INIT_ATS:
3231 GNUNET_STATISTICS_update (GST_stats, 3226 GNUNET_STATISTICS_update (GST_stats,
@@ -3372,11 +3367,11 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
3372 { 3367 {
3373 case GNUNET_TRANSPORT_PS_NOT_CONNECTED: 3368 case GNUNET_TRANSPORT_PS_NOT_CONNECTED:
3374 GNUNET_break (0); 3369 GNUNET_break (0);
3375 free_neighbour (n, GNUNET_NO); 3370 free_neighbour (n);
3376 return GNUNET_YES; 3371 return GNUNET_YES;
3377 case GNUNET_TRANSPORT_PS_INIT_ATS: 3372 case GNUNET_TRANSPORT_PS_INIT_ATS:
3378 GNUNET_break (0); 3373 GNUNET_break (0);
3379 free_neighbour (n, GNUNET_NO); 3374 free_neighbour (n);
3380 return GNUNET_YES; 3375 return GNUNET_YES;
3381 case GNUNET_TRANSPORT_PS_SYN_SENT: 3376 case GNUNET_TRANSPORT_PS_SYN_SENT:
3382 /* The session used to send the SYN terminated: 3377 /* The session used to send the SYN terminated:
@@ -3397,7 +3392,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
3397 case GNUNET_TRANSPORT_PS_SYN_RECV_ACK: 3392 case GNUNET_TRANSPORT_PS_SYN_RECV_ACK:
3398 /* error on inbound session; free neighbour entirely */ 3393 /* error on inbound session; free neighbour entirely */
3399 free_address (&n->primary_address); 3394 free_address (&n->primary_address);
3400 free_neighbour (n, GNUNET_NO); 3395 free_neighbour (n);
3401 return GNUNET_YES; 3396 return GNUNET_YES;
3402 case GNUNET_TRANSPORT_PS_CONNECTED: 3397 case GNUNET_TRANSPORT_PS_CONNECTED:
3403 /* Our primary connection died, try a fast reconnect */ 3398 /* Our primary connection died, try a fast reconnect */
@@ -3615,6 +3610,12 @@ GST_neighbours_set_incoming_quota (const struct GNUNET_PeerIdentity *neighbour,
3615} 3610}
3616 3611
3617 3612
3613/**
3614 * Task to asynchronously run #free_neighbour().
3615 *
3616 * @param cls the `struct NeighbourMapEntry` to free
3617 * @param tc unused
3618 */
3618static void 3619static void
3619delayed_disconnect (void *cls, 3620delayed_disconnect (void *cls,
3620 const struct GNUNET_SCHEDULER_TaskContext* tc) 3621 const struct GNUNET_SCHEDULER_TaskContext* tc)
@@ -3625,7 +3626,7 @@ delayed_disconnect (void *cls,
3625 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3626 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3626 "Disconnecting by request from peer %s\n", 3627 "Disconnecting by request from peer %s\n",
3627 GNUNET_i2s (&n->id)); 3628 GNUNET_i2s (&n->id));
3628 free_neighbour (n, GNUNET_NO); 3629 free_neighbour (n);
3629} 3630}
3630 3631
3631 3632
@@ -3661,16 +3662,21 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer
3661 1, GNUNET_NO); 3662 1, GNUNET_NO);
3662 sdm = (const struct SessionDisconnectMessage *) msg; 3663 sdm = (const struct SessionDisconnectMessage *) msg;
3663 if (NULL == (n = lookup_neighbour (peer))) 3664 if (NULL == (n = lookup_neighbour (peer)))
3664 return; /* gone already */ 3665 {
3666 /* gone already */
3667 return;
3668 }
3665 if (GNUNET_TIME_absolute_ntoh (sdm->timestamp).abs_value_us <= n->connect_ack_timestamp.abs_value_us) 3669 if (GNUNET_TIME_absolute_ntoh (sdm->timestamp).abs_value_us <= n->connect_ack_timestamp.abs_value_us)
3666 { 3670 {
3667 GNUNET_STATISTICS_update (GST_stats, 3671 GNUNET_STATISTICS_update (GST_stats,
3668 gettext_noop 3672 gettext_noop ("# disconnect messages ignored (timestamp)"),
3669 ("# disconnect messages ignored (timestamp)"), 1, 3673 1,
3670 GNUNET_NO); 3674 GNUNET_NO);
3671 return; 3675 return;
3672 } 3676 }
3673 if (0 != memcmp (peer, &sdm->public_key, sizeof (struct GNUNET_PeerIdentity))) 3677 if (0 != memcmp (peer,
3678 &sdm->public_key,
3679 sizeof (struct GNUNET_PeerIdentity)))
3674 { 3680 {
3675 GNUNET_break_op (0); 3681 GNUNET_break_op (0);
3676 return; 3682 return;
@@ -3680,21 +3686,20 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer
3680 sizeof (struct GNUNET_CRYPTO_EddsaPublicKey) + 3686 sizeof (struct GNUNET_CRYPTO_EddsaPublicKey) +
3681 sizeof (struct GNUNET_TIME_AbsoluteNBO)) 3687 sizeof (struct GNUNET_TIME_AbsoluteNBO))
3682 { 3688 {
3683 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3689 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3684 "%s message from peer `%s' has invalid size \n", 3690 "DISCONNECT message from peer `%s' has invalid size\n",
3685 "DISCONNECT",
3686 GNUNET_i2s (peer)); 3691 GNUNET_i2s (peer));
3687 GNUNET_break_op (0); 3692 GNUNET_break_op (0);
3688 return; 3693 return;
3689 } 3694 }
3690 if (GNUNET_OK != 3695 if (GNUNET_OK !=
3691 GNUNET_CRYPTO_eddsa_verify 3696 GNUNET_CRYPTO_eddsa_verify (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT,
3692 (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT, &sdm->purpose, 3697 &sdm->purpose,
3693 &sdm->signature, &sdm->public_key)) 3698 &sdm->signature,
3699 &sdm->public_key))
3694 { 3700 {
3695 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3701 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3696 "%s message from peer `%s' cannot be verified \n", 3702 "DISCONNECT message from peer `%s' cannot be verified \n",
3697 "DISCONNECT",
3698 GNUNET_i2s (peer)); 3703 GNUNET_i2s (peer));
3699 GNUNET_break_op (0); 3704 GNUNET_break_op (0);
3700 return; 3705 return;
@@ -3738,7 +3743,6 @@ neighbours_iterate (void *cls,
3738 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in; 3743 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
3739 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out; 3744 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
3740 3745
3741
3742 if (NULL != n->primary_address.address) 3746 if (NULL != n->primary_address.address)
3743 { 3747 {
3744 bandwidth_in = n->primary_address.bandwidth_in; 3748 bandwidth_in = n->primary_address.bandwidth_in;
@@ -3792,8 +3796,8 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target)
3792 return; /* not active */ 3796 return; /* not active */
3793 if (GNUNET_YES == test_connected (n)) 3797 if (GNUNET_YES == test_connected (n))
3794 GNUNET_STATISTICS_update (GST_stats, 3798 GNUNET_STATISTICS_update (GST_stats,
3795 gettext_noop 3799 gettext_noop ("# disconnected from peer upon explicit request"),
3796 ("# disconnected from peer upon explicit request"), 1, 3800 1,
3797 GNUNET_NO); 3801 GNUNET_NO);
3798 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3802 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3799 "Forced disconnect from peer %s\n", 3803 "Forced disconnect from peer %s\n",
@@ -3869,7 +3873,8 @@ GST_neighbour_get_current_address (const struct GNUNET_PeerIdentity *peer)
3869void 3873void
3870GST_neighbours_start (unsigned int max_fds) 3874GST_neighbours_start (unsigned int max_fds)
3871{ 3875{
3872 neighbours = GNUNET_CONTAINER_multipeermap_create (NEIGHBOUR_TABLE_SIZE, GNUNET_NO); 3876 neighbours = GNUNET_CONTAINER_multipeermap_create (NEIGHBOUR_TABLE_SIZE,
3877 GNUNET_NO);
3873 util_transmission_tk = GNUNET_SCHEDULER_add_delayed (UTIL_TRANSMISSION_INTERVAL, 3878 util_transmission_tk = GNUNET_SCHEDULER_add_delayed (UTIL_TRANSMISSION_INTERVAL,
3874 &utilization_transmission, 3879 &utilization_transmission,
3875 NULL); 3880 NULL);
@@ -3892,9 +3897,9 @@ disconnect_all_neighbours (void *cls,
3892 struct NeighbourMapEntry *n = value; 3897 struct NeighbourMapEntry *n = value;
3893 3898
3894 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3899 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3895 "Disconnecting peer `%4s', %s\n", 3900 "Disconnecting peer `%4s' during shutdown\n",
3896 GNUNET_i2s (&n->id), "SHUTDOWN_TASK"); 3901 GNUNET_i2s (&n->id));
3897 free_neighbour (n, GNUNET_NO); 3902 free_neighbour (n);
3898 return GNUNET_OK; 3903 return GNUNET_OK;
3899} 3904}
3900 3905