summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2012-01-19 23:58:07 +0100
committerMichal Schmidt <mschmidt@redhat.com>2012-01-20 00:51:56 +0100
commit3e52541ef51b1004357fbcd4bf863fb955ab83e9 (patch)
tree62056f0ef2e5014efbc6607fc1ad568046bb99cc
parenta3f914b2a21decb0c4bd7a763ddd3ace215091cb (diff)
service: add missing pid file unwatch in the destructor
The pid file watch could outlive the service unit if a daemon-reload request came at the right time. The inotify event would then be delivered to who knows where. Fix it by unwatching in the service destructor. Further changes will be needed to preserve the state of the pid file watch across daemon-reload. For now let's just fix the crash observed by Jóhann Guðmundsson: Assertion 's->state == SERVICE_START || s->state == SERVICE_START_POST' failed at src/service.c:2609, function service_fd_event(). Aborting Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=783118
-rw-r--r--src/service.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/service.c b/src/service.c
index 0a5c35ec96..4dcd306009 100644
--- a/src/service.c
+++ b/src/service.c
@@ -147,6 +147,17 @@ static void service_unwatch_main_pid(Service *s) {
s->main_pid = 0;
}
+static void service_unwatch_pid_file(Service *s) {
+ if (!s->pid_file_pathspec)
+ return;
+
+ log_debug("Stopping watch for %s's PID file %s", UNIT(s)->id, s->pid_file_pathspec->path);
+ path_spec_unwatch(s->pid_file_pathspec, UNIT(s));
+ path_spec_done(s->pid_file_pathspec);
+ free(s->pid_file_pathspec);
+ s->pid_file_pathspec = NULL;
+}
+
static int service_set_main_pid(Service *s, pid_t pid) {
pid_t ppid;
@@ -222,6 +233,7 @@ static void service_done(Unit *u) {
* our resources */
service_unwatch_main_pid(s);
service_unwatch_control_pid(s);
+ service_unwatch_pid_file(s);
if (s->bus_name) {
unit_unwatch_bus_name(u, s->bus_name);
@@ -1389,17 +1401,6 @@ static void service_notify_sockets_dead(Service *s) {
return;
}
-static void service_unwatch_pid_file(Service *s) {
- if (!s->pid_file_pathspec)
- return;
-
- log_debug("Stopping watch for %s's PID file %s", UNIT(s)->id, s->pid_file_pathspec->path);
- path_spec_unwatch(s->pid_file_pathspec, UNIT(s));
- path_spec_done(s->pid_file_pathspec);
- free(s->pid_file_pathspec);
- s->pid_file_pathspec = NULL;
-}
-
static void service_set_state(Service *s, ServiceState state) {
ServiceState old_state;
assert(s);