We only added G_IO_IN to the watch and therefore never got the G_IO_HUP.
That leads to a busy loop because can_read_data always return true.
By adding G_IO_HUP & friends we really termanate now in
can_read_data. But we unrefed the channel one time to much.
These two bugs were introduced by 8e182879f709 ("openvpn: Use proper
logging function")
---
vpn/plugins/openvpn.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/vpn/plugins/openvpn.c b/vpn/plugins/openvpn.c
index 7d283b477635..e33950970b13 100644
--- a/vpn/plugins/openvpn.c
+++ b/vpn/plugins/openvpn.c
@@ -321,10 +321,8 @@ static gboolean can_read_data(GIOChannel *chan,
gchar *str;
gsize size;
- if (cond == G_IO_HUP) {
- g_io_channel_unref(chan);
+ if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
return FALSE;
- }
g_io_channel_read_line(chan, &str, &size, NULL, NULL);
cbf(str);
@@ -340,7 +338,8 @@ static int setup_log_read(int stdout_fd, int stderr_fd)
chan = g_io_channel_unix_new(stdout_fd);
g_io_channel_set_close_on_unref(chan, TRUE);
- watch = g_io_add_watch(chan, G_IO_IN, can_read_data, connman_debug);
+ watch = g_io_add_watch(chan, G_IO_IN | G_IO_NVAL | G_IO_ERR | G_IO_HUP,
+ can_read_data, connman_debug);
g_io_channel_unref(chan);
if (watch == 0)
@@ -348,7 +347,8 @@ static int setup_log_read(int stdout_fd, int stderr_fd)
chan = g_io_channel_unix_new(stderr_fd);
g_io_channel_set_close_on_unref(chan, TRUE);
- watch = g_io_add_watch(chan, G_IO_IN, can_read_data, connman_error);
+ watch = g_io_add_watch(chan, G_IO_IN | G_IO_NVAL | G_IO_ERR | G_IO_HUP,
+ can_read_data, connman_error);
g_io_channel_unref(chan);
return watch == 0? -EIO : 0;
--
2.9.3
Show replies by date