gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r34424 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r34424 - gnunet/src/transport
Date: Sun, 23 Nov 2014 21:37:14 +0100

Author: grothoff
Date: 2014-11-23 21:37:14 +0100 (Sun, 23 Nov 2014)
New Revision: 34424

Modified:
   gnunet/src/transport/gnunet-service-transport_clients.c
   gnunet/src/transport/gnunet-transport.c
Log:
-fix docs, fix shutdown

Modified: gnunet/src/transport/gnunet-service-transport_clients.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.c     2014-11-23 
20:13:49 UTC (rev 34423)
+++ gnunet/src/transport/gnunet-service-transport_clients.c     2014-11-23 
20:37:14 UTC (rev 34424)
@@ -227,7 +227,13 @@
  */
 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 @@
        (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 @@
   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 @@
   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);
 }
 
 

Modified: gnunet/src/transport/gnunet-transport.c
===================================================================
--- gnunet/src/transport/gnunet-transport.c     2014-11-23 20:13:49 UTC (rev 
34423)
+++ gnunet/src/transport/gnunet-transport.c     2014-11-23 20:37:14 UTC (rev 
34424)
@@ -1599,18 +1599,30 @@
   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 @@
 
 
 /**
- * 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 @@
 }
 
 
+/**
+ * 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 @@
   }
   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 @@
  * @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;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]