From: Yu Watanabe Date: Tue, 13 May 2025 14:50:22 +0000 (+0900) Subject: login: do not call manager_process_seat_device() more than once per event X-Git-Tag: v258-rc1~625^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26a675dd56463cba39b627e053fd71dc32366fde;p=thirdparty%2Fsystemd.git login: do not call manager_process_seat_device() more than once per event 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. --- diff --git a/src/login/logind.c b/src/login/logind.c index 31565f1fce3..0a8663412dd 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -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; }