summaryrefslogtreecommitdiff
path: root/bus/dir-watch-kqueue.c
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-01-21 18:51:27 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-06-13 15:45:54 +0100
commit58f968a2cc700377fc668dcaed4bc94a2ea7ca88 (patch)
treea9f63e16ff92a316a9a741cc348d576daec6de62 /bus/dir-watch-kqueue.c
parenta2e330980d6b7975dfea5b7d798e9bd55b80241c (diff)
downloaddbus-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 'bus/dir-watch-kqueue.c')
-rw-r--r--bus/dir-watch-kqueue.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/bus/dir-watch-kqueue.c b/bus/dir-watch-kqueue.c
index 4e436eb1..62f7b3dc 100644
--- a/bus/dir-watch-kqueue.c
+++ b/bus/dir-watch-kqueue.c
@@ -81,6 +81,7 @@ _handle_kqueue_watch (DBusWatch *watch, unsigned int flags, void *data)
if (watch != NULL)
{
_dbus_loop_remove_watch (loop, watch, _kqueue_watch_callback, NULL);
+ _dbus_watch_invalidate (watch);
_dbus_watch_unref (watch);
watch = NULL;
}
@@ -124,10 +125,11 @@ _init_kqueue (BusContext *context)
NULL, NULL))
{
_dbus_warn ("Unable to add reload watch to main loop");
- close (kq);
- kq = -1;
+ _dbus_watch_invalidate (watch);
_dbus_watch_unref (watch);
watch = NULL;
+ close (kq);
+ kq = -1;
goto out;
}
}