summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-04-27 12:14:38 +0200
committerAnthony G. Basile <blueness@gentoo.org>2015-05-26 11:29:14 -0400
commit0aef2f056ac53c114890e6e96e8f31f87406ac12 (patch)
tree7f8f906f6eca358b1f74fdbd8c60fd21e6b67e33 /src
parent1571f2751556e42fe54d3e0ff6472bff210b1817 (diff)
udevd: worker - move some fields from the worker to the event
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r--src/udev/udevd.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 9caf853db8..98c7feeec0 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -97,6 +97,8 @@ struct event {
dev_t devnum;
int ifindex;
bool is_block;
+ usec_t start_usec;
+ bool warned;
};
static inline struct event *node_to_event(struct udev_list_node *node) {
@@ -120,8 +122,6 @@ struct worker {
struct udev_monitor *monitor;
enum worker_state state;
struct event *event;
- usec_t event_start_usec;
- bool event_warned;
};
/* passed from worker to main process */
@@ -198,10 +198,10 @@ static int worker_new(struct worker **ret, struct udev *udev, struct udev_monito
static void worker_attach_event(struct worker *worker, struct event *event) {
worker->state = WORKER_RUNNING;
- worker->event_start_usec = now(CLOCK_MONOTONIC);
- worker->event_warned = false;
worker->event = event;
event->state = EVENT_RUNNING;
+ event->start_usec = now(CLOCK_MONOTONIC);
+ event->warned = false;
worker_ref(worker);
}
@@ -1426,23 +1426,26 @@ int main(int argc, char *argv[]) {
/* check for hanging events */
udev_list_node_foreach(loop, &worker_list) {
struct worker *worker = node_to_worker(loop);
+ struct event *event = worker->event;
usec_t ts;
if (worker->state != WORKER_RUNNING)
continue;
+ assert(event);
+
ts = now(CLOCK_MONOTONIC);
- if ((ts - worker->event_start_usec) > arg_event_timeout_warn_usec) {
- if ((ts - worker->event_start_usec) > arg_event_timeout_usec) {
- log_error("worker ["PID_FMT"] %s timeout; kill it", worker->pid, worker->event->devpath);
+ 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(worker->event->dev), worker->event->devpath);
- } else if (!worker->event_warned) {
- log_warning("worker ["PID_FMT"] %s is taking a long time", worker->pid, worker->event->devpath);
- worker->event_warned = true;
+ 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);
+ event->warned = true;
}
}
}