Skip to content

Commit

Permalink
udev-spawn: skip executing RUN= if exec_delay= is too long
Browse files Browse the repository at this point in the history
To prevent the worker process killed by the manager.
  • Loading branch information
yuwata committed Jan 2, 2024
1 parent 406c96e commit 1170697
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/udev/udev-spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,17 @@ void udev_event_execute_run(UdevEvent *event) {
log_device_debug_errno(event->dev, r, "Failed to run built-in command \"%s\", ignoring: %m", command);
} else {
if (event->worker && event->worker->exec_delay_usec > 0) {
usec_t timeout_usec = event->worker ? event->worker->timeout_usec : DEFAULT_WORKER_TIMEOUT_USEC;
usec_t now_usec = now(CLOCK_MONOTONIC);
usec_t age_usec = usec_sub_unsigned(now_usec, event->birth_usec);

if (event->worker->exec_delay_usec >= usec_sub_unsigned(timeout_usec, age_usec)) {
log_device_warning(event->dev,
"Cannot delaying execution of \"%s\" for %s, skipping.",
command, FORMAT_TIMESPAN(event->worker->exec_delay_usec, USEC_PER_SEC));
continue;
}

log_device_debug(event->dev, "Delaying execution of \"%s\" for %s.",
command, FORMAT_TIMESPAN(event->worker->exec_delay_usec, USEC_PER_SEC));
(void) usleep_safe(event->worker->exec_delay_usec);
Expand Down

0 comments on commit 1170697

Please sign in to comment.