Lines Matching refs:worker
126 Worker *worker; member
188 if (event->worker) in event_free()
189 event->worker->event = NULL; in event_free()
203 static Worker *worker_free(Worker *worker) { in worker_free() argument
204 if (!worker) in worker_free()
207 if (worker->manager) in worker_free()
208 hashmap_remove(worker->manager->workers, PID_TO_PTR(worker->pid)); in worker_free()
210 sd_event_source_unref(worker->child_event_source); in worker_free()
211 sd_device_monitor_unref(worker->monitor); in worker_free()
212 event_free(worker->event); in worker_free()
214 return mfree(worker); in worker_free()
264 _cleanup_(worker_freep) Worker *worker = NULL; in worker_new()
275 worker = new(Worker, 1); in worker_new()
276 if (!worker) in worker_new()
279 *worker = (Worker) { in worker_new()
284 …r = sd_event_add_child(manager->event, &worker->child_event_source, pid, WEXITED, on_sigchld, work… in worker_new()
288 r = hashmap_ensure_put(&manager->workers, &worker_hash_op, PID_TO_PTR(pid), worker); in worker_new()
292 worker->manager = manager; in worker_new()
294 *ret = TAKE_PTR(worker); in worker_new()
299 Worker *worker; in manager_kill_workers() local
303 HASHMAP_FOREACH(worker, manager->workers) { in manager_kill_workers()
304 if (worker->state == WORKER_KILLED) in manager_kill_workers()
307 if (worker->state == WORKER_RUNNING && !force) { in manager_kill_workers()
308 worker->state = WORKER_KILLING; in manager_kill_workers()
312 worker->state = WORKER_KILLED; in manager_kill_workers()
313 (void) kill(worker->pid, SIGTERM); in manager_kill_workers()
715 assert(event->worker); in on_event_timeout()
717 kill_and_sigcont(event->worker->pid, arg_timeout_signal); in on_event_timeout()
718 event->worker->state = WORKER_KILLED; in on_event_timeout()
720 …nt->dev, "Worker ["PID_FMT"] processing SEQNUM=%"PRIu64" killed", event->worker->pid, event->seqnu… in on_event_timeout()
729 assert(event->worker); in on_event_timeout_warning()
731 …r ["PID_FMT"] processing SEQNUM=%"PRIu64" is taking a long time", event->worker->pid, event->seqnu… in on_event_timeout_warning()
736 static void worker_attach_event(Worker *worker, Event *event) { in worker_attach_event() argument
739 assert(worker); in worker_attach_event()
740 assert(worker->manager); in worker_attach_event()
742 assert(!event->worker); in worker_attach_event()
743 assert(!worker->event); in worker_attach_event()
745 worker->state = WORKER_RUNNING; in worker_attach_event()
746 worker->event = event; in worker_attach_event()
748 event->worker = worker; in worker_attach_event()
750 e = worker->manager->event; in worker_attach_event()
763 Worker *worker; in worker_spawn() local
795 r = worker_new(&worker, manager, worker_monitor, pid); in worker_spawn()
799 worker_attach_event(worker, event); in worker_spawn()
808 Worker *worker; in event_run() local
817 HASHMAP_FOREACH(worker, manager->workers) { in event_run()
818 if (worker->state != WORKER_IDLE) in event_run()
821 r = device_monitor_send_device(manager->monitor, worker->monitor, event->dev); in event_run()
824 worker->pid); in event_run()
825 (void) kill(worker->pid, SIGKILL); in event_run()
826 worker->state = WORKER_KILLED; in event_run()
829 worker_attach_event(worker, event); in event_run()
1095 if (event->worker && event->worker->event == event) in event_requeue()
1096 event->worker->event = NULL; in event_requeue()
1097 event->worker = NULL; in event_requeue()
1223 Worker *worker; in on_worker() local
1248 worker = hashmap_get(manager->workers, PID_TO_PTR(ucred->pid)); in on_worker()
1249 if (!worker) { in on_worker()
1254 if (worker->state == WORKER_KILLING) { in on_worker()
1255 worker->state = WORKER_KILLED; in on_worker()
1256 (void) kill(worker->pid, SIGTERM); in on_worker()
1257 } else if (worker->state != WORKER_KILLED) in on_worker()
1258 worker->state = WORKER_IDLE; in on_worker()
1262 event_requeue(worker->event) < 0) in on_worker()
1263 device_broadcast(manager->monitor, worker->event->dev, -ETIMEDOUT); in on_worker()
1266 event_free(worker->event); in on_worker()
1556 Worker *worker = ASSERT_PTR(userdata); in on_sigchld() local
1557 Manager *manager = ASSERT_PTR(worker->manager); in on_sigchld()
1558 sd_device *dev = worker->event ? ASSERT_PTR(worker->event->dev) : NULL; in on_sigchld()
1594 worker_free(worker); in on_sigchld()