Make connect non-blocking.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 18 Oct 2007 18:20:18 +0000 (20:20 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 18 Oct 2007 18:20:18 +0000 (20:20 +0200)
NEWS
motd
src/network.c
src/plugins.c

diff --git a/NEWS b/NEWS
index 311fad5e52aff17d0fc43c9bd0152c7d0f9654e3..b3714f8f63f52a4f8319166df37f0b1c5ab8f98f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,7 +15,8 @@ Ctrlproxy 3.0.4 UNRELEASED
 
     * Integrate some more standard replication backends. 
 
-    * Allow specifying a network in the password, separated by a colon (:).
+    * Allow specifying a network in the password, separated by a colon (:). 
+      (#11)
 
     * Integrate listeners into the core.
 
@@ -38,10 +39,12 @@ Ctrlproxy 3.0.4 UNRELEASED
 
     * Add support for handling additional 005 parameters: HCN.
 
-       * Compress /NAMES lines (#123).
+    * Compress /NAMES lines (#123).
 
-       * Bail out when invalid arguments are specified on the command-line
-         (Emanuele Giaquinta <e.giaquinta@glauco.it>)
+    * Bail out when invalid arguments are specified on the command-line
+      (Emanuele Giaquinta <e.giaquinta@glauco.it>)
+
+    * Make connect to networks non-blocking. (#133)
 
   INTERNALS
 
diff --git a/motd b/motd
index 97f520faa3e312df39bc4b0cebba8f64cc993e79..58628dd2d2a5788986935a36061c02f56470c050 100644 (file)
--- a/motd
+++ b/motd
@@ -9,3 +9,4 @@
 - 
 - Use /CTRLPROXY HELP or /MSG CTRLPROXY HELP to get 
 - a list of available commands.
+-
index 6bc7baa9d6652013b44ef3237fc5dd315ae3b1f2..e93a861f5497c5a4ef4ef427e1ac697d7a7a1ffb 100644 (file)
@@ -684,6 +684,7 @@ static gboolean connect_current_tcp_server(struct network *s)
        struct addrinfo hints;
        struct addrinfo *addrinfo = NULL;
        int error;
+       gboolean connect_finished = TRUE;
 
        g_assert(s != NULL);
 
@@ -700,9 +701,7 @@ static gboolean connect_current_tcp_server(struct network *s)
                return FALSE;
        }
 
-       log_network(LOG_INFO, s, "Connecting with %s:%s", 
-                         cs->host, 
-                         cs->port);
+       log_network(LOG_INFO, s, "Connecting with %s:%s", cs->host, cs->port);
 
        memset(&hints, 0, sizeof(hints));
        hints.ai_family = PF_UNSPEC;
@@ -731,7 +730,12 @@ static gboolean connect_current_tcp_server(struct network *s)
                        bindsock(s, sock, res, cs->bind_address, cs->bind_port);
 
                ioc = g_io_channel_unix_new(sock);
-               if (connect(sock, res->ai_addr, res->ai_addrlen) < 0 && errno != EINPROGRESS) {
+               g_io_channel_set_flags(ioc, G_IO_FLAG_NONBLOCK, NULL);
+               if (connect(sock, res->ai_addr, res->ai_addrlen) < 0) {
+                       if (errno == EINPROGRESS) {
+                               connect_finished = FALSE;
+                               break;
+                       }
                        g_io_channel_unref(ioc);
                        ioc = NULL;
                        continue;
@@ -775,6 +779,9 @@ static gboolean connect_current_tcp_server(struct network *s)
                return FALSE;
        }
 
+       if (!connect_finished)
+               s->connection.outgoing_id = g_io_add_watch(ioc, G_IO_OUT, server_send_queue, s);
+
        network_set_iochannel(s, ioc);
 
        g_io_channel_unref(s->connection.outgoing);
index 33e4ff9fcc890d501a96b3e794e0eb4a8acd03a4..27059b6f1e9301743f0b35d463c609bca29eedf6 100644 (file)
 struct plugin *current_plugin = NULL;
 GList *plugins = NULL;
 
+/**
+ * Check whether a certain plugin has already been loaded.
+ *
+ * @param name Name of the plugin
+ */
 gboolean plugin_loaded(const char *name)
 {
        GList *gl;