diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-01-21 18:51:27 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-06-13 15:45:54 +0100 |
commit | 58f968a2cc700377fc668dcaed4bc94a2ea7ca88 (patch) | |
tree | a9f63e16ff92a316a9a741cc348d576daec6de62 /dbus/dbus-mainloop.c | |
parent | a2e330980d6b7975dfea5b7d798e9bd55b80241c (diff) | |
download | dbus-58f968a2cc700377fc668dcaed4bc94a2ea7ca88.tar.gz |
Always remove, invalidate and free watches before closing watched sockets
This should mean we don't get invalid fds in the main loop.
The BSD (kqueue) and Windows code paths are untested, but follow the same
patterns as the tested Linux/generic Unix versions.
DBusTransportSocket was already OK (it called free_watches() before
_dbus_close_socket, and that did the remove, invalidate, unref dance).
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33336
Reviewed-by: Will Thompson <will.thompson@collabora.co.uk>
Reviewed-by: Thiago Macieira <thiago@kde.org>
Diffstat (limited to 'dbus/dbus-mainloop.c')
-rw-r--r-- | dbus/dbus-mainloop.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/dbus/dbus-mainloop.c b/dbus/dbus-mainloop.c index 43159a70..03e9d1c1 100644 --- a/dbus/dbus-mainloop.c +++ b/dbus/dbus-mainloop.c @@ -832,11 +832,14 @@ _dbus_loop_iterate (DBusLoop *loop, if (_DBUS_UNLIKELY (fds[i].revents & _DBUS_POLLNVAL)) { + DBusWatch *watch = _dbus_watch_ref (wcb->watch); + _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, + _dbus_loop_remove_watch (loop, watch, wcb->function, ((Callback *)wcb)->data); + _dbus_watch_invalidate (watch); + _dbus_watch_unref (watch); } } |