aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_neighbours.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-11-02 14:55:03 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-11-02 14:55:03 +0000
commit692ba215de119f96d2240abbac9d2b895936b72e (patch)
tree0879bd9228e0af4e807728e20c15bf37e565e6cb /src/transport/gnunet-service-transport_neighbours.c
parentbd4eecf2fff9c4eb3a4401736dfffb2ceff85f03 (diff)
downloadgnunet-692ba215de119f96d2240abbac9d2b895936b72e.tar.gz
gnunet-692ba215de119f96d2240abbac9d2b895936b72e.zip
+ prevent bug https://www.gnunet.org/bugs/view.php?id=1868
+ changes shutdown order to send DISCONNECT Messages
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c75
1 files changed, 63 insertions, 12 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index a1ce1364f..6bd47a8cb 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -579,7 +579,14 @@ send_with_plugin ( const struct GNUNET_PeerIdentity * target,
579 struct GNUNET_TRANSPORT_PluginFunctions *papi; 579 struct GNUNET_TRANSPORT_PluginFunctions *papi;
580 size_t ret = GNUNET_SYSERR; 580 size_t ret = GNUNET_SYSERR;
581 581
582 GNUNET_assert (plugin_name != NULL); 582 /* FIXME : ats returns an address with all values 0 */
583 if (((plugin_name == NULL) && (addr == NULL) && (addrlen == 0 )) ||
584 ((plugin_name == NULL) && (session == NULL)))
585 {
586 if (cont != NULL)
587 cont (cont_cls, target, GNUNET_SYSERR);
588 return GNUNET_SYSERR;
589 }
583 papi = GST_plugins_find (plugin_name); 590 papi = GST_plugins_find (plugin_name);
584 if (papi == NULL) 591 if (papi == NULL)
585 { 592 {
@@ -1000,7 +1007,11 @@ ats_suggest_cancel (void *cls,
1000void 1007void
1001GST_neighbours_stop () 1008GST_neighbours_stop ()
1002{ 1009{
1003 GNUNET_assert (neighbours != NULL); 1010 // This can happen during shutdown
1011 if (neighbours == NULL)
1012 {
1013 return;
1014 }
1004 1015
1005 GNUNET_CONTAINER_multihashmap_iterate (neighbours, &disconnect_all_neighbours, 1016 GNUNET_CONTAINER_multihashmap_iterate (neighbours, &disconnect_all_neighbours,
1006 NULL); 1017 NULL);
@@ -1189,7 +1200,11 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1189 size_t msg_len; 1200 size_t msg_len;
1190 size_t ret; 1201 size_t ret;
1191 1202
1192 GNUNET_assert (neighbours != NULL); 1203 // This can happen during shutdown
1204 if (neighbours == NULL)
1205 {
1206 return GNUNET_NO;
1207 }
1193 n = lookup_neighbour (peer); 1208 n = lookup_neighbour (peer);
1194 if (NULL == n) 1209 if (NULL == n)
1195 { 1210 {
@@ -1382,7 +1397,11 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
1382{ 1397{
1383 struct NeighbourMapEntry *n; 1398 struct NeighbourMapEntry *n;
1384 1399
1385 GNUNET_assert (neighbours != NULL); 1400 // This can happen during shutdown
1401 if (neighbours == NULL)
1402 {
1403 return;
1404 }
1386#if DEBUG_TRANSPORT 1405#if DEBUG_TRANSPORT
1387 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect to peer `%s'\n", 1406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect to peer `%s'\n",
1388 GNUNET_i2s (target)); 1407 GNUNET_i2s (target));
@@ -1426,7 +1445,11 @@ GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target)
1426{ 1445{
1427 struct NeighbourMapEntry *n; 1446 struct NeighbourMapEntry *n;
1428 1447
1429 GNUNET_assert (neighbours != NULL); 1448 // This can happen during shutdown
1449 if (neighbours == NULL)
1450 {
1451 return GNUNET_NO;
1452 }
1430 1453
1431 n = lookup_neighbour (target); 1454 n = lookup_neighbour (target);
1432 1455
@@ -1448,7 +1471,11 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
1448{ 1471{
1449 struct NeighbourMapEntry *n; 1472 struct NeighbourMapEntry *n;
1450 1473
1451 GNUNET_assert (neighbours != NULL); 1474 // This can happen during shutdown
1475 if (neighbours == NULL)
1476 {
1477 return;
1478 }
1452 1479
1453#if DEBUG_TRANSPORT 1480#if DEBUG_TRANSPORT
1454 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1481 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1502,7 +1529,11 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg,
1502 struct NeighbourMapEntry *n; 1529 struct NeighbourMapEntry *n;
1503 struct MessageQueue *mq; 1530 struct MessageQueue *mq;
1504 1531
1505 GNUNET_assert (neighbours != NULL); 1532 // This can happen during shutdown
1533 if (neighbours == NULL)
1534 {
1535 return;
1536 }
1506 1537
1507 n = lookup_neighbour (target); 1538 n = lookup_neighbour (target);
1508 if ((n == NULL) || (!is_connected(n))) 1539 if ((n == NULL) || (!is_connected(n)))
@@ -1583,7 +1614,11 @@ GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity
1583 struct NeighbourMapEntry *n; 1614 struct NeighbourMapEntry *n;
1584 struct GNUNET_TIME_Relative ret; 1615 struct GNUNET_TIME_Relative ret;
1585 1616
1586 GNUNET_assert (neighbours != NULL); 1617 // This can happen during shutdown
1618 if (neighbours == NULL)
1619 {
1620 return GNUNET_TIME_UNIT_FOREVER_REL;
1621 }
1587 1622
1588 n = lookup_neighbour (sender); 1623 n = lookup_neighbour (sender);
1589 if (n == NULL) 1624 if (n == NULL)
@@ -1666,7 +1701,11 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour)
1666{ 1701{
1667 struct NeighbourMapEntry *n; 1702 struct NeighbourMapEntry *n;
1668 1703
1669 GNUNET_assert (neighbours != NULL); 1704 // This can happen during shutdown
1705 if (neighbours == NULL)
1706 {
1707 return;
1708 }
1670 1709
1671 n = lookup_neighbour (neighbour); 1710 n = lookup_neighbour (neighbour);
1672 if (NULL == n) 1711 if (NULL == n)
@@ -1696,7 +1735,11 @@ GST_neighbours_set_incoming_quota (const struct GNUNET_PeerIdentity *neighbour,
1696{ 1735{
1697 struct NeighbourMapEntry *n; 1736 struct NeighbourMapEntry *n;
1698 1737
1699 GNUNET_assert (neighbours != NULL); 1738 // This can happen during shutdown
1739 if (neighbours == NULL)
1740 {
1741 return;
1742 }
1700 1743
1701 n = lookup_neighbour (neighbour); 1744 n = lookup_neighbour (neighbour);
1702 if (n == NULL) 1745 if (n == NULL)
@@ -1772,7 +1815,11 @@ GST_neighbours_iterate (GST_NeighbourIterator cb, void *cb_cls)
1772{ 1815{
1773 struct IteratorContext ic; 1816 struct IteratorContext ic;
1774 1817
1775 GNUNET_assert (neighbours != NULL); 1818 // This can happen during shutdown
1819 if (neighbours == NULL)
1820 {
1821 return;
1822 }
1776 1823
1777 ic.cb = cb; 1824 ic.cb = cb;
1778 ic.cb_cls = cb_cls; 1825 ic.cb_cls = cb_cls;
@@ -1789,7 +1836,11 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target)
1789{ 1836{
1790 struct NeighbourMapEntry *n; 1837 struct NeighbourMapEntry *n;
1791 1838
1792 GNUNET_assert (neighbours != NULL); 1839 // This can happen during shutdown
1840 if (neighbours == NULL)
1841 {
1842 return;
1843 }
1793 1844
1794 n = lookup_neighbour (target); 1845 n = lookup_neighbour (target);
1795 if (NULL == n) 1846 if (NULL == n)