mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 13:37:22 +00:00
[host] Windows: improved service restart detection
This commit is contained in:
parent
e08d3afdbc
commit
10d9678b3d
@ -496,23 +496,24 @@ VOID WINAPI SvcMain(DWORD dwArgc, LPTSTR *lpszArgv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
setupLogging();
|
setupLogging();
|
||||||
HANDLE m = CreateMutex(NULL, FALSE, INSTANCE_MUTEX_NAME);
|
|
||||||
|
|
||||||
ReportSvcStatus(SERVICE_RUNNING, NO_ERROR, 0);
|
ReportSvcStatus(SERVICE_RUNNING, NO_ERROR, 0);
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
/* check if the app is running by trying to take the lock */
|
/* check if the app is running by trying to take the lock */
|
||||||
bool running = true;
|
bool running = true;
|
||||||
|
HANDLE m = CreateMutex(NULL, FALSE, INSTANCE_MUTEX_NAME);
|
||||||
if (WaitForSingleObject(m, 0) == WAIT_OBJECT_0)
|
if (WaitForSingleObject(m, 0) == WAIT_OBJECT_0)
|
||||||
{
|
{
|
||||||
running = false;
|
running = false;
|
||||||
ReleaseMutex(m);
|
ReleaseMutex(m);
|
||||||
}
|
}
|
||||||
|
CloseHandle(m);
|
||||||
|
|
||||||
if (!running && GetInteractiveSessionID() != 0)
|
if (!running && GetInteractiveSessionID() != 0)
|
||||||
Launch();
|
Launch();
|
||||||
|
|
||||||
if (WaitForSingleObject(ghSvcStopEvent, 100) == WAIT_OBJECT_0)
|
if (WaitForSingleObject(ghSvcStopEvent, 1000) == WAIT_OBJECT_0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user