diff options
author | Colin Walters <walters@verbum.org> | 2008-07-28 12:02:56 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2008-07-28 12:02:56 -0400 |
commit | 121c6b13a35759ee590551cfb9978e9f20766a12 (patch) | |
tree | 95d098e49e7c1f477773fdf68614ff30964d907d | |
parent | 892c0a00539151dc449e80d1b0311a9e4ea69f79 (diff) |
Bug 16294: Don't lose inotify watch when config fails to parse
* bus/dir-watch-inotify.c: Always drop the watch in
handle_inotify_watch; this ensures we always readd it
correctly in bus_drop_all_directory_watches.
-rw-r--r-- | bus/dir-watch-inotify.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/bus/dir-watch-inotify.c b/bus/dir-watch-inotify.c index e15faadc..44ec9cf0 100644 --- a/bus/dir-watch-inotify.c +++ b/bus/dir-watch-inotify.c @@ -55,12 +55,13 @@ _inotify_watch_callback (DBusWatch *watch, unsigned int condition, void *data) } static dbus_bool_t -_handle_inotify_watch (DBusWatch *watch, unsigned int flags, void *data) +_handle_inotify_watch (DBusWatch *passed_watch, unsigned int flags, void *data) { char buffer[INOTIFY_BUF_LEN]; ssize_t ret = 0; int i = 0; pid_t pid; + dbus_bool_t have_change = FALSE; ret = read (inotify_fd, buffer, INOTIFY_BUF_LEN); if (ret < 0) @@ -81,16 +82,11 @@ _handle_inotify_watch (DBusWatch *watch, unsigned int flags, void *data) _dbus_verbose ("inotify event: wd=%d mask=%u cookie=%u len=%u\n", ev->wd, ev->mask, ev->cookie, ev->len); #endif _dbus_verbose ("Sending SIGHUP signal on reception of a inotify event\n"); - (void) kill (pid, SIGHUP); + have_change = TRUE; } + if (have_change) + (void) kill (pid, SIGHUP); - if (watch != NULL) - { - _dbus_loop_remove_watch (loop, watch, _inotify_watch_callback, NULL); - _dbus_watch_unref (watch); - watch = NULL; - } - return TRUE; } @@ -153,6 +149,13 @@ bus_drop_all_directory_watches (void) { int ret; + if (watch != NULL) + { + _dbus_loop_remove_watch (loop, watch, _inotify_watch_callback, NULL); + _dbus_watch_unref (watch); + watch = NULL; + } + _dbus_verbose ("Dropping all watches on config directories\n"); ret = close (inotify_fd); if (ret) |