[NetworkManager-libreswan/nm-1-0: 37/51] service: properly handle pty master hangups



commit 3043e1a81a6fb4d88453437cb12fd0ed1f500761
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Mon Oct 26 11:18:07 2015 +0100

    service: properly handle pty master hangups
    
    Missing hunks from [service: watch for pty master hangups] omitted by accident.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1271973#c5
    (cherry picked from commit 3caa64591364ae59284130a89c57e98f3b57eb9f)

 src/nm-openswan-service.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/nm-openswan-service.c b/src/nm-openswan-service.c
index 5198424..eb82cf8 100644
--- a/src/nm-openswan-service.c
+++ b/src/nm-openswan-service.c
@@ -339,7 +339,7 @@ pipe_init (Pipe *pipe, int fd, const char *detail)
        pipe->channel = g_io_channel_unix_new (fd);
        g_io_channel_set_encoding (pipe->channel, NULL, NULL);
        g_io_channel_set_buffered (pipe->channel, FALSE);
-       pipe->id = g_io_add_watch (pipe->channel, G_IO_IN | G_IO_ERR, pr_cb, pipe);
+       pipe->id = g_io_add_watch (pipe->channel, G_IO_IN | G_IO_ERR | G_IO_HUP, pr_cb, pipe);
 }
 
 static void
@@ -926,7 +926,13 @@ io_cb (GIOChannel *source, GIOCondition condition, gpointer user_data)
        NMVPNConnectionStateReason reason = NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED;
        const char *found;
 
-       if (condition & (G_IO_ERR | G_IO_HUP)) {
+       if (condition & G_IO_HUP) {
+               DEBUG ("PTY disconnected");
+               priv->io_id = 0;
+               return G_SOURCE_REMOVE;
+       }
+
+       if (condition & G_IO_ERR) {
                g_warning ("PTY spawn: pipe error!");
                goto done;
        }
@@ -997,7 +1003,7 @@ pr_cb (GIOChannel *source, GIOCondition condition, gpointer user_data)
        char *nl;
 
        if (condition & (G_IO_ERR | G_IO_HUP)) {
-               g_warning ("PTY(%s) pipe error!", pipe->detail);
+               DEBUG ("PTY(%s) pipe error!", pipe->detail);
                return G_SOURCE_REMOVE;
        }
        g_assert (condition & G_IO_IN);


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