launcher:

- STOP_TIMEOUT vs KILL_TIMEOUT
    - JobControl registry value
This commit is contained in:
Bill Zissimopoulos 2016-05-14 19:27:59 -07:00
parent 3035ba2847
commit 08a02d7b35
2 changed files with 17 additions and 5 deletions

View File

@ -241,6 +241,7 @@ NTSTATUS SvcInstanceCreate(HANDLE ClientToken,
DWORD ClassNameSize, InstanceNameSize; DWORD ClassNameSize, InstanceNameSize;
WCHAR Executable[MAX_PATH], CommandLineBuf[512] = L"%0 ", SecurityBuf[512] = L"O:SYG:SY"; WCHAR Executable[MAX_PATH], CommandLineBuf[512] = L"%0 ", SecurityBuf[512] = L"O:SYG:SY";
PWSTR CommandLine, Security; PWSTR CommandLine, Security;
DWORD JobControl;
PSECURITY_DESCRIPTOR SecurityDescriptor; PSECURITY_DESCRIPTOR SecurityDescriptor;
PWSTR Argv[10]; PWSTR Argv[10];
STARTUPINFOW StartupInfo; STARTUPINFOW StartupInfo;
@ -308,6 +309,16 @@ NTSTATUS SvcInstanceCreate(HANDLE ClientToken,
goto exit; goto exit;
} }
RegSize = sizeof JobControl;
JobControl = 1; /* default is YES! */
RegResult = RegGetValueW(RegKey, ClassName, L"JobControl", RRF_RT_REG_DWORD, 0,
&JobControl, &RegSize);
if (ERROR_SUCCESS != RegResult && ERROR_FILE_NOT_FOUND != RegResult)
{
Result = FspNtStatusFromWin32(RegResult);
goto exit;
}
RegCloseKey(RegKey); RegCloseKey(RegKey);
RegKey = 0; RegKey = 0;
@ -352,7 +363,7 @@ NTSTATUS SvcInstanceCreate(HANDLE ClientToken,
StartupInfo.cb = sizeof StartupInfo; StartupInfo.cb = sizeof StartupInfo;
if (!CreateProcessW(Executable, SvcInstance->CommandLine, 0, 0, FALSE, if (!CreateProcessW(Executable, SvcInstance->CommandLine, 0, 0, FALSE,
CREATE_NEW_PROCESS_GROUP | CREATE_SUSPENDED, 0, 0, &StartupInfo, &ProcessInfo)) CREATE_SUSPENDED | CREATE_NEW_PROCESS_GROUP, 0, 0, &StartupInfo, &ProcessInfo))
{ {
Result = FspNtStatusFromWin32(GetLastError()); Result = FspNtStatusFromWin32(GetLastError());
goto exit; goto exit;
@ -368,7 +379,7 @@ NTSTATUS SvcInstanceCreate(HANDLE ClientToken,
goto exit; goto exit;
} }
if (0 != Job) if (0 != Job && JobControl)
{ {
if (!AssignProcessToJobObject(Job, SvcInstance->Process)) if (!AssignProcessToJobObject(Job, SvcInstance->Process))
FspServiceLog(EVENTLOG_WARNING_TYPE, FspServiceLog(EVENTLOG_WARNING_TYPE,
@ -474,7 +485,7 @@ NTSTATUS SvcInstanceStop(HANDLE ClientToken,
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
goto exit; goto exit;
KillProcess(SvcInstance->ProcessId, SvcInstance->Process, STOP_TIMEOUT); KillProcess(SvcInstance->ProcessId, SvcInstance->Process, KILL_TIMEOUT);
Result = STATUS_SUCCESS; Result = STATUS_SUCCESS;
@ -575,7 +586,7 @@ NTSTATUS SvcInstanceStopAndWaitAll(VOID)
{ {
SvcInstance = CONTAINING_RECORD(ListEntry, SVC_INSTANCE, ListEntry); SvcInstance = CONTAINING_RECORD(ListEntry, SVC_INSTANCE, ListEntry);
KillProcess(SvcInstance->ProcessId, SvcInstance->Process, STOP_TIMEOUT); KillProcess(SvcInstance->ProcessId, SvcInstance->Process, KILL_TIMEOUT);
} }
LeaveCriticalSection(&SvcInstanceLock); LeaveCriticalSection(&SvcInstanceLock);

View File

@ -21,7 +21,8 @@
#include <winfsp/winfsp.h> #include <winfsp/winfsp.h>
#include <shared/minimal.h> #include <shared/minimal.h>
#define STOP_TIMEOUT 5000 #define STOP_TIMEOUT 5500
#define KILL_TIMEOUT 5000
#define PIPE_NAME "\\\\.\\pipe\\WinFsp.{14E7137D-22B4-437A-B0C1-D21D1BDF3767}" #define PIPE_NAME "\\\\.\\pipe\\WinFsp.{14E7137D-22B4-437A-B0C1-D21D1BDF3767}"
#define PIPE_BUFFER_SIZE 2048 #define PIPE_BUFFER_SIZE 2048