For some reason, sometimes when 'make install'-ing a project that installs dbus config files, dbus will fail to validate one of the config files and not re-watch the config directories.
- intofiy notices change, writes HUP to pipe
- mainloop processes HUP, calls bus_context_reload_config()
- process_config_every_time() returns an error, possibly it tried to read in a half-written file
- bus_context_reload_config() skips process_config_postinit(), which re-watches the config directory
All further updates of config files in the config directory are lost until a SIGHUP is sent to the daemon.
I'd suggest unconditionally calling process_config_postinit() or unconditionally re-adding the directory watches even if process_config_every_time() fails.
Created attachment 17034 [details] [review]
Dan and I tracked this down; in handle_inotify_watch, we *always* remove the watch from the mainloop, even if no error occurred. This caused a side effect where we were relying on then later calling bus_drop_all_directory_watches which would close the fd, and cause the watch to be readded when we first process a directory.
In the case where we hit a config file error, we would drop the watch, but then it would never be readded.
The right fix here I believe is to drop the watch inside bus_drop_all_directory_watches to match the inotify fd being closed and set to -1.
I checked the FreeBSD kqueue version, and they only drop the watch on error.
I'm almost sure this change is right because the code to drop the watch was clearly wrong - it set the watch to NULL even though the watch parameter was an auto parameter that shadowed the global watch variable.
Author: Colin Walters <firstname.lastname@example.org>
Date: Mon Jul 28 12:02:56 2008 -0400
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.