chiark / gitweb /
disable the cgroups release agent when shutting down
authorKay Sievers <kay@vrfy.org>
Thu, 4 Jul 2013 18:31:18 +0000 (20:31 +0200)
committerKay Sievers <kay@vrfy.org>
Thu, 4 Jul 2013 18:31:18 +0000 (20:31 +0200)
During shutdown, when we try to clean up all remaining processes, the
kernel will fork new agents every time a cgroup runs empty. These
new processes cause delays in the final SIGTERM, SIGKILL logic.

Apart from that, this should also avoid that the kernel-forked binaries
cause unpredictably timed access to the filesystem which we might need to
unmount.

src/core/main.c
src/shared/cgroup-util.c
src/shared/cgroup-util.h

index 8b8e110f249877a1a447c622a70a7b7df56efd78..ada0f9d94b55d187c3b1c4f59dbc40036645c72b 100644 (file)
@@ -1942,6 +1942,10 @@ finish:
                         watchdog_close(true);
                 }
 
+               /* avoid the creation of new processes forked by the kernel; at this
+                 * point, we will not listen to the signals anyway */
+               cg_uninstall_release_agent(SYSTEMD_CGROUP_CONTROLLER);
+
                 execve(SYSTEMD_SHUTDOWN_BINARY_PATH, (char **) command_line, env_block);
                 free(env_block);
                 log_error("Failed to execute shutdown binary, freezing: %m");
index 390259e3e43c5e28b18de5b18494a43291fa0b75..73013d1d97f1b908fb61b9469b44d06261d9b237 100644 (file)
@@ -790,6 +790,21 @@ int cg_install_release_agent(const char *controller, const char *agent) {
         return 0;
 }
 
+int cg_uninstall_release_agent(const char *controller) {
+        _cleanup_free_ char *fs = NULL;
+        int r;
+
+        r = cg_get_path(controller, NULL, "release_agent", &fs);
+        if (r < 0)
+                return r;
+
+        r = write_string_file(fs, "");
+        if (r < 0)
+                return r;
+
+       return 0;
+}
+
 int cg_is_empty(const char *controller, const char *path, bool ignore_self) {
         _cleanup_fclose_ FILE *f = NULL;
         pid_t pid = 0, self_pid;
index c781aabb2280f046585a453a41d5876a98b2c713..0fc93c12c87737ae64f3448c2c16c3d5c44e2345 100644 (file)
@@ -89,6 +89,7 @@ int cg_set_group_access(const char *controller, const char *path, mode_t mode, u
 int cg_set_task_access(const char *controller, const char *path, mode_t mode, uid_t uid, gid_t gid);
 
 int cg_install_release_agent(const char *controller, const char *agent);
+int cg_uninstall_release_agent(const char *controller);
 
 int cg_is_empty(const char *controller, const char *path, bool ignore_self);
 int cg_is_empty_by_spec(const char *spec, bool ignore_self);