dll: FspService: console mode testing

This commit is contained in:
Bill Zissimopoulos 2016-05-09 12:35:51 -07:00
parent 0c18b82cc2
commit 89e4e8a96c

View File

@ -290,24 +290,29 @@ FSP_API NTSTATUS FspServiceLoop(FSP_SERVICE *Service)
goto exit; goto exit;
} }
/* set up our console control handler */ /* quick check to see if service already stopped */
if (!SetConsoleCtrlHandler(FspServiceConsoleCtrlHandler, TRUE)) WaitResult = WaitForSingleObject(FspServiceConsoleModeEvent, 0);
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
/* wait until we get signaled by the console control handler */
WaitResult = WaitForSingleObject(FspServiceConsoleModeEvent, INFINITE);
SetConsoleCtrlHandler(FspServiceConsoleCtrlHandler, FALSE);
if (WAIT_OBJECT_0 != WaitResult) if (WAIT_OBJECT_0 != WaitResult)
{ {
Result = FspNtStatusFromWin32(GetLastError()); /* set up our console control handler */
goto exit; if (!SetConsoleCtrlHandler(FspServiceConsoleCtrlHandler, TRUE))
} {
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
if (Service->AcceptControl & SERVICE_ACCEPT_STOP) /* wait until we get signaled by the console control handler */
FspServiceCtrlHandler(SERVICE_CONTROL_STOP, 0, 0, Service); WaitResult = WaitForSingleObject(FspServiceConsoleModeEvent, INFINITE);
SetConsoleCtrlHandler(FspServiceConsoleCtrlHandler, FALSE);
if (WAIT_OBJECT_0 != WaitResult)
{
Result = FspNtStatusFromWin32(GetLastError());
goto exit;
}
if (Service->AcceptControl & SERVICE_ACCEPT_STOP)
FspServiceCtrlHandler(SERVICE_CONTROL_STOP, 0, 0, Service);
}
} }
Result = STATUS_SUCCESS; Result = STATUS_SUCCESS;
@ -466,7 +471,7 @@ static DWORD WINAPI FspServiceConsoleModeThread(PVOID Context)
PWSTR *Argv = Context; PWSTR *Argv = Context;
DWORD Argc; DWORD Argc;
for (Argc = 0; 0 != *Argv; Argc++) for (Argc = 0; 0 != *Argv; Argv++, Argc++)
; ;
Service = FspServiceFromTable(); Service = FspServiceFromTable();