From: Marcel Holtmann Date: Thu, 26 Mar 2009 00:04:31 +0000 (-0700) Subject: Check for socket errors and cancel gracefully X-Git-Tag: 0.14~31 X-Git-Url: http://git.maemo.org/git/?p=connman;a=commitdiff_plain;h=d768f6821cdb93ffbce08fbb19777202e61682b7 Check for socket errors and cancel gracefully --- diff --git a/plugins/dnsproxy.c b/plugins/dnsproxy.c index 66d608c..84ad596 100644 --- a/plugins/dnsproxy.c +++ b/plugins/dnsproxy.c @@ -94,10 +94,17 @@ static struct server_data *find_server(const char *interface, static gboolean server_event(GIOChannel *channel, GIOCondition condition, gpointer user_data) { + struct server_data *data = user_data; struct request_data *req; unsigned char buf[768]; int sk, err, len; + if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) { + connman_error("Error with server channel"); + data->watch = 0; + return FALSE; + } + sk = g_io_channel_unix_get_fd(channel); len = recv(sk, buf, sizeof(buf), 0); @@ -325,6 +332,12 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition, socklen_t size = sizeof(sin); int sk, err, len; + if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) { + connman_error("Error with listener channel"); + listener_watch = 0; + return FALSE; + } + sk = g_io_channel_unix_get_fd(channel); memset(&sin, 0, sizeof(sin));