From: Yu Watanabe Date: Sat, 5 Apr 2025 17:06:12 +0000 (+0900) Subject: udev: drop unnecessary discardment of queued events X-Git-Tag: v258-rc1~871^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F37022%2Fhead;p=thirdparty%2Fsystemd.git udev: drop unnecessary discardment of queued events With the previous commit, now on_post_exit() checks only events currently being processed. Hence, it is not necessary to discard queued events in manager_exit(). Also, as already SIGTERM is sent to all workers, kill workers timer is not necessary anymore after manager_exit(), hence disable it. This mostly does not change any behavior. Just refactoring and preparation for later change. --- diff --git a/src/udev/udev-manager.c b/src/udev/udev-manager.c index 375bcd55e8d..883b27a2328 100644 --- a/src/udev/udev-manager.c +++ b/src/udev/udev-manager.c @@ -107,15 +107,6 @@ static Event* event_free(Event *event) { return mfree(event); } -static void event_queue_cleanup(Manager *manager, EventState match_state) { - LIST_FOREACH(event, event, manager->events) { - if (match_state != EVENT_UNDEF && match_state != event->state) - continue; - - event_free(event); - } -} - static Worker* worker_free(Worker *worker) { if (!worker) return NULL; @@ -149,7 +140,8 @@ Manager* manager_free(Manager *manager) { udev_rules_free(manager->rules); hashmap_free(manager->workers); - event_queue_cleanup(manager, EVENT_UNDEF); + while (manager->events) + event_free(manager->events); safe_close(manager->inotify_fd); @@ -274,9 +266,9 @@ void manager_exit(Manager *manager) { (void) sd_event_source_set_enabled(sd_device_monitor_get_event_source(manager->monitor), SD_EVENT_OFF); (void) sd_device_monitor_detach_event(manager->monitor); - /* discard queued events and kill workers */ - event_queue_cleanup(manager, EVENT_QUEUED); + /* Kill all workers with SIGTERM, and disable unnecessary timer event source. */ manager_kill_workers(manager, SIGTERM); + manager->kill_workers_event = sd_event_source_disable_unref(manager->kill_workers_event); } void notify_ready(Manager *manager) {