From 7e60f24441ae84fe5aa965a09805e25996423886 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 23 Nov 2014 20:37:14 +0000 Subject: -fix docs, fix shutdown --- src/transport/gnunet-service-transport_clients.c | 33 +++++++++++++++----- src/transport/gnunet-transport.c | 39 +++++++++++++++++++----- 2 files changed, 56 insertions(+), 16 deletions(-) (limited to 'src') 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; */ static struct GNUNET_SERVER_NotificationContext *plugin_nc; +/** + * Plugin monitoring client we are currently syncing, NULL if all + * monitoring clients are in sync. + */ +static struct GNUNET_SERVER_Client *sync_client; + /** * Find the internal handle associated with the given client handle @@ -1406,11 +1412,16 @@ plugin_session_info_cb (void *cls, (NULL == session) ) { /* end of initial iteration */ - sync.size = htons (sizeof (struct GNUNET_MessageHeader)); - sync.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_SYNC); - GNUNET_SERVER_notification_context_broadcast (plugin_nc, + if (NULL != sync_client) + { + sync.size = htons (sizeof (struct GNUNET_MessageHeader)); + sync.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_SYNC); + GNUNET_SERVER_notification_context_unicast (plugin_nc, + sync_client, &sync, GNUNET_NO); + sync_client = NULL; + } return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1442,9 +1453,15 @@ plugin_session_info_cb (void *cls, memcpy (name, info->address->transport_name, slen); addr = &name[slen + 1]; memcpy (addr, info->address->address, alen); - GNUNET_SERVER_notification_context_broadcast (plugin_nc, - &msg->header, - GNUNET_NO); + if (NULL != sync_client) + GNUNET_SERVER_notification_context_unicast (plugin_nc, + sync_client, + &msg->header, + GNUNET_NO); + else + GNUNET_SERVER_notification_context_broadcast (plugin_nc, + &msg->header, + GNUNET_NO); GNUNET_free (msg); } @@ -1464,8 +1481,8 @@ clients_handle_monitor_plugins (void *cls, GNUNET_SERVER_client_mark_monitor (client); GNUNET_SERVER_disable_receive_done_warning (client); GNUNET_SERVER_notification_context_add (plugin_nc, client); - if (1 == GNUNET_SERVER_notification_context_get_size (plugin_nc)) - GST_plugins_monitor_subscribe (&plugin_session_info_cb, NULL); + sync_client = client; + GST_plugins_monitor_subscribe (&plugin_session_info_cb, NULL); } 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, const char *state; struct PluginMonitorAddress *addr; - fprintf (stderr, "E!\n"); if ( (NULL == info) && (NULL == session) ) return; /* in sync with transport service */ + addr = *session_ctx; if (NULL == info) + { + if (NULL != addr) + { + if (NULL != addr->asc) + { + GNUNET_TRANSPORT_address_to_string_cancel (addr->asc); + addr->asc = NULL; + } + GNUNET_free_non_null (addr->str); + GNUNET_free (addr); + *session_ctx = NULL; + } return; /* shutdown */ + } if ( (NULL != cpid) && (0 != memcmp (&info->address->peer, cpid, sizeof (struct GNUNET_PeerIdentity))) ) return; /* filtered */ - addr = *session_ctx; if (NULL == addr) { addr = GNUNET_new (struct PluginMonitorAddress); @@ -1747,8 +1759,8 @@ process_peer_monitoring_cb (void *cls, /** - * Function called with our result of trying to connect to the - * transport service. Will retry 10 times, and if we still + * Function called with our result of trying to connect to a peer + * using the transport service. Will retry 10 times, and if we still * fail to connect terminate with an error message. * * @param cls NULL @@ -1787,6 +1799,14 @@ try_connect_cb (void *cls, } +/** + * Function called with our result of trying to disconnect a peer + * using the transport service. Will retry 10 times, and if we still + * fail to disconnect, terminate with an error message. + * + * @param cls NULL + * @param result #GNUNET_OK if we connected to the service + */ static void try_disconnect_cb (void *cls, const int result) @@ -1799,12 +1819,14 @@ try_disconnect_cb (void *cls, } retries++; if (retries < 10) - tc_handle = GNUNET_TRANSPORT_try_disconnect (handle, &pid, try_disconnect_cb, - NULL); + tc_handle = GNUNET_TRANSPORT_try_disconnect (handle, + &pid, + &try_disconnect_cb, + NULL); else { FPRINTF (stderr, "%s", - _("Failed to send connect request to transport service\n")); + _("Failed to send disconnect request to transport service\n")); if (GNUNET_SCHEDULER_NO_TASK != end) GNUNET_SCHEDULER_cancel (end); ret = 1; @@ -1822,7 +1844,8 @@ try_disconnect_cb (void *cls, * @param result #GNUNET_YES if transport is running */ static void -testservice_task (void *cls, int result) +testservice_task (void *cls, + int result) { int counter = 0; ret = 1; -- cgit v1.2.3