winebus.sys: Return an event from UDEV bus wait on device removal.

Instead of calling bus_unlink_hid_device or IoInvalidateDeviceRelations.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-08-30 11:22:53 +02:00 committed by Alexandre Julliard
parent 6006758ca8
commit 9f09e2a3cb

View file

@ -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;