When a socket is closed, poll(2) will always return readable immediately, read(2) will return 0 (EOF), thus we need to remove it from the watched channels, or else the cpu get spinning to 100%.
Signed-off-by: Bao Haojun <baohao...@gmail.com> --- src/nm-openvpn-service.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/nm-openvpn-service.c b/src/nm-openvpn-service.c index 660fd2f..d69f536 100644 --- a/src/nm-openvpn-service.c +++ b/src/nm-openvpn-service.c @@ -404,12 +404,20 @@ handle_management_socket (NMVPNPlugin *plugin, NMOpenvpnPluginIOData *io_data = NM_OPENVPN_PLUGIN_GET_PRIVATE (plugin)->io_data; gboolean again = TRUE; char *str = NULL, *auth = NULL, *buf; + GIOStatus status; if (!(condition & G_IO_IN)) return TRUE; - if (g_io_channel_read_line (source, &str, NULL, NULL, NULL) != G_IO_STATUS_NORMAL) + status = g_io_channel_read_line (source, &str, NULL, NULL, NULL); + + if (status != G_IO_STATUS_NORMAL) { + if (status == G_IO_STATUS_EOF && io_data->socket_channel_eventid) { + g_source_remove (io_data->socket_channel_eventid); + io_data->socket_channel_eventid = 0; + } return TRUE; + } if (strlen (str) < 1) goto out; -- 1.7.10.4 _______________________________________________ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list