mirror of
https://github.com/systemd/systemd
synced 2024-10-14 20:17:52 +00:00
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.
This commit is contained in:
parent
32767cb1e8
commit
9719859c07
|
@ -44,6 +44,7 @@
|
||||||
<arg><option>--debug</option></arg>
|
<arg><option>--debug</option></arg>
|
||||||
<arg><option>--children-max=</option></arg>
|
<arg><option>--children-max=</option></arg>
|
||||||
<arg><option>--exec-delay=</option></arg>
|
<arg><option>--exec-delay=</option></arg>
|
||||||
|
<arg><option>--event-timeout=</option></arg>
|
||||||
<arg><option>--resolve-names=early|late|never</option></arg>
|
<arg><option>--resolve-names=early|late|never</option></arg>
|
||||||
<arg><option>--version</option></arg>
|
<arg><option>--version</option></arg>
|
||||||
<arg><option>--help</option></arg>
|
<arg><option>--help</option></arg>
|
||||||
|
@ -95,6 +96,15 @@
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--event-timeout=</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Wait for the event to finish up to the given
|
||||||
|
number of seconds. After this time the event will
|
||||||
|
be terminated. Default is 30.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>--resolve-names=</option></term>
|
<term><option>--resolve-names=</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@ -155,6 +165,15 @@
|
||||||
non-working kernel modules.</para>
|
non-working kernel modules.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>udev.event-timeout=</varname></term>
|
||||||
|
<term><varname>rd.udev.event-timeout=</varname></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Wait for events to finish up to the given number
|
||||||
|
of seconds. This option might be useful if events are
|
||||||
|
terminated due to a timeout in large configurations.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>net.ifnames=</varname></term>
|
<term><varname>net.ifnames=</varname></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
|
|
@ -74,6 +74,7 @@ static bool reload;
|
||||||
static int children;
|
static int children;
|
||||||
static int children_max;
|
static int children_max;
|
||||||
static int exec_delay;
|
static int exec_delay;
|
||||||
|
static int event_timeout = 30;
|
||||||
static sigset_t sigmask_orig;
|
static sigset_t sigmask_orig;
|
||||||
static UDEV_LIST(event_list);
|
static UDEV_LIST(event_list);
|
||||||
static UDEV_LIST(worker_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 */
|
/* apply rules, create node, symlinks */
|
||||||
udev_event_execute_rules(udev_event, rules, &sigmask_orig);
|
udev_event_execute_rules(udev_event, rules, &sigmask_orig);
|
||||||
|
|
||||||
|
@ -1009,6 +1013,8 @@ static void kernel_cmdline_options(struct udev *udev)
|
||||||
children_max = strtoul(opt + 18, NULL, 0);
|
children_max = strtoul(opt + 18, NULL, 0);
|
||||||
} else if (startswith(opt, "udev.exec-delay=")) {
|
} else if (startswith(opt, "udev.exec-delay=")) {
|
||||||
exec_delay = strtoul(opt + 16, NULL, 0);
|
exec_delay = strtoul(opt + 16, NULL, 0);
|
||||||
|
} else if (startswith(opt, "udev.event-timeout=")) {
|
||||||
|
event_timeout = strtoul(opt + 16, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(s);
|
free(s);
|
||||||
|
@ -1026,6 +1032,7 @@ int main(int argc, char *argv[])
|
||||||
{ "debug", no_argument, NULL, 'D' },
|
{ "debug", no_argument, NULL, 'D' },
|
||||||
{ "children-max", required_argument, NULL, 'c' },
|
{ "children-max", required_argument, NULL, 'c' },
|
||||||
{ "exec-delay", required_argument, NULL, 'e' },
|
{ "exec-delay", required_argument, NULL, 'e' },
|
||||||
|
{ "event-timeout", required_argument, NULL, 't' },
|
||||||
{ "resolve-names", required_argument, NULL, 'N' },
|
{ "resolve-names", required_argument, NULL, 'N' },
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
{ "version", no_argument, NULL, 'V' },
|
{ "version", no_argument, NULL, 'V' },
|
||||||
|
@ -1069,6 +1076,9 @@ int main(int argc, char *argv[])
|
||||||
case 'e':
|
case 'e':
|
||||||
exec_delay = strtoul(optarg, NULL, 0);
|
exec_delay = strtoul(optarg, NULL, 0);
|
||||||
break;
|
break;
|
||||||
|
case 't':
|
||||||
|
event_timeout = strtoul(optarg, NULL, 0);
|
||||||
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
debug = true;
|
debug = true;
|
||||||
log_set_max_level(LOG_DEBUG);
|
log_set_max_level(LOG_DEBUG);
|
||||||
|
@ -1406,7 +1416,7 @@ int main(int argc, char *argv[])
|
||||||
if (worker->state != WORKER_RUNNING)
|
if (worker->state != WORKER_RUNNING)
|
||||||
continue;
|
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,
|
log_error("worker [%u] %s timeout; kill it", worker->pid,
|
||||||
worker->event ? worker->event->devpath : "<idle>");
|
worker->event ? worker->event->devpath : "<idle>");
|
||||||
kill(worker->pid, SIGKILL);
|
kill(worker->pid, SIGKILL);
|
||||||
|
|
Loading…
Reference in a new issue