summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-07-01 11:06:45 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-07-20 17:59:53 +0200
commitc15e100eec24e78bb78d4bd8c0b6ef6bdebc73d4 (patch)
tree673501f0ec05e802e159151417386d91fdb26595
parent3fa82957117677ec9d858bf86c203be6a39f812c (diff)
downloadsystemd-c15e100eec24e78bb78d4bd8c0b6ef6bdebc73d4.tar.gz
core: add comment explaining event source deallocation
Followup for bc989831e6. The original reproducer still works w/o the unref, and doesn't work with this change. (cherry picked from commit 13bb1ffb912cacea4041910e38674e0984ac5772) (cherry picked from commit d82da0f04f6ebe7044f4c33b9067c17c909a8d5d)
-rw-r--r--src/core/service.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/core/service.c b/src/core/service.c
index dd4eb3fe9f..6caffc2f27 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -3409,11 +3409,6 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
else
clean_mode = EXIT_CLEAN_DAEMON;
- if (s->main_pid == pid)
- /* Clean up the exec_fd event source. The source owns its end of the pipe, so this will close
- * that too. */
- s->exec_fd_event_source = sd_event_source_disable_unref(s->exec_fd_event_source);
-
if (is_clean_exit(code, status, clean_mode, &s->success_status))
f = SERVICE_SUCCESS;
else if (code == CLD_EXITED)
@@ -3426,6 +3421,11 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
assert_not_reached("Unknown code");
if (s->main_pid == pid) {
+ /* Clean up the exec_fd event source. We want to do this here, not later in
+ * service_set_state(), because service_enter_stop_post() calls service_spawn().
+ * The source owns its end of the pipe, so this will close that too. */
+ s->exec_fd_event_source = sd_event_source_disable_unref(s->exec_fd_event_source);
+
/* Forking services may occasionally move to a new PID.
* As long as they update the PID file before exiting the old
* PID, they're fine. */