extern bool limiter;
extern void __update_plog(const struct log_config *conf);
-static void __setup_runtime_watch(char const *path)
+static bool __setup_runtime_watch(char const *path)
{
assert(path);
assert(inotify_fd == -1);
inotify_fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
if (inotify_fd == -1) {
- syslog_critical_failure("DLog: inotify_init failed (%d)", errno);// LCOV_EXCL_LINE
- return;// LCOV_EXCL_LINE
+ syslog_critical_failure("DLog: inotify_init failed (%d)", errno);
+ return false;
}
inotify_wd = inotify_add_watch(inotify_fd, path, IN_CREATE | IN_CLOSE_WRITE | IN_MOVE | IN_DELETE);
if (inotify_wd == -1) {
- syslog_critical_failure("DLog: inotify_add_watch failed (%d)", errno);// LCOV_EXCL_LINE
- close(inotify_fd);// LCOV_EXCL_LINE
- inotify_fd = -1;// LCOV_EXCL_LINE
- return;// LCOV_EXCL_LINE
+ syslog_critical_failure("DLog: inotify_add_watch failed (%d)", errno);
+ close(inotify_fd);
+ inotify_fd = -1;
+ return false;
}
+
+ return true;
}
static void __apply_update()
__attribute__((cleanup(log_config_free))) struct log_config config = {NULL, NULL};
const int r = log_config_read_file(&config, inotify_path);
if (r && r != -ENOENT) {
- syslog_critical_failure("DLog: keeping current runtime filters, can't read from \"%s\" (%d)", inotify_path, -r);// LCOV_EXCL_LINE
+ syslog_critical_failure("DLog: keeping current runtime filters, can't read from \"%s\" (%d)", inotify_path, -r);
return;
}
return false; // LCOV_EXCL_LINE
}
+ if (!__setup_runtime_watch(extra_config_path)) {
+ free(inotify_path);
+ inotify_path = NULL;
+ return false;
+ }
+
/* missing filters config file at startup
* is not an error so no need to check
* return value here
*/
log_config_read_file(config, inotify_path);
- __setup_runtime_watch(extra_config_path);
-
return true;
}