mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 21:47:23 +00:00
[host] windows: fix graceful exit
We were using an auto-reset event to signal the mousehook exit. This was fine when there was only one thread, but with the addition of the update thread, only one thread is signaled, causing the wait to last forever. The fix is switching to a manual reset event and call ResetEvent after the threads have exited.
This commit is contained in:
parent
669148bca0
commit
80bc9604ba
@ -166,7 +166,7 @@ void mouseHook_install(MouseHookFn callback)
|
|||||||
{
|
{
|
||||||
if (!mouseHook.event)
|
if (!mouseHook.event)
|
||||||
{
|
{
|
||||||
mouseHook.event = CreateEventA(NULL, FALSE, FALSE, NULL);
|
mouseHook.event = CreateEventA(NULL, TRUE, FALSE, NULL);
|
||||||
if (!mouseHook.event)
|
if (!mouseHook.event)
|
||||||
{
|
{
|
||||||
DEBUG_WINERROR("Failed to create mouse hook uninstall event",
|
DEBUG_WINERROR("Failed to create mouse hook uninstall event",
|
||||||
@ -201,6 +201,7 @@ void mouseHook_remove(void)
|
|||||||
SetEvent(mouseHook.event);
|
SetEvent(mouseHook.event);
|
||||||
WaitForSingleObject(mouseHook.thread , INFINITE);
|
WaitForSingleObject(mouseHook.thread , INFINITE);
|
||||||
WaitForSingleObject(mouseHook.updateThread, INFINITE);
|
WaitForSingleObject(mouseHook.updateThread, INFINITE);
|
||||||
|
ResetEvent(mouseHook.event);
|
||||||
CloseHandle(mouseHook.thread);
|
CloseHandle(mouseHook.thread);
|
||||||
CloseHandle(mouseHook.updateThread);
|
CloseHandle(mouseHook.updateThread);
|
||||||
}
|
}
|
||||||
|
@ -698,6 +698,7 @@ VOID WINAPI SvcMain(DWORD dwArgc, LPTSTR *lpszArgv)
|
|||||||
{
|
{
|
||||||
case WAIT_OBJECT_0:
|
case WAIT_OBJECT_0:
|
||||||
service.running = false;
|
service.running = false;
|
||||||
|
doLog("Host application exited gracefully\n");
|
||||||
break;
|
break;
|
||||||
case WAIT_TIMEOUT:
|
case WAIT_TIMEOUT:
|
||||||
doLog("Host application failed to exit in 1 second\n");
|
doLog("Host application failed to exit in 1 second\n");
|
||||||
|
@ -787,6 +787,7 @@ fail_lgmp:
|
|||||||
fail_ivshmem:
|
fail_ivshmem:
|
||||||
ivshmemClose(&shmDev);
|
ivshmemClose(&shmDev);
|
||||||
ivshmemFree(&shmDev);
|
ivshmemFree(&shmDev);
|
||||||
|
DEBUG_INFO("Host application exited");
|
||||||
return exitcode;
|
return exitcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user