]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: do an extra check if oom was triggered when handling sigchild 12626/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 19 May 2019 13:52:02 +0000 (15:52 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 20 May 2019 14:37:06 +0000 (16:37 +0200)
Should fix #12425.

src/core/cgroup.c
src/core/cgroup.h
src/core/manager.c

index 6cab4b5ee050b6a3aba076ec1fa998b7cdef3bae..042a742fa9b4b7132545adc2858a200da90e3a61 100644 (file)
@@ -2607,7 +2607,7 @@ void unit_add_to_cgroup_empty_queue(Unit *u) {
                 log_debug_errno(r, "Failed to enable cgroup empty event source: %m");
 }
 
-static int unit_check_oom(Unit *u) {
+int unit_check_oom(Unit *u) {
         _cleanup_free_ char *oom_kill = NULL;
         bool increased;
         uint64_t c;
index be8be1b7e7650beea75d16feefa310dfa0a5f1f4..fe347ea11453303ba24b448628295ab7aec848cc 100644 (file)
@@ -197,6 +197,7 @@ int unit_watch_cgroup(Unit *u);
 int unit_watch_cgroup_memory(Unit *u);
 
 void unit_add_to_cgroup_empty_queue(Unit *u);
+int unit_check_oom(Unit *u);
 
 int unit_attach_pids_to_cgroup(Unit *u, Set *pids, const char *suffix_path);
 
index b7848648bebfd430ed0c86c161937feff3200e1d..f7baa345e2e28fefa0755a9cdf15540b598c0342 100644 (file)
@@ -2524,8 +2524,13 @@ static int manager_dispatch_sigchld(sd_event_source *source, void *userdata) {
                 /* Finally, execute them all. Note that u1, u2 and the array might contain duplicates, but
                  * that's fine, manager_invoke_sigchld_event() will ensure we only invoke the handlers once for
                  * each iteration. */
-                if (u1)
+                if (u1) {
+                        /* We check for oom condition, in case we got SIGCHLD before the oom notification.
+                         * We only do this for the cgroup the PID belonged to. */
+                        (void) unit_check_oom(u1);
+
                         manager_invoke_sigchld_event(m, u1, &si);
+                }
                 if (u2)
                         manager_invoke_sigchld_event(m, u2, &si);
                 if (array_copy)