summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2012-04-15 02:35:31 +0200
committerKay Sievers <kay@vrfy.org>2012-04-15 03:11:08 +0200
commit194bbe33382f5365be3865ed1779147cb680f1d3 (patch)
treea8f8c8ddaacd38e62f49f720151f5de15428640e
parentb45f770f0049fbdf3f6c9db0ab11deeff4ccd86d (diff)
udev: cleanup the udev cgroup when the daemon enters the idle state
-rw-r--r--NEWS14
-rw-r--r--TODO3
-rw-r--r--docs/gudev/gudev-docs.xml2
-rw-r--r--src/udev/udevd.c37
4 files changed, 33 insertions, 23 deletions
diff --git a/NEWS b/NEWS
index 7984b6be9..52196dc0b 100644
--- a/NEWS
+++ b/NEWS
@@ -3,3 +3,8 @@ systemd System and Service Manager
CHANGES WITH 182:
- * udev: sources merged into the systemd sources
+ * udev: all udev sources are merged into the systemd source tree now.
+ All future udev development will happen in the systemd tree. It
+ is still fully supported to use the udev daemon and tools without
+ systemd running, like in initramfs or other init systems. Building
+ udev though, will require the *build* of the systemd tree, but
+ udev can be properly *run* without systems.
@@ -12,2 +17,9 @@ CHANGES WITH 182:
+ * udev: when udevd is started by systemd, processes which are left
+ behind by forking them off of udev rules, are unconditionally cleaned
+ up and killed now after the event handling has finished. Services or
+ daemons must be started as systemd services. Services can be
+ pulled-in by udev to ge started, but they can no longer be directly
+ forked by udev rules.
+
* systemd-logingctl and systemd-journalctl have been renamed
diff --git a/TODO b/TODO
index 48591e4de..1709b5e2c 100644
--- a/TODO
+++ b/TODO
@@ -21,5 +21,2 @@ Features:
-* udevd: SIGKILL all non-udevd processes in udev.service cgroup when entering idle
- (the time to be able start services from udev rules is over on systemd systems)
-
* udev: remove /sys and /dev configurability
diff --git a/docs/gudev/gudev-docs.xml b/docs/gudev/gudev-docs.xml
index b40b61553..4c3267998 100644
--- a/docs/gudev/gudev-docs.xml
+++ b/docs/gudev/gudev-docs.xml
@@ -12,3 +12,3 @@
<copyright>
- <year>2012</year>
+ <year>2009-2012</year>
<holder>David Zeuthen &lt;davidz@redhat.com&gt;</holder>
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index da044fcdc..97b910cc2 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -48,2 +48,3 @@
#include "sd-daemon.h"
+#include "cgroup-util.h"
@@ -74,2 +75,3 @@ static UDEV_LIST(event_list);
static UDEV_LIST(worker_list);
+char *udev_cgroup;
static bool udev_exit;
@@ -454,11 +456,5 @@ static int event_queue_insert(struct udev_device *dev)
-static void worker_kill(struct udev *udev, int retain)
+static void worker_kill(struct udev *udev)
{
struct udev_list_node *loop;
- int max;
-
- if (children <= retain)
- return;
-
- max = children - retain;
@@ -467,5 +463,2 @@ static void worker_kill(struct udev *udev, int retain)
- if (max-- <= 0)
- break;
-
if (worker->state == WORKER_KILLED)
@@ -637,3 +630,3 @@ static struct udev_ctrl_connection *handle_ctrl_msg(struct udev_ctrl *uctrl)
udev_set_log_priority(udev, i);
- worker_kill(udev, 0);
+ worker_kill(udev);
}
@@ -679,3 +672,3 @@ static struct udev_ctrl_connection *handle_ctrl_msg(struct udev_ctrl *uctrl)
}
- worker_kill(udev, 0);
+ worker_kill(udev);
}
@@ -1146,4 +1139,4 @@ int main(int argc, char *argv[])
debug = true;
- if (udev_get_log_priority(udev) < LOG_INFO)
- udev_set_log_priority(udev, LOG_INFO);
+ log_set_max_level(LOG_DEBUG);
+ udev_set_log_priority(udev, LOG_INFO);
break;
@@ -1265,2 +1258,6 @@ int main(int argc, char *argv[])
}
+
+ /* get our own cgroup, we regularly kill everything udev has left behind */
+ if (cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, 0, &udev_cgroup) < 0)
+ udev_cgroup = NULL;
} else {
@@ -1482,3 +1479,3 @@ int main(int argc, char *argv[])
event_queue_cleanup(udev, EVENT_QUEUED);
- worker_kill(udev, 0);
+ worker_kill(udev);
@@ -1490,5 +1487,9 @@ int main(int argc, char *argv[])
timeout = 30 * 1000;
- } else if (udev_list_node_is_empty(&event_list) && children <= 2) {
+ } else if (udev_list_node_is_empty(&event_list) && !children) {
/* we are idle */
timeout = -1;
+
+ /* cleanup possible left-over processes in our cgroup */
+ if (udev_cgroup)
+ cg_kill(SYSTEMD_CGROUP_CONTROLLER, udev_cgroup, SIGKILL, false, true, NULL);
} else {
@@ -1513,3 +1514,3 @@ int main(int argc, char *argv[])
log_debug("cleanup idle workers\n");
- worker_kill(udev, 2);
+ worker_kill(udev);
}
@@ -1568,3 +1569,3 @@ int main(int argc, char *argv[])
if (reload) {
- worker_kill(udev, 0);
+ worker_kill(udev);
rules = udev_rules_unref(rules);