Changhui Liu : hidclass.sys: Properly quit hid_device_thread when both completion event and halt event are signaled.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jan 20 10:50:02 CST 2016


Module: wine
Branch: master
Commit: 3f2055b1cf47812dc3453d69d420d3f9481efe74
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3f2055b1cf47812dc3453d69d420d3f9481efe74

Author: Changhui Liu <liuchanghui at linuxdeepin.com>
Date:   Wed Jan 20 14:11:42 2016 +0800

hidclass.sys: Properly quit hid_device_thread when both completion event and halt event are signaled.

Signed-off-by: Changhui Liu <liuchanghui at linuxdeepin.com>
Signed-off-by: Aric Stewart <aric at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/hidclass.sys/device.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c
index 41b5405..886a77a 100644
--- a/dlls/hidclass.sys/device.c
+++ b/dlls/hidclass.sys/device.c
@@ -261,7 +261,7 @@ static DWORD CALLBACK hid_device_thread(void *args)
     NTSTATUS ntrc;
 
     BASE_DEVICE_EXTENSION *ext = device->DeviceExtension;
-    events[0] = CreateEventA(NULL, FALSE, FALSE, NULL);
+    events[0] = CreateEventA(NULL, TRUE, FALSE, NULL);
     events[1] = ext->halt_event;
 
     if (ext->information.Polled)
@@ -336,12 +336,13 @@ static DWORD CALLBACK hid_device_thread(void *args)
 
             if (ntrc == STATUS_PENDING)
             {
-                rc = WaitForMultipleObjects(2, events, FALSE, INFINITE);
-
-                if (rc == WAIT_OBJECT_0 + 1)
-                    exit_now = TRUE;
+                WaitForMultipleObjects(2, events, FALSE, INFINITE);
             }
 
+            rc = WaitForSingleObject(ext->halt_event, 0);
+            if (rc == WAIT_OBJECT_0)
+                exit_now = TRUE;
+
             if (!exit_now && irp->IoStatus.u.Status == STATUS_SUCCESS)
             {
                 packet->reportId = buffer[0];
@@ -368,7 +369,7 @@ static DWORD CALLBACK hid_device_thread(void *args)
 void HID_StartDeviceThread(DEVICE_OBJECT *device)
 {
     BASE_DEVICE_EXTENSION *ext = device->DeviceExtension;
-    ext->halt_event = CreateEventA(NULL, FALSE, FALSE, NULL);
+    ext->halt_event = CreateEventA(NULL, TRUE, FALSE, NULL);
     ext->thread = CreateThread(NULL, 0, hid_device_thread, device, 0, NULL);
 }
 




More information about the wine-cvs mailing list