From: Simon McVittie Date: Wed, 12 Jan 2011 12:14:49 +0000 (+0000) Subject: _dbus_loop_iterate: if the kernel says a fd is bad, stop watching it X-Git-Tag: dbus-1.4.4~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=460e6282d68a928a78f16031ed1637bc7676e10e;p=thirdparty%2Fdbus.git _dbus_loop_iterate: if the kernel says a fd is bad, stop watching it Again, this shouldn't happen - modules are responsible for cleaning up their watches - but the failure mode here is really bad: if we leave an invalid fd in the set, every poll() call will instantly return, marking it as POLLNVAL. The result is that dbus-daemon busy-loops on poll() without responding to I/O, so the bad watch will probably never be cleared up. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=32992 Bug-NB: NB#200248 Reviewed-by: Colin Walters --- diff --git a/dbus/dbus-mainloop.c b/dbus/dbus-mainloop.c index c37513829..43159a70b 100644 --- a/dbus/dbus-mainloop.c +++ b/dbus/dbus-mainloop.c @@ -829,6 +829,15 @@ _dbus_loop_iterate (DBusLoop *loop, retval = TRUE; } + + if (_DBUS_UNLIKELY (fds[i].revents & _DBUS_POLLNVAL)) + { + _dbus_warn ("invalid request, socket fd %d not open\n", + fds[i].fd); + _dbus_watch_invalidate (wcb->watch); + _dbus_loop_remove_watch (loop, wcb->watch, wcb->function, + ((Callback *)wcb)->data); + } } ++i;