]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: drop unnecessary discardment of queued events 37022/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 5 Apr 2025 17:06:12 +0000 (02:06 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 7 Apr 2025 13:17:16 +0000 (22:17 +0900)
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.

src/udev/udev-manager.c

index 375bcd55e8d245357eed3466fda54600dc6ff765..883b27a23283284dcf411383e2e361f0468b4740 100644 (file)
@@ -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) {