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 /bus/dir-watch-inotify.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 'bus/dir-watch-inotify.c')
-rw-r--r-- | bus/dir-watch-inotify.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bus/dir-watch-inotify.c b/bus/dir-watch-inotify.c index 461b8ee3..54704a4f 100644 --- a/bus/dir-watch-inotify.c +++ b/bus/dir-watch-inotify.c @@ -204,16 +204,18 @@ _shutdown_inotify (void *data) _set_watched_dirs_internal (&empty); - close (inotify_fd); - inotify_fd = -1; if (watch != NULL) { _dbus_loop_remove_watch (loop, watch, _inotify_watch_callback, NULL); + _dbus_watch_invalidate (watch); _dbus_watch_unref (watch); _dbus_loop_unref (loop); } watch = NULL; loop = NULL; + + close (inotify_fd); + inotify_fd = -1; } static int |