gresolv: Handle POLLERR on DNS UDP socket
authorDavid Woodhouse <David.Woodhouse@intel.com>
Wed, 1 Dec 2010 16:35:58 +0000 (16:35 +0000)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Wed, 1 Dec 2010 16:35:58 +0000 (16:35 +0000)
If we get an error on the UDP socket, we'll currently go into an endless
loop eating CPU with poll() returning POLLERR and us ignoring it.

This at least hooks things up so that our callback gets called, and we
stop looping. But the callback's handling of POLLERR isn't correct. It
should close the socket and open a new one. As it is, it's just going to
try to use the same broken socket again for the next request. But at least
with this patch it'll stop eating CPU.

gweb/gresolv.c

index afd0653..99dc57a 100644 (file)
@@ -329,8 +329,8 @@ static int connect_udp_channel(struct resolv_nameserver *nameserver)
        g_io_channel_set_close_on_unref(nameserver->udp_channel, TRUE);
 
        nameserver->udp_watch = g_io_add_watch(nameserver->udp_channel,
-                                               G_IO_IN, received_udp_data,
-                                                               nameserver);
+                              G_IO_IN | G_IO_NVAL | G_IO_ERR | G_IO_HUP,
+                              received_udp_data, nameserver);
 
        return 0;
 }