From 9f09e2a3cbadf89aec91100cb4e0a88041f17e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Mon, 30 Aug 2021 11:22:53 +0200 Subject: [PATCH] winebus.sys: Return an event from UDEV bus wait on device removal. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of calling bus_unlink_hid_device or IoInvalidateDeviceRelations. Signed-off-by: RĂ©mi Bernon Signed-off-by: Alexandre Julliard --- dlls/winebus.sys/bus_udev.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 8d631fb928e..c954e6b2128 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -92,6 +92,7 @@ static struct udev *udev_context = NULL; static struct udev_monitor *udev_monitor; static int deviceloop_control[2]; static int udev_monitor_fd; +static struct list event_queue = LIST_INIT(event_queue); static const WCHAR hidraw_busidW[] = {'H','I','D','R','A','W',0}; static const WCHAR lnxev_busidW[] = {'L','N','X','E','V',0}; @@ -1171,16 +1172,10 @@ static void try_add_device(struct udev_device *dev) static void try_remove_device(struct udev_device *dev) { - DEVICE_OBJECT *device = NULL; - - device = bus_find_hid_device(hidraw_busidW, dev); + bus_event_queue_device_removed(&event_queue, hidraw_busidW, dev); #ifdef HAS_PROPER_INPUT_HEADER - if (device == NULL) device = bus_find_hid_device(lnxev_busidW, dev); + bus_event_queue_device_removed(&event_queue, lnxev_busidW, dev); #endif - if (!device) return; - - bus_unlink_hid_device(device); - IoInvalidateDeviceRelations(bus_pdo, BusRelations); } static void build_initial_deviceset(void) @@ -1337,6 +1332,7 @@ error: NTSTATUS udev_bus_wait(void *args) { + struct bus_event *result = args; struct pollfd pfd[2]; pfd[0].fd = udev_monitor_fd; @@ -1348,12 +1344,14 @@ NTSTATUS udev_bus_wait(void *args) while (1) { + if (bus_event_queue_pop(&event_queue, result)) return STATUS_PENDING; if (poll(pfd, 2, -1) <= 0) continue; if (pfd[1].revents) break; process_monitor_event(udev_monitor); } TRACE("UDEV main loop exiting\n"); + bus_event_queue_destroy(&event_queue); udev_monitor_unref(udev_monitor); udev_unref(udev_context); udev_context = NULL;