803fb7
From fa37e91818c1de70977462d170df08f441170db5 Mon Sep 17 00:00:00 2001
803fb7
From: Michal Sekletar <msekletar@users.noreply.github.com>
803fb7
Date: Thu, 25 Aug 2016 08:18:42 +0200
803fb7
Subject: [PATCH] udev: inform systemd how many workers we can potentially
803fb7
 spawn (#4036)
803fb7
803fb7
(cherry picked from commit 1ef72b55ba6d38f879d7ac9f0237cf8a2b53f0e6)
803fb7
Resolves: #1361601
803fb7
---
803fb7
 src/udev/udevd.c | 10 ++++++++--
803fb7
 1 file changed, 8 insertions(+), 2 deletions(-)
803fb7
803fb7
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
803fb7
index 82c7a5425..1d21182fb 100644
803fb7
--- a/src/udev/udevd.c
803fb7
+++ b/src/udev/udevd.c
803fb7
@@ -697,6 +697,10 @@ static struct udev_ctrl_connection *handle_ctrl_msg(struct udev_ctrl *uctrl) {
803fb7
         if (i >= 0) {
803fb7
                 log_debug("udevd message (SET_MAX_CHILDREN) received, children_max=%i", i);
803fb7
                 arg_children_max = i;
803fb7
+
803fb7
+                (void) sd_notifyf(false,
803fb7
+                                  "READY=1\n"
803fb7
+                                  "STATUS=Processing with %u children at max", arg_children_max);
803fb7
         }
803fb7
 
803fb7
         if (udev_ctrl_get_ping(ctrl_msg) > 0)
803fb7
@@ -1271,8 +1275,6 @@ int main(int argc, char *argv[]) {
803fb7
                 setsid();
803fb7
 
803fb7
                 write_string_file("/proc/self/oom_score_adj", "-1000");
803fb7
-        } else {
803fb7
-                sd_notify(1, "READY=1");
803fb7
         }
803fb7
 
803fb7
         if (arg_children_max <= 0) {
803fb7
@@ -1321,6 +1323,10 @@ int main(int argc, char *argv[]) {
803fb7
         ep_netlink.data.fd = fd_netlink;
803fb7
         ep_worker.data.fd = fd_worker;
803fb7
 
803fb7
+        (void) sd_notifyf(false,
803fb7
+                          "READY=1\n"
803fb7
+                          "STATUS=Processing with %u children at max", arg_children_max);
803fb7
+
803fb7
         fd_ep = epoll_create1(EPOLL_CLOEXEC);
803fb7
         if (fd_ep < 0) {
803fb7
                 log_error_errno(errno, "error creating epoll fd: %m");