diff options
author | Hannes Reinecke <hare@suse.de> | 2014-07-29 09:06:14 +0200 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2014-07-30 09:30:59 -0400 |
commit | babb0ec5865658d920ef0bb07c89a3122beb8ec2 (patch) | |
tree | b4a459fa0ef2c225a96887004d4bb0c8c735e8ef /src/udev/udevd.c | |
parent | c4ffad5655a4c30fbfea4240007f88e98ec52af9 (diff) |
udevd: add --event-timeout commandline option
Some events take longer than the default 30 seconds. Killing those
events will leave the machine halfway configured.
Add a commandline option '--event-timeout' to handle these cases.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/udev/udevd.c')
-rw-r--r-- | src/udev/udevd.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 617e029749..269baa3ce2 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -74,6 +74,7 @@ static bool reload; static int children; static int children_max; static int exec_delay; +static int event_timeout = 30; static sigset_t sigmask_orig; static UDEV_LIST(event_list); static UDEV_LIST(worker_list); @@ -312,6 +313,9 @@ static void worker_new(struct event *event) } } + if (event_timeout != 30) + udev_event->timeout_usec = event_timeout * USEC_PER_SEC; + /* apply rules, create node, symlinks */ udev_event_execute_rules(udev_event, rules, &sigmask_orig); @@ -1044,6 +1048,8 @@ static void kernel_cmdline_options(struct udev *udev) children_max = strtoul(opt + 18, NULL, 0); } else if (startswith(opt, "udev.exec-delay=")) { exec_delay = strtoul(opt + 16, NULL, 0); + } else if (startswith(opt, "udev.event-timeout=")) { + event_timeout = strtoul(opt + 16, NULL, 0); } free(s); @@ -1061,6 +1067,7 @@ int main(int argc, char *argv[]) { "debug", no_argument, NULL, 'D' }, { "children-max", required_argument, NULL, 'c' }, { "exec-delay", required_argument, NULL, 'e' }, + { "event-timeout", required_argument, NULL, 't' }, { "resolve-names", required_argument, NULL, 'N' }, { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, @@ -1103,6 +1110,9 @@ int main(int argc, char *argv[]) case 'e': exec_delay = strtoul(optarg, NULL, 0); break; + case 't': + event_timeout = strtoul(optarg, NULL, 0); + break; case 'D': debug = true; log_set_max_level(LOG_DEBUG); @@ -1433,7 +1443,7 @@ int main(int argc, char *argv[]) if (worker->state != WORKER_RUNNING) continue; - if ((now(CLOCK_MONOTONIC) - worker->event_start_usec) > 30 * USEC_PER_SEC) { + if ((now(CLOCK_MONOTONIC) - worker->event_start_usec) > event_timeout * USEC_PER_SEC) { log_error("worker [%u] %s timeout; kill it", worker->pid, worker->event ? worker->event->devpath : "<idle>"); kill(worker->pid, SIGKILL); |