diff options
author | Tom Gundersen <teg@jklm.no> | 2015-05-18 17:17:07 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-05-18 23:49:35 +0200 |
commit | 4fa4d885556af16fb945f9a9402e71077d5a4e4a (patch) | |
tree | b90c2e78b3790e8d79947e80480e1178c1e5f56c /src | |
parent | f29328d6557f1ebb3df5c0b491fb3dd3d970d356 (diff) |
udevd: introduce on_event_timeout{,_warning}
This uses kill_and_sigcont() instead of kill(), otherwise no functional change.
Diffstat (limited to 'src')
-rw-r--r-- | src/udev/udevd.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c index a9e82de4cd..a641b16e8b 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -43,6 +43,7 @@ #include "sd-daemon.h" #include "rtnl-util.h" #include "cgroup-util.h" +#include "process-util.h" #include "dev-setup.h" #include "fileio.h" #include "selinux-util.h" @@ -226,6 +227,30 @@ static int worker_new(struct worker **ret, Manager *manager, struct udev_monitor return 0; } +static int on_event_timeout(sd_event_source *s, uint64_t usec, void *userdata) { + struct event *event = userdata; + + assert(event); + assert(event->worker); + + kill_and_sigcont(event->worker->pid, SIGKILL); + event->worker->state = WORKER_KILLED; + + log_error("seq %llu '%s' killed", udev_device_get_seqnum(event->dev), event->devpath); + + return 1; +} + +static int on_event_timeout_warning(sd_event_source *s, uint64_t usec, void *userdata) { + struct event *event = userdata; + + assert(event); + + log_warning("seq %llu '%s' is taking a long time", udev_device_get_seqnum(event->dev), event->devpath); + + return 1; +} + static void worker_attach_event(struct worker *worker, struct event *event) { assert(worker); assert(event); @@ -1571,14 +1596,10 @@ int main(int argc, char *argv[]) { ts = now(CLOCK_MONOTONIC); if ((ts - event->start_usec) > arg_event_timeout_warn_usec) { - if ((ts - event->start_usec) > arg_event_timeout_usec) { - log_error("worker ["PID_FMT"] %s timeout; kill it", worker->pid, event->devpath); - kill(worker->pid, SIGKILL); - worker->state = WORKER_KILLED; - - log_error("seq %llu '%s' killed", udev_device_get_seqnum(event->dev), event->devpath); - } else if (!event->warned) { - log_warning("worker ["PID_FMT"] %s is taking a long time", worker->pid, event->devpath); + if ((ts - event->start_usec) > arg_event_timeout_usec) + on_event_timeout(NULL, 0, event); + else if (!event->warned) { + on_event_timeout_warning(NULL, 0, event); event->warned = true; } } |