]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: enable kill workers timer when processing queued events stopped
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 7 May 2025 16:07:44 +0000 (01:07 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 8 May 2025 23:54:26 +0000 (08:54 +0900)
It is not necessary to keep idle workers so long time in that case.

src/udev/udev-manager-ctrl.c
src/udev/udev-manager.c
src/udev/udev-manager.h
src/udev/udev-varlink.c

index 397ed0341065e3682af4d322d5d99224f80dd91e..d9cc44bc5ca76d4b042efd5a880fc0d2c999ed62 100644 (file)
@@ -29,6 +29,7 @@ static int on_ctrl_msg(UdevCtrl *uctrl, UdevCtrlMessageType type, const UdevCtrl
         case UDEV_CTRL_STOP_EXEC_QUEUE:
                 log_debug("Received udev control message (STOP_EXEC_QUEUE)");
                 manager->stop_exec_queue = true;
+                (void) manager_reset_kill_workers_timer(manager);
                 break;
         case UDEV_CTRL_START_EXEC_QUEUE:
                 log_debug("Received udev control message (START_EXEC_QUEUE)");
index dc684d4b95b62705ae526f44c5e9e818616a34cc..2ad47258f71d1167c6680238616a3700aa5c3739 100644 (file)
@@ -201,7 +201,7 @@ static int on_kill_workers_event(sd_event_source *s, uint64_t usec, void *userda
         return 0;
 }
 
-static int manager_reset_kill_workers_timer(Manager *manager) {
+int manager_reset_kill_workers_timer(Manager *manager) {
         int r;
 
         assert(manager);
index 4f6d1168577d21e7ce335323675fbb53e55f86f0..4a2225d1c2d0a01e5fc3a51e068fd9813bfaa997 100644 (file)
@@ -93,6 +93,7 @@ void manager_exit(Manager *manager);
 void notify_ready(Manager *manager);
 
 void manager_kill_workers(Manager *manager, int signo);
+int manager_reset_kill_workers_timer(Manager *manager);
 
 bool devpath_conflict(const char *a, const char *b);
 
index d087a33b5d0d21c35b6e72ffafd2e153a20d10b1..5c0a97be3dafa0f61f096c920cb34493d6c0e45d 100644 (file)
@@ -136,6 +136,14 @@ static int vl_method_start_stop_exec_queue(sd_varlink *link, sd_json_variant *pa
 
         log_debug("Received %s()", method);
         manager->stop_exec_queue = streq(method, "io.systemd.Udev.StopExecQueue");
+
+        /* In case that processing queued events will be stopped for a while, regardless if there exist
+         * queued events, enable the kill workers timer here unless it is already enabled. Note, it is not
+         * necessary to disable the timer when processing is restarted, as it will be anyway disabled in
+         * on_post() -> event_queue_start(). */
+        if (manager->stop_exec_queue)
+                (void) manager_reset_kill_workers_timer(manager);
+
         return sd_varlink_reply(link, NULL);
 }