diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-11-23 20:37:14 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-11-23 20:37:14 +0000 |
commit | 7e60f24441ae84fe5aa965a09805e25996423886 (patch) | |
tree | 07bc7f0efd53a08db93082a85011a6a0c7bcac56 /src | |
parent | 353a1b1b3d482863aec041449ec4eea6f8a97885 (diff) | |
download | gnunet-7e60f24441ae84fe5aa965a09805e25996423886.tar.gz gnunet-7e60f24441ae84fe5aa965a09805e25996423886.zip |
-fix docs, fix shutdown
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 33 | ||||
-rw-r--r-- | src/transport/gnunet-transport.c | 39 |
2 files changed, 56 insertions, 16 deletions
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index d0aba723d..91833af23 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -227,6 +227,12 @@ static struct GNUNET_SERVER_NotificationContext *val_nc; | |||
227 | */ | 227 | */ |
228 | static struct GNUNET_SERVER_NotificationContext *plugin_nc; | 228 | static struct GNUNET_SERVER_NotificationContext *plugin_nc; |
229 | 229 | ||
230 | /** | ||
231 | * Plugin monitoring client we are currently syncing, NULL if all | ||
232 | * monitoring clients are in sync. | ||
233 | */ | ||
234 | static struct GNUNET_SERVER_Client *sync_client; | ||
235 | |||
230 | 236 | ||
231 | /** | 237 | /** |
232 | * Find the internal handle associated with the given client handle | 238 | * Find the internal handle associated with the given client handle |
@@ -1406,11 +1412,16 @@ plugin_session_info_cb (void *cls, | |||
1406 | (NULL == session) ) | 1412 | (NULL == session) ) |
1407 | { | 1413 | { |
1408 | /* end of initial iteration */ | 1414 | /* end of initial iteration */ |
1409 | sync.size = htons (sizeof (struct GNUNET_MessageHeader)); | 1415 | if (NULL != sync_client) |
1410 | sync.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_SYNC); | 1416 | { |
1411 | GNUNET_SERVER_notification_context_broadcast (plugin_nc, | 1417 | sync.size = htons (sizeof (struct GNUNET_MessageHeader)); |
1418 | sync.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_SYNC); | ||
1419 | GNUNET_SERVER_notification_context_unicast (plugin_nc, | ||
1420 | sync_client, | ||
1412 | &sync, | 1421 | &sync, |
1413 | GNUNET_NO); | 1422 | GNUNET_NO); |
1423 | sync_client = NULL; | ||
1424 | } | ||
1414 | return; | 1425 | return; |
1415 | } | 1426 | } |
1416 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1442,9 +1453,15 @@ plugin_session_info_cb (void *cls, | |||
1442 | memcpy (name, info->address->transport_name, slen); | 1453 | memcpy (name, info->address->transport_name, slen); |
1443 | addr = &name[slen + 1]; | 1454 | addr = &name[slen + 1]; |
1444 | memcpy (addr, info->address->address, alen); | 1455 | memcpy (addr, info->address->address, alen); |
1445 | GNUNET_SERVER_notification_context_broadcast (plugin_nc, | 1456 | if (NULL != sync_client) |
1446 | &msg->header, | 1457 | GNUNET_SERVER_notification_context_unicast (plugin_nc, |
1447 | GNUNET_NO); | 1458 | sync_client, |
1459 | &msg->header, | ||
1460 | GNUNET_NO); | ||
1461 | else | ||
1462 | GNUNET_SERVER_notification_context_broadcast (plugin_nc, | ||
1463 | &msg->header, | ||
1464 | GNUNET_NO); | ||
1448 | GNUNET_free (msg); | 1465 | GNUNET_free (msg); |
1449 | } | 1466 | } |
1450 | 1467 | ||
@@ -1464,8 +1481,8 @@ clients_handle_monitor_plugins (void *cls, | |||
1464 | GNUNET_SERVER_client_mark_monitor (client); | 1481 | GNUNET_SERVER_client_mark_monitor (client); |
1465 | GNUNET_SERVER_disable_receive_done_warning (client); | 1482 | GNUNET_SERVER_disable_receive_done_warning (client); |
1466 | GNUNET_SERVER_notification_context_add (plugin_nc, client); | 1483 | GNUNET_SERVER_notification_context_add (plugin_nc, client); |
1467 | if (1 == GNUNET_SERVER_notification_context_get_size (plugin_nc)) | 1484 | sync_client = client; |
1468 | GST_plugins_monitor_subscribe (&plugin_session_info_cb, NULL); | 1485 | GST_plugins_monitor_subscribe (&plugin_session_info_cb, NULL); |
1469 | } | 1486 | } |
1470 | 1487 | ||
1471 | 1488 | ||
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index 4b1e683f6..646b8087b 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -1599,18 +1599,30 @@ plugin_monitoring_cb (void *cls, | |||
1599 | const char *state; | 1599 | const char *state; |
1600 | struct PluginMonitorAddress *addr; | 1600 | struct PluginMonitorAddress *addr; |
1601 | 1601 | ||
1602 | fprintf (stderr, "E!\n"); | ||
1603 | if ( (NULL == info) && | 1602 | if ( (NULL == info) && |
1604 | (NULL == session) ) | 1603 | (NULL == session) ) |
1605 | return; /* in sync with transport service */ | 1604 | return; /* in sync with transport service */ |
1605 | addr = *session_ctx; | ||
1606 | if (NULL == info) | 1606 | if (NULL == info) |
1607 | { | ||
1608 | if (NULL != addr) | ||
1609 | { | ||
1610 | if (NULL != addr->asc) | ||
1611 | { | ||
1612 | GNUNET_TRANSPORT_address_to_string_cancel (addr->asc); | ||
1613 | addr->asc = NULL; | ||
1614 | } | ||
1615 | GNUNET_free_non_null (addr->str); | ||
1616 | GNUNET_free (addr); | ||
1617 | *session_ctx = NULL; | ||
1618 | } | ||
1607 | return; /* shutdown */ | 1619 | return; /* shutdown */ |
1620 | } | ||
1608 | if ( (NULL != cpid) && | 1621 | if ( (NULL != cpid) && |
1609 | (0 != memcmp (&info->address->peer, | 1622 | (0 != memcmp (&info->address->peer, |
1610 | cpid, | 1623 | cpid, |
1611 | sizeof (struct GNUNET_PeerIdentity))) ) | 1624 | sizeof (struct GNUNET_PeerIdentity))) ) |
1612 | return; /* filtered */ | 1625 | return; /* filtered */ |
1613 | addr = *session_ctx; | ||
1614 | if (NULL == addr) | 1626 | if (NULL == addr) |
1615 | { | 1627 | { |
1616 | addr = GNUNET_new (struct PluginMonitorAddress); | 1628 | addr = GNUNET_new (struct PluginMonitorAddress); |
@@ -1747,8 +1759,8 @@ process_peer_monitoring_cb (void *cls, | |||
1747 | 1759 | ||
1748 | 1760 | ||
1749 | /** | 1761 | /** |
1750 | * Function called with our result of trying to connect to the | 1762 | * Function called with our result of trying to connect to a peer |
1751 | * transport service. Will retry 10 times, and if we still | 1763 | * using the transport service. Will retry 10 times, and if we still |
1752 | * fail to connect terminate with an error message. | 1764 | * fail to connect terminate with an error message. |
1753 | * | 1765 | * |
1754 | * @param cls NULL | 1766 | * @param cls NULL |
@@ -1787,6 +1799,14 @@ try_connect_cb (void *cls, | |||
1787 | } | 1799 | } |
1788 | 1800 | ||
1789 | 1801 | ||
1802 | /** | ||
1803 | * Function called with our result of trying to disconnect a peer | ||
1804 | * using the transport service. Will retry 10 times, and if we still | ||
1805 | * fail to disconnect, terminate with an error message. | ||
1806 | * | ||
1807 | * @param cls NULL | ||
1808 | * @param result #GNUNET_OK if we connected to the service | ||
1809 | */ | ||
1790 | static void | 1810 | static void |
1791 | try_disconnect_cb (void *cls, | 1811 | try_disconnect_cb (void *cls, |
1792 | const int result) | 1812 | const int result) |
@@ -1799,12 +1819,14 @@ try_disconnect_cb (void *cls, | |||
1799 | } | 1819 | } |
1800 | retries++; | 1820 | retries++; |
1801 | if (retries < 10) | 1821 | if (retries < 10) |
1802 | tc_handle = GNUNET_TRANSPORT_try_disconnect (handle, &pid, try_disconnect_cb, | 1822 | tc_handle = GNUNET_TRANSPORT_try_disconnect (handle, |
1803 | NULL); | 1823 | &pid, |
1824 | &try_disconnect_cb, | ||
1825 | NULL); | ||
1804 | else | 1826 | else |
1805 | { | 1827 | { |
1806 | FPRINTF (stderr, "%s", | 1828 | FPRINTF (stderr, "%s", |
1807 | _("Failed to send connect request to transport service\n")); | 1829 | _("Failed to send disconnect request to transport service\n")); |
1808 | if (GNUNET_SCHEDULER_NO_TASK != end) | 1830 | if (GNUNET_SCHEDULER_NO_TASK != end) |
1809 | GNUNET_SCHEDULER_cancel (end); | 1831 | GNUNET_SCHEDULER_cancel (end); |
1810 | ret = 1; | 1832 | ret = 1; |
@@ -1822,7 +1844,8 @@ try_disconnect_cb (void *cls, | |||
1822 | * @param result #GNUNET_YES if transport is running | 1844 | * @param result #GNUNET_YES if transport is running |
1823 | */ | 1845 | */ |
1824 | static void | 1846 | static void |
1825 | testservice_task (void *cls, int result) | 1847 | testservice_task (void *cls, |
1848 | int result) | ||
1826 | { | 1849 | { |
1827 | int counter = 0; | 1850 | int counter = 0; |
1828 | ret = 1; | 1851 | ret = 1; |