summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-04-27 11:33:41 +0200
committerTom Gundersen <teg@jklm.no>2015-05-06 18:35:55 +0200
commit39c19cf13a5d32887977f06cb34e4c95e6da3f56 (patch)
tree74d4c8793588b90b31405b50cd8533feeebf4213 /src
parent3a19b32a673f133f8b953869dd11a2a17344856c (diff)
udevd: worker - introduce worker_attach_event()
Diffstat (limited to 'src')
-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 f8dbe26b8f..fafe3979df 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -179,8 +179,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);
@@ -194,6 +193,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;
@@ -418,11 +426,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;
}
@@ -447,12 +452,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;
}