teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame 0001-revert-udev-killing.patch

Michal Schmidt 59081b
From 2b3509a898dcb65d6fba41f3c9cd484b00730017 Mon Sep 17 00:00:00 2001
Michal Schmidt 59081b
From: Michal Schmidt <mschmidt@redhat.com>
Michal Schmidt 59081b
Date: Thu, 15 Nov 2012 16:55:09 +0100
Michal Schmidt 59081b
Subject: [PATCH] revert udev killing
Michal Schmidt 59081b
Michal Schmidt 59081b
revert of upstream commit 194bbe33382f5365be3865ed1779147cb680f1d3
Michal Schmidt 59081b
---
Michal Schmidt 59081b
 src/udev/udevd.c | 32 ++++++++++++++++----------------
Michal Schmidt 59081b
 1 file changed, 16 insertions(+), 16 deletions(-)
Michal Schmidt 59081b
Michal Schmidt 59081b
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
Michal Schmidt 59081b
index ebd601e..53322b0 100644
Michal Schmidt 59081b
--- a/src/udev/udevd.c
Michal Schmidt 59081b
+++ b/src/udev/udevd.c
Michal Schmidt 59081b
@@ -74,7 +74,6 @@ static int exec_delay;
Michal Schmidt 59081b
 static sigset_t sigmask_orig;
Michal Schmidt 59081b
 static UDEV_LIST(event_list);
Michal Schmidt 59081b
 static UDEV_LIST(worker_list);
Michal Schmidt 59081b
-char *udev_cgroup;
Michal Schmidt 59081b
 static bool udev_exit;
Michal Schmidt 59081b
 
Michal Schmidt 59081b
 enum event_state {
Michal Schmidt 59081b
@@ -453,13 +452,22 @@ static int event_queue_insert(struct udev_device *dev)
Michal Schmidt 59081b
         return 0;
Michal Schmidt 59081b
 }
Michal Schmidt 59081b
 
Michal Schmidt 59081b
-static void worker_kill(struct udev *udev)
Michal Schmidt 59081b
+static void worker_kill(struct udev *udev, int retain)
Michal Schmidt 59081b
 {
Michal Schmidt 59081b
         struct udev_list_node *loop;
Michal Schmidt 59081b
+        int max;
Michal Schmidt 59081b
+
Michal Schmidt 59081b
+        if (children <= retain)
Michal Schmidt 59081b
+                return;
Michal Schmidt 59081b
+
Michal Schmidt 59081b
+        max = children - retain;
Michal Schmidt 59081b
 
Michal Schmidt 59081b
         udev_list_node_foreach(loop, &worker_list) {
Michal Schmidt 59081b
                 struct worker *worker = node_to_worker(loop);
Michal Schmidt 59081b
 
Michal Schmidt 59081b
+                if (max-- <= 0)
Michal Schmidt 59081b
+                        break;
Michal Schmidt 59081b
+
Michal Schmidt 59081b
                 if (worker->state == WORKER_KILLED)
Michal Schmidt 59081b
                         continue;
Michal Schmidt 59081b
 
Michal Schmidt 59081b
@@ -631,7 +639,7 @@ static struct udev_ctrl_connection *handle_ctrl_msg(struct udev_ctrl *uctrl)
Michal Schmidt 59081b
                 log_debug("udevd message (SET_LOG_PRIORITY) received, log_priority=%i\n", i);
Michal Schmidt 59081b
                 log_set_max_level(i);
Michal Schmidt 59081b
                 udev_set_log_priority(udev, i);
Michal Schmidt 59081b
-                worker_kill(udev);
Michal Schmidt 59081b
+                worker_kill(udev, 0);
Michal Schmidt 59081b
         }
Michal Schmidt 59081b
 
Michal Schmidt 59081b
         if (udev_ctrl_get_stop_exec_queue(ctrl_msg) > 0) {
Michal Schmidt 59081b
@@ -673,7 +681,7 @@ static struct udev_ctrl_connection *handle_ctrl_msg(struct udev_ctrl *uctrl)
Michal Schmidt 59081b
                         }
Michal Schmidt 59081b
                         free(key);
Michal Schmidt 59081b
                 }
Michal Schmidt 59081b
-                worker_kill(udev);
Michal Schmidt 59081b
+                worker_kill(udev, 0);
Michal Schmidt 59081b
         }
Michal Schmidt 59081b
 
Michal Schmidt 59081b
         i = udev_ctrl_get_set_children_max(ctrl_msg);
Michal Schmidt 59081b
@@ -1198,10 +1206,6 @@ int main(int argc, char *argv[])
Michal Schmidt 59081b
                         rc = 3;
Michal Schmidt 59081b
                         goto exit;
Michal Schmidt 59081b
                 }
Michal Schmidt 59081b
-
Michal Schmidt 59081b
-                /* get our own cgroup, we regularly kill everything udev has left behind */
Michal Schmidt 59081b
-                if (cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, 0, &udev_cgroup) < 0)
Michal Schmidt 59081b
-                        udev_cgroup = NULL;
Michal Schmidt 59081b
         } else {
Michal Schmidt 59081b
                 /* open control and netlink socket */
Michal Schmidt 59081b
                 udev_ctrl = udev_ctrl_new(udev);
Michal Schmidt 59081b
@@ -1400,7 +1404,7 @@ int main(int argc, char *argv[])
Michal Schmidt 59081b
 
Michal Schmidt 59081b
                         /* discard queued events and kill workers */
Michal Schmidt 59081b
                         event_queue_cleanup(udev, EVENT_QUEUED);
Michal Schmidt 59081b
-                        worker_kill(udev);
Michal Schmidt 59081b
+                        worker_kill(udev, 0);
Michal Schmidt 59081b
 
Michal Schmidt 59081b
                         /* exit after all has cleaned up */
Michal Schmidt 59081b
                         if (udev_list_node_is_empty(&event_list) && udev_list_node_is_empty(&worker_list))
Michal Schmidt 59081b
@@ -1408,13 +1412,9 @@ int main(int argc, char *argv[])
Michal Schmidt 59081b
 
Michal Schmidt 59081b
                         /* timeout at exit for workers to finish */
Michal Schmidt 59081b
                         timeout = 30 * 1000;
Michal Schmidt 59081b
-                } else if (udev_list_node_is_empty(&event_list) && !children) {
Michal Schmidt 59081b
+                } else if (udev_list_node_is_empty(&event_list) && children <= 2) {
Michal Schmidt 59081b
                         /* we are idle */
Michal Schmidt 59081b
                         timeout = -1;
Michal Schmidt 59081b
-
Michal Schmidt 59081b
-                        /* cleanup possible left-over processes in our cgroup */
Michal Schmidt 59081b
-                        if (udev_cgroup)
Michal Schmidt 59081b
-                                cg_kill(SYSTEMD_CGROUP_CONTROLLER, udev_cgroup, SIGKILL, false, true, NULL);
Michal Schmidt 59081b
                 } else {
Michal Schmidt 59081b
                         /* kill idle or hanging workers */
Michal Schmidt 59081b
                         timeout = 3 * 1000;
Michal Schmidt 59081b
@@ -1435,7 +1435,7 @@ int main(int argc, char *argv[])
Michal Schmidt 59081b
                         /* kill idle workers */
Michal Schmidt 59081b
                         if (udev_list_node_is_empty(&event_list)) {
Michal Schmidt 59081b
                                 log_debug("cleanup idle workers\n");
Michal Schmidt 59081b
-                                worker_kill(udev);
Michal Schmidt 59081b
+                                worker_kill(udev, 2);
Michal Schmidt 59081b
                         }
Michal Schmidt 59081b
 
Michal Schmidt 59081b
                         /* check for hanging events */
Michal Schmidt 59081b
@@ -1490,7 +1490,7 @@ int main(int argc, char *argv[])
Michal Schmidt 59081b
 
Michal Schmidt 59081b
                 /* reload requested, HUP signal received, rules changed, builtin changed */
Michal Schmidt 59081b
                 if (reload) {
Michal Schmidt 59081b
-                        worker_kill(udev);
Michal Schmidt 59081b
+                        worker_kill(udev, 0);
Michal Schmidt 59081b
                         rules = udev_rules_unref(rules);
Michal Schmidt 59081b
                         udev_builtin_exit(udev);
Michal Schmidt 59081b
                         reload = false;
Michal Schmidt 59081b
-- 
Michal Schmidt 59081b
1.7.11.7
Michal Schmidt 59081b