Rémi Bernon : dinput: Hold the HID joystick CS when updating the device state.

Alexandre Julliard julliard at winehq.org
Fri Oct 8 14:12:27 CDT 2021


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

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Fri Oct  8 15:36:00 2021 +0200

dinput: Hold the HID joystick CS when updating the device state.

The read buffer is only used by the reading thread but the device state
is not, we should only update it while holding the CS.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dinput/joystick_hid.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index 4449c11256c..6f9e9987e6e 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -1603,6 +1603,7 @@ static HRESULT hid_joystick_read_state( IDirectInputDevice8W *iface )
         }
     }
 
+    EnterCriticalSection( &impl->base.crit );
     do
     {
         count = impl->usages_count;
@@ -1638,6 +1639,7 @@ static HRESULT hid_joystick_read_state( IDirectInputDevice8W *iface )
         memset( &impl->read_ovl, 0, sizeof(impl->read_ovl) );
         impl->read_ovl.hEvent = impl->base.read_event;
     } while (ReadFile( impl->device, report_buf, report_len, &count, &impl->read_ovl ));
+    LeaveCriticalSection( &impl->base.crit );
 
     return DI_OK;
 }




More information about the wine-cvs mailing list