diff options
Diffstat (limited to 'src/udev/udevd.c')
-rw-r--r-- | src/udev/udevd.c | 26 |
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; } |