From: Fabian Maurer dark.shadow4@web.de
Since we stop the thread in DllMain, we always haev the loaderlock. Thread shutdown also requires the loader lock, so we will always time out So just wait until all cleanup is done, the thread itself can exit later
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52314 Signed-off-by: Fabian Maurer dark.shadow4@web.de --- dlls/dinput/dinput_main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index d3db22c70b5..dc0de9c44f9 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -1227,7 +1227,7 @@ static DWORD WINAPI dinput_thread_proc( void *params ) static HHOOK kbd_hook, mouse_hook; struct dinput_device *impl, *next; SIZE_T events_count = 0; - HANDLE finished_event; + HANDLE finished_event = NULL; DWORD ret; MSG msg;
@@ -1320,6 +1320,7 @@ static DWORD WINAPI dinput_thread_proc( void *params ) done: DestroyWindow( di_em_win ); di_em_win = NULL; + SetEvent(finished_event); return 0; }
@@ -1347,9 +1348,13 @@ static void dinput_thread_start(void)
static void dinput_thread_stop(void) { - PostThreadMessageW( dinput_thread_id, WM_USER + 0x10, 0, 0 ); - if (WaitForSingleObject( dinput_thread, 500 ) == WAIT_TIMEOUT) - WARN("Timeout while waiting for internal thread\n"); + HANDLE finished_event = CreateEventW( NULL, FALSE, FALSE, NULL ); + + PostThreadMessageW( dinput_thread_id, WM_USER + 0x10, 0, (LPARAM)finished_event ); + + WaitForSingleObject( finished_event, INFINITE ); + + CloseHandle( finished_event ); CloseHandle( dinput_thread ); }