Subject: hidclass.sys: Properly quit hid_device_thread when both completion event and halt event are signaled (try 4)
Changhui LIU
chliu027028 at gmail.com
Wed Jan 20 00:19:10 CST 2016
Superseded patch 117854.
--
Regards,
Changhui Liu
-------------- next part --------------
From 50fc9f862bd563c84a10d544953b319756cc29a7 Mon Sep 17 00:00:00 2001
From: Changhui Liu <liuchanghui at linuxdeepin.com>
Date: Wed, 20 Jan 2016 14:11:42 +0800
Subject: hidclass.sys: Properly quit hid_device_thread when both completion
event and halt event are signaled.
To: wine-patches <wine-patches at winehq.org>
Reply-To: wine-devel <wine-devel at winehq.org>
WaitForMultipleObjects always returns first signaled event index when multiple events are signaled.
Signed-off-by: Changhui Liu <liuchanghui at linuxdeepin.com>
---
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);
}
--
1.9.1
More information about the wine-patches
mailing list