fixing the AV for graceful shutdown on Win7, set forwardWindowsAuthToken default to true and other minor issues
This commit is contained in:
parent
839437ef8c
commit
87f808cc9d
|
|
@ -141,7 +141,7 @@ private:
|
||||||
<li> Enable logging the application process' stdout messages </li> \
|
<li> Enable logging the application process' stdout messages </li> \
|
||||||
<li> Attach a debugger to the application process and inspect </li></ul></fieldset> \
|
<li> Attach a debugger to the application process and inspect </li></ul></fieldset> \
|
||||||
<fieldset><h4> For more information visit: \
|
<fieldset><h4> For more information visit: \
|
||||||
<a href=\"http://go.microsoft.com/fwlink/?linkid=808681\" <cite> http://go.microsoft.com/fwlink/?LinkID=808681 </cite></a></h4> \
|
<a href=\"https://go.microsoft.com/fwlink/?linkid=808681\" <cite> https://go.microsoft.com/fwlink/?LinkID=808681 </cite></a></h4> \
|
||||||
</fieldset> \
|
</fieldset> \
|
||||||
</div> \
|
</div> \
|
||||||
</div></body></html>")
|
</div></body></html>")
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,6 @@ private:
|
||||||
DWORD m_dwProcessId;
|
DWORD m_dwProcessId;
|
||||||
DWORD m_dwListeningProcessId;
|
DWORD m_dwListeningProcessId;
|
||||||
STRA m_straGuid;
|
STRA m_straGuid;
|
||||||
HANDLE m_CancelEvent;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// m_hProcessHandle is the handle to process this object creates.
|
// m_hProcessHandle is the handle to process this object creates.
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,6 @@ PROCESS_MANAGER::GetProcess(
|
||||||
goto Finished;
|
goto Finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->ReferenceProcessManager();
|
|
||||||
hr = m_ppServerProcessList[dwProcessIndex]->Initialize(
|
hr = m_ppServerProcessList[dwProcessIndex]->Initialize(
|
||||||
this,
|
this,
|
||||||
pConfig->QueryProcessPath(),
|
pConfig->QueryProcessPath(),
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ SERVER_PROCESS::Initialize(
|
||||||
m_dwShutdownTimeLimitInMS = dwShtudownTimeLimitInMS;
|
m_dwShutdownTimeLimitInMS = dwShtudownTimeLimitInMS;
|
||||||
m_fStdoutLogEnabled = fStdoutLogEnabled;
|
m_fStdoutLogEnabled = fStdoutLogEnabled;
|
||||||
|
|
||||||
|
m_pProcessManager->ReferenceProcessManager();
|
||||||
|
|
||||||
hr = m_ProcessPath.Copy(*pszProcessExePath);
|
hr = m_ProcessPath.Copy(*pszProcessExePath);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
|
|
@ -1208,7 +1210,7 @@ Finished:
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send ctrl-c signnal to the process to let it graceful shutdown
|
// send ctrl-c signnal to the process to let it gracefully shutdown
|
||||||
// if the process cannot shutdown within given time, terminate it
|
// if the process cannot shutdown within given time, terminate it
|
||||||
// todo: allow user to config this shutdown timeout
|
// todo: allow user to config this shutdown timeout
|
||||||
|
|
||||||
|
|
@ -1217,7 +1219,7 @@ SERVER_PROCESS::SendSignal(
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
HANDLE hProc;
|
HANDLE hProc = INVALID_HANDLE_VALUE;
|
||||||
BOOL fIsSuccess = FALSE;
|
BOOL fIsSuccess = FALSE;
|
||||||
LPCWSTR apsz[1];
|
LPCWSTR apsz[1];
|
||||||
STACK_STRU(strEventMsg, 256);
|
STACK_STRU(strEventMsg, 256);
|
||||||
|
|
@ -1233,46 +1235,53 @@ SERVER_PROCESS::SendSignal(
|
||||||
{
|
{
|
||||||
fIsSuccess = GenerateConsoleCtrlEvent(CTRL_C_EVENT, m_dwProcessId);
|
fIsSuccess = GenerateConsoleCtrlEvent(CTRL_C_EVENT, m_dwProcessId);
|
||||||
FreeConsole();
|
FreeConsole();
|
||||||
CloseHandle(m_hProcessHandle);
|
|
||||||
m_hProcessHandle = INVALID_HANDLE_VALUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fIsSuccess)
|
|
||||||
{
|
|
||||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
|
||||||
ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE_MSG,
|
|
||||||
m_dwProcessId )))
|
|
||||||
{
|
|
||||||
apsz[0] = strEventMsg.QueryStr();
|
|
||||||
// log a warning for ungraceful shutdown
|
|
||||||
if (FORWARDING_HANDLER::QueryEventLog() != NULL)
|
|
||||||
{
|
|
||||||
ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
|
|
||||||
EVENTLOG_INFORMATION_TYPE,
|
|
||||||
0,
|
|
||||||
ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE,
|
|
||||||
NULL,
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
apsz,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fIsSuccess || (WaitForSingleObject(hProc, m_dwShutdownTimeLimitInMS) != WAIT_OBJECT_0))
|
|
||||||
{
|
|
||||||
// cannot gracefule shutdown or timeout
|
|
||||||
// terminate the process
|
|
||||||
TerminateProcess(m_hProcessHandle, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!fIsSuccess || (WaitForSingleObject(hProc, m_dwShutdownTimeLimitInMS) != WAIT_OBJECT_0))
|
||||||
|
{
|
||||||
|
//Backend process will be terminated, remove the waitcallback
|
||||||
|
if (m_hProcessWaitHandle != NULL)
|
||||||
|
{
|
||||||
|
UnregisterWait(m_hProcessWaitHandle);
|
||||||
|
m_hProcessWaitHandle = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cannot gracefully shutdown or timeout, terminate the process
|
||||||
|
TerminateProcess(m_hProcessHandle, 0);
|
||||||
|
|
||||||
|
// log a warning for ungraceful shutdown
|
||||||
|
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||||
|
ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE_MSG,
|
||||||
|
m_dwProcessId)))
|
||||||
|
{
|
||||||
|
apsz[0] = strEventMsg.QueryStr();
|
||||||
|
if (FORWARDING_HANDLER::QueryEventLog() != NULL)
|
||||||
|
{
|
||||||
|
ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
|
||||||
|
EVENTLOG_WARNING_TYPE,
|
||||||
|
0,
|
||||||
|
ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE,
|
||||||
|
NULL,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
apsz,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (hProc != INVALID_HANDLE_VALUE)
|
if (hProc != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
CloseHandle(hProc);
|
CloseHandle(hProc);
|
||||||
hProc = INVALID_HANDLE_VALUE;
|
hProc = INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
|
if (m_hProcessHandle != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
CloseHandle(m_hProcessHandle);
|
||||||
|
m_hProcessHandle = INVALID_HANDLE_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -1640,7 +1649,6 @@ Finished:
|
||||||
|
|
||||||
SERVER_PROCESS::SERVER_PROCESS() :
|
SERVER_PROCESS::SERVER_PROCESS() :
|
||||||
m_cRefs( 1 ),
|
m_cRefs( 1 ),
|
||||||
m_CancelEvent( NULL ),
|
|
||||||
m_hProcessHandle( NULL ),
|
m_hProcessHandle( NULL ),
|
||||||
m_hProcessWaitHandle( NULL ),
|
m_hProcessWaitHandle( NULL ),
|
||||||
m_dwProcessId( 0 ),
|
m_dwProcessId( 0 ),
|
||||||
|
|
@ -1681,13 +1689,6 @@ SERVER_PROCESS::~SERVER_PROCESS()
|
||||||
m_hProcessWaitHandle = NULL;
|
m_hProcessWaitHandle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_CancelEvent != NULL )
|
|
||||||
{
|
|
||||||
SetEvent( m_CancelEvent );
|
|
||||||
CloseHandle( m_CancelEvent );
|
|
||||||
m_CancelEvent = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(INT i=0;i<MAX_ACTIVE_CHILD_PROCESSES;++i)
|
for(INT i=0;i<MAX_ACTIVE_CHILD_PROCESSES;++i)
|
||||||
{
|
{
|
||||||
if(m_hChildProcessWaitHandles[i] != NULL)
|
if(m_hChildProcessWaitHandles[i] != NULL)
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
<attribute name="stdoutLogEnabled" type="bool" defaultValue="false" />
|
<attribute name="stdoutLogEnabled" type="bool" defaultValue="false" />
|
||||||
<attribute name="stdoutLogFile" type="string" defaultValue=".\aspnetcore-stdout" expanded="true"/>
|
<attribute name="stdoutLogFile" type="string" defaultValue=".\aspnetcore-stdout" expanded="true"/>
|
||||||
<attribute name="processesPerApplication" type="uint" defaultValue="1" validationType="integerRange" validationParameter="1,100"/>
|
<attribute name="processesPerApplication" type="uint" defaultValue="1" validationType="integerRange" validationParameter="1,100"/>
|
||||||
<attribute name="forwardWindowsAuthToken" type="bool" defaultValue="false" />
|
<attribute name="forwardWindowsAuthToken" type="bool" defaultValue="true" />
|
||||||
<attribute name="disableStartUpErrorPage" type="bool" defaultValue="false" />
|
<attribute name="disableStartUpErrorPage" type="bool" defaultValue="false" />
|
||||||
<element name="recycleOnFileChange">
|
<element name="recycleOnFileChange">
|
||||||
<collection addElement="file" clearElement="clear">
|
<collection addElement="file" clearElement="clear">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue