From d768f6821cdb93ffbce08fbb19777202e61682b7 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 25 Mar 2009 17:04:31 -0700 Subject: [PATCH] Check for socket errors and cancel gracefully --- plugins/dnsproxy.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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)); -- 1.7.9.5