diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-03-03 01:32:34 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-03-03 20:16:56 -0500 |
commit | bc41f93e90f6edcc9067f3bc1085bb6c85082c00 (patch) | |
tree | 3dc1a8a6642b283dfa5844c667128f7ded0a4611 /src/core/service.c | |
parent | 03c149144d374cffd40a17ffb067837e3e220933 (diff) |
core/path: install inotify watches top-down instead of bottom-up
When watches are installed from the bottom, it is always possible
to race, and miss a file creation event. The race can be avoided
if a watch is first established for a parent directory, and then for
the file in the directory. If the file is created in the time between,
the watch on the parent directory will fire.
Some messages (mostly at debug level) are added to help diagnose
pidfile issues.
Should fix https://bugzilla.redhat.com/show_bug.cgi?id=917075.
Diffstat (limited to 'src/core/service.c')
-rw-r--r-- | src/core/service.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/core/service.c b/src/core/service.c index 3f8aabcf45..61b150cba8 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -1400,8 +1400,13 @@ static int service_load_pid_file(Service *s, bool may_warn) { } r = parse_pid(k, &pid); - if (r < 0) + if (r < 0) { + if (may_warn) + log_info_unit(UNIT(s)->id, + "Failed to read PID from file %s: %s", + s->pid_file, strerror(-r)); return r; + } if (kill(pid, 0) < 0 && errno != EPERM) { if (may_warn) @@ -1429,9 +1434,13 @@ static int service_load_pid_file(Service *s, bool may_warn) { return r; r = unit_watch_pid(UNIT(s), pid); - if (r < 0) + if (r < 0) { /* FIXME: we need to do something here */ + log_warning_unit(UNIT(s)->id, + "Failed to watch PID %lu from service %s", + (unsigned long) pid, UNIT(s)->id); return r; + } return 0; } @@ -2824,6 +2833,9 @@ static int service_watch_pid_file(Service *s) { goto fail; /* the pidfile might have appeared just before we set the watch */ + log_debug_unit(UNIT(s)->id, + "Trying to read %s's PID file %s in case it changed", + UNIT(s)->id, s->pid_file_pathspec->path); service_retry_pid_file(s); return 0; |