Check for socket errors and cancel gracefully
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 26 Mar 2009 00:04:31 +0000 (17:04 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 26 Mar 2009 00:04:31 +0000 (17:04 -0700)
plugins/dnsproxy.c

index 66d608c..84ad596 100644 (file)
@@ -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));