udev: enable kill workers timer when processing queued events stopped
It is not necessary to keep idle workers so long time in that case.
This commit is contained in:
@@ -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)");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user