Zebediah Figura : wineusb.sys: Remove devices through the event thread.

Alexandre Julliard julliard at winehq.org
Tue Jul 5 15:55:06 CDT 2022


Module: wine
Branch: master
Commit: 4ed25028052a8e40a065cdf1aacf418083ccadeb
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=4ed25028052a8e40a065cdf1aacf418083ccadeb

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Tue May 24 18:39:08 2022 -0500

wineusb.sys: Remove devices through the event thread.

---

 dlls/wineusb.sys/wineusb.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/dlls/wineusb.sys/wineusb.c b/dlls/wineusb.sys/wineusb.c
index b3d14e91839..b8bcb816e95 100644
--- a/dlls/wineusb.sys/wineusb.c
+++ b/dlls/wineusb.sys/wineusb.c
@@ -113,12 +113,18 @@ static pthread_mutex_t event_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 enum usb_event_type
 {
+    USB_EVENT_REMOVE_DEVICE,
     USB_EVENT_SHUTDOWN,
 };
 
 struct usb_event
 {
     enum usb_event_type type;
+
+    union
+    {
+        struct unix_device *removed_device;
+    } u;
 };
 
 static struct usb_event *usb_events;
@@ -348,13 +354,18 @@ static void remove_unix_device(struct unix_device *unix_device)
 static void remove_usb_device(libusb_device *libusb_device)
 {
     struct unix_device *unix_device;
+    struct usb_event usb_event;
 
     TRACE("Removing device %p.\n", libusb_device);
 
     LIST_FOR_EACH_ENTRY(unix_device, &unix_device_list, struct unix_device, entry)
     {
         if (libusb_get_device(unix_device->handle) == libusb_device)
-            remove_unix_device(unix_device);
+        {
+            usb_event.type = USB_EVENT_REMOVE_DEVICE;
+            usb_event.u.removed_device = unix_device;
+            queue_event(&usb_event);
+        }
     }
 }
 
@@ -403,6 +414,11 @@ static DWORD CALLBACK event_thread_proc(void *arg)
 
         switch (event.type)
         {
+            case USB_EVENT_REMOVE_DEVICE:
+                TRACE("Got remove event for device %p.\n", event.u.removed_device);
+                remove_unix_device(event.u.removed_device);
+                break;
+
             case USB_EVENT_SHUTDOWN:
                 TRACE("Shutting down client event thread.\n");
                 return 0;




More information about the wine-cvs mailing list