summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-04-27 11:33:41 +0200
committerAnthony G. Basile <blueness@gentoo.org>2015-05-26 11:28:08 -0400
commit1571f2751556e42fe54d3e0ff6472bff210b1817 (patch)
treef6037d368566991e6a4a346d93c3bf437da7b7ec
parent0c804867b569142ffd07a13c6c350eca35cd81af (diff)
udevd: worker - introduce worker_attach_event()
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
-rw-r--r--src/udev/udevd.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 8be9d136c5..9caf853db8 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -182,8 +182,7 @@ static int worker_new(struct worker **ret, struct udev *udev, struct udev_monito
if (!worker)
return -ENOMEM;
- /* worker + event reference */
- worker->refcount = 2;
+ worker->refcount = 1;
worker->udev = udev_ref(udev);
/* close monitor, but keep address around */
udev_monitor_disconnect(worker_monitor);
@@ -197,6 +196,15 @@ static int worker_new(struct worker **ret, struct udev *udev, struct udev_monito
return 0;
}
+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;
+ worker_ref(worker);
+}
+
static void worker_spawn(struct event *event) {
struct udev *udev = event->udev;
_cleanup_udev_monitor_unref_ struct udev_monitor *worker_monitor = NULL;
@@ -413,11 +421,8 @@ out:
if (r < 0)
return;
- worker->state = WORKER_RUNNING;
- worker->event_start_usec = now(CLOCK_MONOTONIC);
- worker->event_warned = false;
- worker->event = event;
- event->state = EVENT_RUNNING;
+ worker_attach_event(worker, event);
+
log_debug("seq %llu forked new worker ["PID_FMT"]", udev_device_get_seqnum(event->dev), pid);
break;
}
@@ -442,12 +447,7 @@ static void event_run(struct event *event) {
worker->state = WORKER_KILLED;
continue;
}
- worker_ref(worker);
- worker->event = event;
- worker->state = WORKER_RUNNING;
- worker->event_start_usec = now(CLOCK_MONOTONIC);
- worker->event_warned = false;
- event->state = EVENT_RUNNING;
+ worker_attach_event(worker, event);
return;
}