]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
login: do not call manager_process_seat_device() more than once per event
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 13 May 2025 14:50:22 +0000 (23:50 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 13 May 2025 17:06:02 +0000 (02:06 +0900)
When udevd broadcasts an event for e.g. a graphics device with master-of-seat
tag, then previously manager_process_seat_device() was called twice for
the event.

With this commit, the function is called only once even for an event for
such device.

src/login/logind.c

index 31565f1fce3ed66c62288372a07be904e84d30e4..0a8663412dda42100e46b43d6eefdd26a7b24782 100644 (file)
@@ -610,19 +610,35 @@ static int manager_enumerate_inhibitors(Manager *m) {
 
 static int manager_dispatch_seat_udev(sd_device_monitor *monitor, sd_device *device, void *userdata) {
         Manager *m = ASSERT_PTR(userdata);
+        int r;
 
         assert(device);
 
-        manager_process_seat_device(m, device);
+        r = manager_process_seat_device(m, device);
+        if (r < 0)
+                log_device_warning_errno(device, r, "Failed to process seat device, ignoring: %m");
+
         return 0;
 }
 
 static int manager_dispatch_device_udev(sd_device_monitor *monitor, sd_device *device, void *userdata) {
         Manager *m = ASSERT_PTR(userdata);
+        int r;
 
         assert(device);
 
-        manager_process_seat_device(m, device);
+        /* If the device currently has "master-of-seat" tag, then it has been or will be processed by
+         * manager_dispatch_seat_udev(). */
+        r = sd_device_has_current_tag(device, "master-of-seat");
+        if (r < 0)
+                log_device_warning_errno(device, r, "Failed to check if the device currently has master-of-seat tag, ignoring: %m");
+        if (r != 0)
+                return 0;
+
+        r = manager_process_seat_device(m, device);
+        if (r < 0)
+                log_device_warning_errno(device, r, "Failed to process seat device, ignoring: %m");
+
         return 0;
 }