Lines Matching refs:event

90         sd_event *event;  member
140 LIST_FIELDS(Event, event);
157 Event *event; member
174 static Event *event_free(Event *event) { in event_free() argument
175 if (!event) in event_free()
178 assert(event->manager); in event_free()
180 LIST_REMOVE(event, event->manager->events, event); in event_free()
181 sd_device_unref(event->dev); in event_free()
185 sd_event_source_unref(event->timeout_warning_event); in event_free()
186 sd_event_source_unref(event->timeout_event); in event_free()
188 if (event->worker) in event_free()
189 event->worker->event = NULL; in event_free()
191 return mfree(event); in event_free()
195 LIST_FOREACH(event, event, manager->events) { in event_queue_cleanup()
196 if (match_state != EVENT_UNDEF && match_state != event->state) in event_queue_cleanup()
199 event_free(event); in event_queue_cleanup()
212 event_free(worker->event); in worker_free()
228 manager->event = sd_event_unref(manager->event); in manager_clear_for_worker()
284 …r = sd_event_add_child(manager->event, &worker->child_event_source, pid, WEXITED, on_sigchld, work… in worker_new()
683 r = sd_event_new(&manager->event); in worker_main()
687 r = sd_event_add_signal(manager->event, NULL, SIGTERM, NULL, NULL); in worker_main()
691 r = sd_device_monitor_attach_event(monitor, manager->event); in worker_main()
704 r = sd_event_loop(manager->event); in worker_main()
712 Event *event = userdata; in on_event_timeout() local
714 assert(event); in on_event_timeout()
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 …log_device_error(event->dev, "Worker ["PID_FMT"] processing SEQNUM=%"PRIu64" killed", event->worke… in on_event_timeout()
726 Event *event = userdata; in on_event_timeout_warning() local
728 assert(event); in on_event_timeout_warning()
729 assert(event->worker); in on_event_timeout_warning()
731 …log_device_warning(event->dev, "Worker ["PID_FMT"] processing SEQNUM=%"PRIu64" is taking a long ti… in on_event_timeout_warning()
736 static void worker_attach_event(Worker *worker, Event *event) { in worker_attach_event() argument
741 assert(event); in worker_attach_event()
742 assert(!event->worker); in worker_attach_event()
743 assert(!worker->event); in worker_attach_event()
746 worker->event = event; in worker_attach_event()
747 event->state = EVENT_RUNNING; in worker_attach_event()
748 event->worker = worker; in worker_attach_event()
750 e = worker->manager->event; in worker_attach_event()
752 (void) sd_event_add_time_relative(e, &event->timeout_warning_event, CLOCK_MONOTONIC, in worker_attach_event()
754 on_event_timeout_warning, event); in worker_attach_event()
756 (void) sd_event_add_time_relative(e, &event->timeout_event, CLOCK_MONOTONIC, in worker_attach_event()
758 on_event_timeout, event); in worker_attach_event()
761 static int worker_spawn(Manager *manager, Event *event) { in worker_spawn() argument
783 event->state = EVENT_QUEUED; in worker_spawn()
787 DEVICE_TRACE_POINT(worker_spawned, event->dev, getpid()); in worker_spawn()
790 r = worker_main(manager, worker_monitor, sd_device_ref(event->dev)); in worker_spawn()
799 worker_attach_event(worker, event); in worker_spawn()
801 …log_device_debug(event->dev, "Worker ["PID_FMT"] is forked for processing SEQNUM=%"PRIu64".", pid,… in worker_spawn()
805 static int event_run(Event *event) { in event_run() argument
811 assert(event); in event_run()
812 assert(event->manager); in event_run()
814 log_device_uevent(event->dev, "Device ready for processing"); in event_run()
816 manager = event->manager; in event_run()
821 r = device_monitor_send_device(manager->monitor, worker->monitor, event->dev); in event_run()
823 …log_device_error_errno(event->dev, r, "Worker ["PID_FMT"] did not accept message, killing the work… in event_run()
829 worker_attach_event(worker, event); in event_run()
847 r = worker_spawn(manager, event); in event_run()
854 static int event_is_blocked(Event *event) { in event_is_blocked() argument
864 assert(event); in event_is_blocked()
865 assert(event->manager); in event_is_blocked()
866 assert(event->blocker_seqnum <= event->seqnum); in event_is_blocked()
868 if (event->retry_again_next_usec > 0) { in event_is_blocked()
871 r = sd_event_now(event->manager->event, CLOCK_BOOTTIME, &now_usec); in event_is_blocked()
875 if (event->retry_again_next_usec <= now_usec) in event_is_blocked()
879 if (event->blocker_seqnum == event->seqnum) in event_is_blocked()
883 LIST_FOREACH(event, e, event->manager->events) { in event_is_blocked()
887 if (loop_event->seqnum < event->blocker_seqnum) in event_is_blocked()
891 if (loop_event->seqnum == event->blocker_seqnum) in event_is_blocked()
895 if (loop_event->seqnum >= event->seqnum) in event_is_blocked()
903 assert(loop_event->seqnum > event->blocker_seqnum && in event_is_blocked()
904 loop_event->seqnum < event->seqnum); in event_is_blocked()
906 r = sd_device_get_subsystem(event->dev, &subsystem); in event_is_blocked()
912 r = sd_device_get_devpath(event->dev, &devpath); in event_is_blocked()
918 r = sd_device_get_property_value(event->dev, "DEVPATH_OLD", &devpath_old); in event_is_blocked()
922 r = sd_device_get_devnum(event->dev, &devnum); in event_is_blocked()
926 r = sd_device_get_ifindex(event->dev, &ifindex); in event_is_blocked()
931 LIST_FOREACH(event, e, loop_event) { in event_is_blocked()
938 if (loop_event->seqnum >= event->seqnum) in event_is_blocked()
994 log_device_debug(event->dev, "SEQNUM=%" PRIu64 " blocked by SEQNUM=%" PRIu64, in event_is_blocked()
995 event->seqnum, loop_event->seqnum); in event_is_blocked()
997 event->blocker_seqnum = loop_event->seqnum; in event_is_blocked()
1001 event->blocker_seqnum = event->seqnum; in event_is_blocked()
1015 assert_se(sd_event_now(manager->event, CLOCK_MONOTONIC, &usec) >= 0); in event_queue_start()
1042 LIST_FOREACH(event, event, manager->events) { in event_queue_start()
1043 if (event->state != EVENT_QUEUED) in event_queue_start()
1047 r = event_is_blocked(event); in event_queue_start()
1051 log_device_warning_errno(event->dev, r, in event_queue_start()
1054 event->seqnum, in event_queue_start()
1055 strna(device_action_to_string(event->action))); in event_queue_start()
1057 r = event_run(event); in event_queue_start()
1065 static int event_requeue(Event *event) { in event_requeue() argument
1069 assert(event); in event_requeue()
1070 assert(event->manager); in event_requeue()
1071 assert(event->manager->event); in event_requeue()
1073 event->timeout_warning_event = sd_event_source_disable_unref(event->timeout_warning_event); in event_requeue()
1074 event->timeout_event = sd_event_source_disable_unref(event->timeout_event); in event_requeue()
1077 r = sd_event_now(event->manager->event, CLOCK_BOOTTIME, &now_usec); in event_requeue()
1079 return log_device_warning_errno(event->dev, r, in event_requeue()
1082event->seqnum, strna(device_action_to_string(event->action))); in event_requeue()
1084 if (event->retry_again_timeout_usec > 0 && event->retry_again_timeout_usec <= now_usec) in event_requeue()
1085 return log_device_warning_errno(event->dev, SYNTHETIC_ERRNO(ETIMEDOUT), in event_requeue()
1089event->seqnum, strna(device_action_to_string(event->action))); in event_requeue()
1091 event->retry_again_next_usec = usec_add(now_usec, EVENT_RETRY_INTERVAL_USEC); in event_requeue()
1092 if (event->retry_again_timeout_usec == 0) in event_requeue()
1093 event->retry_again_timeout_usec = usec_add(now_usec, EVENT_RETRY_TIMEOUT_USEC); in event_requeue()
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()
1099 event->state = EVENT_QUEUED; in event_requeue()
1115 LIST_FOREACH(event, event, manager->events) { in event_queue_assume_block_device_unlocked()
1118 if (event->state != EVENT_QUEUED) in event_queue_assume_block_device_unlocked()
1121 if (event->retry_again_next_usec == 0) in event_queue_assume_block_device_unlocked()
1124 if (device_get_whole_disk(event->dev, NULL, &event_devname) <= 0) in event_queue_assume_block_device_unlocked()
1130 event->retry_again_next_usec = 0; in event_queue_assume_block_device_unlocked()
1139 Event *event; in event_queue_insert() local
1157 event = new(Event, 1); in event_queue_insert()
1158 if (!event) in event_queue_insert()
1161 *event = (Event) { in event_queue_insert()
1175 LIST_APPEND(event, manager->events, event); in event_queue_insert()
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()
1558 sd_device *dev = worker->event ? ASSERT_PTR(worker->event->dev) : NULL; in on_sigchld()
1634 … (void) event_reset_time(manager->event, &manager->kill_workers_event, CLOCK_MONOTONIC, in on_post()
1643 return sd_event_exit(manager->event, 0); in on_post()
2001 r = sd_event_default(&manager->event); in main_loop()
2005 r = sd_event_add_signal(manager->event, NULL, SIGINT, on_sigterm, manager); in main_loop()
2009 r = sd_event_add_signal(manager->event, NULL, SIGTERM, on_sigterm, manager); in main_loop()
2013 r = sd_event_add_signal(manager->event, NULL, SIGHUP, on_sighup, manager); in main_loop()
2017 r = sd_event_set_watchdog(manager->event, true); in main_loop()
2021 r = udev_ctrl_attach_event(manager->ctrl, manager->event); in main_loop()
2037 …r = sd_event_add_io(manager->event, &manager->inotify_event, manager->inotify_fd, EPOLLIN, on_inot… in main_loop()
2041 r = sd_device_monitor_attach_event(manager->monitor, manager->event); in main_loop()
2051 r = sd_event_add_io(manager->event, NULL, fd_worker, EPOLLIN, on_worker, manager); in main_loop()
2055 r = sd_event_add_post(manager->event, NULL, on_post, manager); in main_loop()
2071 r = sd_event_loop(manager->event); in main_loop()