Panwang/addinglog (#508)
* adding windows event log * adding windows event log * fix a wrong bool variable * some updates * fix bad merge
This commit is contained in:
parent
8707d71f1e
commit
7b65bdb6ef
|
|
@ -52,6 +52,8 @@ x64/
|
|||
src/AspNetCore/aspnetcore_msg.h
|
||||
src/AspNetCore/aspnetcore_msg.rc
|
||||
src/AspNetCore/version.h
|
||||
src/CommonLib/aspnetcore_msg.h
|
||||
src/CommonLib/aspnetcore_msg.rc
|
||||
.build
|
||||
|
||||
*.VC.*db
|
||||
|
|
|
|||
|
|
@ -202,7 +202,6 @@
|
|||
<ClInclude Include="Inc\applicationinfo.h" />
|
||||
<ClInclude Include="Inc\appoffline.h" />
|
||||
<ClInclude Include="inc\globalmodule.h" />
|
||||
<ClInclude Include="Inc\resource.h" />
|
||||
<ClInclude Include="Inc\applicationmanager.h" />
|
||||
<ClInclude Include="Inc\filewatcher.h" />
|
||||
<ClInclude Include="Inc\proxymodule.h" />
|
||||
|
|
|
|||
|
|
@ -135,9 +135,21 @@ APPLICATION_INFO::UpdateAppOfflineFileHandle()
|
|||
// recycle the application
|
||||
if (m_pApplication != NULL)
|
||||
{
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_RECYCLE_APPOFFLINE_MSG,
|
||||
m_pApplication->QueryConfig()->QueryApplicationPath()->QueryStr())))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_RECYCLE_APPOFFLINE,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
|
||||
m_pApplication->ShutDown();
|
||||
m_pApplication->DereferenceApplication();
|
||||
m_pApplication = NULL;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ APPLICATION_MANAGER::GetApplicationInfo(
|
|||
BOOL fMixedHostingModelError = FALSE;
|
||||
BOOL fDuplicatedInProcessApp = FALSE;
|
||||
PCWSTR pszApplicationId = NULL;
|
||||
LPCWSTR apsz[1];
|
||||
STACK_STRU ( strEventMsg, 256 );
|
||||
|
||||
*ppApplicationInfo = NULL;
|
||||
|
|
@ -153,42 +152,24 @@ Finished:
|
|||
ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP_MSG,
|
||||
pszApplicationId)))
|
||||
{
|
||||
/*apsz[0] = strEventMsg.QueryStr();
|
||||
if (FORWARDING_HANDLER::QueryEventLog() != NULL)
|
||||
{
|
||||
ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
0,
|
||||
ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP,
|
||||
NULL,
|
||||
1,
|
||||
0,
|
||||
apsz,
|
||||
NULL);
|
||||
}*/
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
}
|
||||
else if (fMixedHostingModelError)
|
||||
{
|
||||
//if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
// ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR_MSG,
|
||||
// pszApplicationId,
|
||||
// pConfig->QueryHostingModelStr())))
|
||||
//{
|
||||
// apsz[0] = strEventMsg.QueryStr();
|
||||
// /*if (FORWARDING_HANDLER::QueryEventLog() != NULL)
|
||||
// {
|
||||
// ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
|
||||
// EVENTLOG_ERROR_TYPE,
|
||||
// 0,
|
||||
// ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR,
|
||||
// NULL,
|
||||
// 1,
|
||||
// 0,
|
||||
// apsz,
|
||||
// NULL);
|
||||
// }*/
|
||||
//}
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR_MSG,
|
||||
pszApplicationId,
|
||||
pConfig->QueryHostingModel())))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -197,19 +178,10 @@ Finished:
|
|||
pszApplicationId,
|
||||
hr)))
|
||||
{
|
||||
apsz[0] = strEventMsg.QueryStr();
|
||||
/*if (FORWARDING_HANDLER::QueryEventLog() != NULL)
|
||||
{
|
||||
ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
0,
|
||||
ASPNETCORE_EVENT_ADD_APPLICATION_ERROR,
|
||||
NULL,
|
||||
1,
|
||||
0,
|
||||
apsz,
|
||||
NULL);
|
||||
}*/
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_ADD_APPLICATION_ERROR,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
HTTP_MODULE_ID g_pModuleId = NULL;
|
||||
IHttpServer * g_pHttpServer = NULL;
|
||||
HANDLE g_hEventLog = NULL;
|
||||
BOOL g_fRecycleProcessCalled = FALSE;
|
||||
PCWSTR g_pszModuleName = NULL;
|
||||
HINSTANCE g_hModule;
|
||||
|
|
@ -25,6 +26,11 @@ VOID
|
|||
StaticCleanup()
|
||||
{
|
||||
APPLICATION_MANAGER::Cleanup();
|
||||
if (g_hEventLog != NULL)
|
||||
{
|
||||
DeregisterEventSource(g_hEventLog);
|
||||
g_hEventLog = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HMODULE hModule,
|
||||
|
|
@ -100,6 +106,15 @@ HRESULT
|
|||
g_pszModuleName = pModuleInfo->GetName();
|
||||
g_pHttpServer = pHttpServer;
|
||||
|
||||
if (g_pHttpServer->IsCommandLineLaunch())
|
||||
{
|
||||
g_hEventLog = RegisterEventSource(NULL, ASPNETCORE_IISEXPRESS_EVENT_PROVIDER);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_hEventLog = RegisterEventSource(NULL, ASPNETCORE_EVENT_PROVIDER);
|
||||
}
|
||||
|
||||
// check whether the feature is disabled due to security reason
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\Microsoft\\IIS Extensions\\IIS AspNetCore Module\\Parameters",
|
||||
|
|
@ -127,6 +142,17 @@ HRESULT
|
|||
if (fDisableANCM)
|
||||
{
|
||||
// Logging
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_MODULE_DISABLED_MSG)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_WARNING_TYPE,
|
||||
ASPNETCORE_EVENT_MODULE_DISABLED,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
// this will return 500 error to client
|
||||
// as we did not register the module
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,14 +108,14 @@ inline bool IsSpace(char ch)
|
|||
#include "..\..\CommonLib\utility.h"
|
||||
#include "..\..\CommonLib\debugutil.h"
|
||||
#include "..\..\CommonLib\requesthandler.h"
|
||||
//#include "..\aspnetcore_msg.h"
|
||||
#include "..\..\CommonLib\resources.h"
|
||||
#include "..\..\CommonLib\aspnetcore_msg.h"
|
||||
//#include "aspnetcore_event.h"
|
||||
#include "appoffline.h"
|
||||
#include "filewatcher.h"
|
||||
#include "applicationinfo.h"
|
||||
#include "applicationmanager.h"
|
||||
#include "globalmodule.h"
|
||||
#include "resource.h"
|
||||
#include "proxymodule.h"
|
||||
#include "applicationinfo.h"
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ extern HINSTANCE g_hModule;
|
|||
extern HMODULE g_hAspnetCoreRH;
|
||||
extern SRWLOCK g_srwLock;
|
||||
extern PCWSTR g_pwzAspnetcoreRequestHandlerName;
|
||||
|
||||
extern HANDLE g_hEventLog;
|
||||
extern PFN_ASPNETCORE_CREATE_APPLICATION g_pfnAspNetCoreCreateApplication;
|
||||
extern PFN_ASPNETCORE_CREATE_REQUEST_HANDLER g_pfnAspNetCoreCreateRequestHandler;
|
||||
#pragma warning( error : 4091)
|
||||
|
|
|
|||
|
|
@ -177,6 +177,7 @@
|
|||
<ClInclude Include="fx_ver.h" />
|
||||
<ClInclude Include="hostfxr_utility.h" />
|
||||
<ClInclude Include="requesthandler.h" />
|
||||
<ClInclude Include="resources.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="utility.h" />
|
||||
</ItemGroup>
|
||||
|
|
@ -199,6 +200,23 @@
|
|||
<Project>{4787a64f-9a3e-4867-a55a-70cb4b2b2ffe}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="aspnetcore_msg.mc">
|
||||
<FileType>Document</FileType>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">mc %(FullPath)</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compiling Event Messages ...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).rc;%(Filename).h;MSG0409.bin</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">mc %(FullPath)</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compiling Event Messages ...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).rc;%(Filename).h;MSG0409.bin</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">mc %(FullPath)</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compiling Event Messages ...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).rc;%(Filename).h;MSG0409.bin</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">mc %(FullPath)</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compiling Event Messages ...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).rc;%(Filename).h;MSG0409.bin</Outputs>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
|
|
|||
|
|
@ -98,6 +98,18 @@ Language=English
|
|||
%1
|
||||
.
|
||||
|
||||
Messageid=1012
|
||||
SymbolicName=ASPNETCORE_EVENT_RECYCLE_APPOFFLINE
|
||||
Language=English
|
||||
%1
|
||||
.
|
||||
|
||||
Messageid=1013
|
||||
SymbolicName=ASPNETCORE_EVENT_MODULE_DISABLED
|
||||
Language=English
|
||||
%1
|
||||
.
|
||||
|
||||
;
|
||||
;#endif // _ASPNETCORE_MODULE_MSG_H_
|
||||
;
|
||||
;
|
||||
|
|
@ -6,12 +6,15 @@
|
|||
#define IDS_INVALID_PROPERTY 1000
|
||||
#define IDS_SERVER_ERROR 1001
|
||||
|
||||
#define ASPNETCORE_EVENT_PROVIDER L"IIS AspNetCore Module"
|
||||
#define ASPNETCORE_IISEXPRESS_EVENT_PROVIDER L"IIS Express AspNetCore Module"
|
||||
|
||||
#define ASPNETCORE_EVENT_MSG_BUFFER_SIZE 256
|
||||
#define ASPNETCORE_EVENT_PROCESS_START_SUCCESS_MSG L"Application '%s' started process '%d' successfully and is listening on port '%d'."
|
||||
#define ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED_MSG L"Maximum rapid fail count per minute of '%d' exceeded."
|
||||
#define ASPNETCORE_EVENT_PROCESS_START_INTERNAL_ERROR_MSG L"Application '%s' failed to parse processPath and arguments due to internal error, ErrorCode = '0x%x'."
|
||||
#define ASPNETCORE_EVENT_PROCESS_START_POSTCREATE_ERROR_MSG L"Application '%s' with physical root '%s' created process with commandline '%s'but failed to get its status, ErrorCode = '0x%x'."
|
||||
#define ASPNETCORE_EVENT_PROCESS_START_ERROR_MSG L"Application '%s' with physical root '%s' failed to start process with commandline '%s', ErrorCode = '0x%x' processStatus code '%x'."
|
||||
#define ASPNETCORE_EVENT_PROCESS_START_POSTCREATE_ERROR_MSG L"Application '%s' with physical root '%s' created process with commandline '%s'but failed to get its status, ErrorCode = '0x%x', retryCounter '%d'."
|
||||
#define ASPNETCORE_EVENT_PROCESS_START_ERROR_MSG L"Application '%s' with physical root '%s' failed to start process with commandline '%s', ErrorCode = '0x%x', retryCounter '%d'."
|
||||
#define ASPNETCORE_EVENT_PROCESS_START_WRONGPORT_ERROR_MSG L"Application '%s' with physical root '%s' created process with commandline '%s' but failed to listen on the given port '%d'"
|
||||
#define ASPNETCORE_EVENT_PROCESS_START_NOTREADY_ERROR_MSG L"Application '%s' with physical root '%s' created process with commandline '%s' but either crashed or did not reponse or did not listen on the given port '%d', ErrorCode = '0x%x'"
|
||||
#define ASPNETCORE_EVENT_INVALID_STDOUT_LOG_FILE_MSG L"Warning: Could not create stdoutLogFile %s, ErrorCode = %d."
|
||||
|
|
@ -19,6 +22,8 @@
|
|||
#define ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST_MSG L"Sent shutdown HTTP message to process '%d' and received http status '%d'."
|
||||
#define ASPNETCORE_EVENT_LOAD_CLR_FALIURE_MSG L"Application '%s' with physical root '%s' failed to load clr and managed application, ErrorCode = '0x%x."
|
||||
#define ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP_MSG L"Only one inprocess application is allowed per IIS application pool. Please assign the application '%s' to a different IIS application pool."
|
||||
#define ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR_MSG L"Mixed hosting model is not supported. Application '%s' configured with different hostingModel value '%s' other than the one of running application(s)."
|
||||
#define ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR_MSG L"Mixed hosting model is not supported. Application '%s' configured with different hostingModel value '%d' other than the one of running application(s)."
|
||||
#define ASPNETCORE_EVENT_ADD_APPLICATION_ERROR_MSG L"Failed to start application '%s', ErrorCode '0x%x'."
|
||||
#define ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_MSG L"Application '%s' with physical root '%s' hit unexpected managed background thread exit, ErrorCode = '0x%x."
|
||||
#define ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_MSG L"Application '%s' with physical root '%s' hit unexpected managed background thread eixt, ErrorCode = '0x%x."
|
||||
#define ASPNETCORE_EVENT_RECYCLE_APPOFFLINE_MSG L"Application '%s' is recycled due to app_offline file was detected."
|
||||
#define ASPNETCORE_EVENT_MODULE_DISABLED_MSG L"AspNetCore Module is disabled"
|
||||
|
|
@ -599,3 +599,31 @@ UTILITY::CheckIfFileExists(
|
|||
|
||||
return fFileExists;
|
||||
}
|
||||
|
||||
VOID
|
||||
UTILITY::LogEvent(
|
||||
_In_ HANDLE hEventLog,
|
||||
_In_ WORD dwEventInfoType,
|
||||
_In_ DWORD dwEventId,
|
||||
_In_ LPCWSTR pstrMsg
|
||||
)
|
||||
{
|
||||
if (hEventLog != NULL)
|
||||
{
|
||||
ReportEventW(hEventLog,
|
||||
dwEventInfoType,
|
||||
0, // wCategory
|
||||
dwEventId,
|
||||
NULL, // lpUserSid
|
||||
1, // wNumStrings
|
||||
0, // dwDataSize,
|
||||
&pstrMsg,
|
||||
NULL // lpRawData
|
||||
);
|
||||
}
|
||||
|
||||
if (dwEventInfoType == EVENTLOG_ERROR_TYPE)
|
||||
{
|
||||
fwprintf(stderr, L"ERROR: %s\n", pstrMsg);
|
||||
}
|
||||
}
|
||||
|
|
@ -111,8 +111,17 @@ public:
|
|||
PCWSTR pszFilePath
|
||||
);
|
||||
|
||||
static
|
||||
VOID
|
||||
LogEvent(
|
||||
_In_ HANDLE hEventLog,
|
||||
_In_ WORD dwEventInfoType,
|
||||
_In_ DWORD dwEventId,
|
||||
_In_ LPCWSTR pstrMsg
|
||||
);
|
||||
|
||||
private:
|
||||
|
||||
UTILITY() {}
|
||||
~UTILITY() {}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -201,7 +201,7 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="aspnetcore_event.h" />
|
||||
<ClInclude Include="aspnetcore_msg.h" />
|
||||
<ClInclude Include="disconnectcontext.h" />
|
||||
<ClInclude Include="sttimer.h" />
|
||||
<ClInclude Include="outofprocess\forwarderconnection.h" />
|
||||
<ClInclude Include="outofprocess\processmanager.h" />
|
||||
|
|
@ -211,7 +211,6 @@
|
|||
<ClInclude Include="outofprocess\websockethandler.h" />
|
||||
<ClInclude Include="outofprocess\winhttphelper.h" />
|
||||
<ClInclude Include="precomp.hxx" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include=".\inprocess\inprocessapplication.h" />
|
||||
<ClInclude Include=".\inprocess\inprocesshandler.h" />
|
||||
<ClInclude Include=".\outofprocess\forwardinghandler.h" />
|
||||
|
|
@ -232,23 +231,6 @@
|
|||
<ClCompile Include="outofprocess\websockethandler.cxx" />
|
||||
<ClCompile Include="outofprocess\winhttphelper.cxx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="aspnetcore_msg.mc">
|
||||
<FileType>Document</FileType>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">mc %(FullPath)</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compiling Event Messages ...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).rc;%(Filename).h;MSG0409.bin</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">mc %(FullPath)</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compiling Event Messages ...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).rc;%(Filename).h;MSG0409.bin</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">mc %(FullPath)</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compiling Event Messages ...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).rc;%(Filename).h;MSG0409.bin</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">mc %(FullPath)</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compiling Event Messages ...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).rc;%(Filename).h;MSG0409.bin</Outputs>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CommonLib\CommonLib.vcxproj">
|
||||
<Project>{55494e58-e061-4c4c-a0a8-837008e72f85}</Project>
|
||||
|
|
@ -257,9 +239,6 @@
|
|||
<Project>{4787a64f-9a3e-4867-a55a-70cb4b2b2ffe}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="RequestHandler.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Source.def" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="precomp.hxx" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include=".\inprocess\inprocessapplication.h">
|
||||
<Filter>InProcess</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -80,7 +79,6 @@
|
|||
</ClInclude>
|
||||
<ClInclude Include="aspnetcore_event.h" />
|
||||
<ClInclude Include="sttimer.h" />
|
||||
<ClInclude Include="aspnetcore_msg.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="RequestHandler.rc" />
|
||||
|
|
@ -102,7 +100,4 @@
|
|||
<UniqueIdentifier>{5568209f-269e-4d0a-bbb7-ba14f874ccb7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="aspnetcore_msg.mc" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
#include "version.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United States) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE 9, 1
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (United States) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION FileVersion
|
||||
PRODUCTVERSION ProductVersion
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Microsoft"
|
||||
VALUE "FileDescription", "IIS ASP.NET Core Module Request Handler"
|
||||
VALUE "FileVersion", FileVersionStr
|
||||
VALUE "InternalName", "aspnetcorerh.dll"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2016"
|
||||
VALUE "OriginalFilename", "aspnetcorerh.dll"
|
||||
VALUE "ProductName", "ASP.NET Core Module"
|
||||
VALUE "ProductVersion", ProductVersionStr
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
|
|
@ -1,165 +0,0 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) .NET Foundation. All rights reserved.
|
||||
Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
Module Name:
|
||||
|
||||
aspnetcore_msg.mc
|
||||
|
||||
Abstract:
|
||||
|
||||
Asp.Net Core Module localizable messages.
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
#ifndef _ASPNETCORE_MSG_H_
|
||||
#define _ASPNETCORE_MSG_H_
|
||||
|
||||
//
|
||||
// Values are 32 bit values laid out as follows:
|
||||
//
|
||||
// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
|
||||
// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
|
||||
// +---+-+-+-----------------------+-------------------------------+
|
||||
// |Sev|C|R| Facility | Code |
|
||||
// +---+-+-+-----------------------+-------------------------------+
|
||||
//
|
||||
// where
|
||||
//
|
||||
// Sev - is the severity code
|
||||
//
|
||||
// 00 - Success
|
||||
// 01 - Informational
|
||||
// 10 - Warning
|
||||
// 11 - Error
|
||||
//
|
||||
// C - is the Customer code flag
|
||||
//
|
||||
// R - is a reserved bit
|
||||
//
|
||||
// Facility - is the facility code
|
||||
//
|
||||
// Code - is the facility's status code
|
||||
//
|
||||
//
|
||||
// Define the facility codes
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// Define the severity codes
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// MessageId: ASPNETCORE_EVENT_PROCESS_START_ERROR
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// %1
|
||||
//
|
||||
#define ASPNETCORE_EVENT_PROCESS_START_ERROR ((DWORD)0x000003E8L)
|
||||
|
||||
//
|
||||
// MessageId: ASPNETCORE_EVENT_PROCESS_START_SUCCESS
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// %1
|
||||
//
|
||||
#define ASPNETCORE_EVENT_PROCESS_START_SUCCESS ((DWORD)0x000003E9L)
|
||||
|
||||
//
|
||||
// MessageId: ASPNETCORE_EVENT_PROCESS_CRASH
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// %1
|
||||
//
|
||||
#define ASPNETCORE_EVENT_PROCESS_CRASH ((DWORD)0x000003EAL)
|
||||
|
||||
//
|
||||
// MessageId: ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// %1
|
||||
//
|
||||
#define ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED ((DWORD)0x000003EBL)
|
||||
|
||||
//
|
||||
// MessageId: ASPNETCORE_EVENT_CONFIG_ERROR
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// %1
|
||||
//
|
||||
#define ASPNETCORE_EVENT_CONFIG_ERROR ((DWORD)0x000003ECL)
|
||||
|
||||
//
|
||||
// MessageId: ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// %1
|
||||
//
|
||||
#define ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE ((DWORD)0x000003EDL)
|
||||
|
||||
//
|
||||
// MessageId: ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// %1
|
||||
//
|
||||
#define ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST ((DWORD)0x000003EEL)
|
||||
|
||||
//
|
||||
// MessageId: ASPNETCORE_EVENT_LOAD_CLR_FALIURE
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// %1
|
||||
//
|
||||
#define ASPNETCORE_EVENT_LOAD_CLR_FALIURE ((DWORD)0x000003EFL)
|
||||
|
||||
//
|
||||
// MessageId: ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// %1
|
||||
//
|
||||
#define ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP ((DWORD)0x000003F0L)
|
||||
|
||||
//
|
||||
// MessageId: ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// %1
|
||||
//
|
||||
#define ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR ((DWORD)0x000003F1L)
|
||||
|
||||
//
|
||||
// MessageId: ASPNETCORE_EVENT_ADD_APPLICATION_ERROR
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// %1
|
||||
//
|
||||
#define ASPNETCORE_EVENT_ADD_APPLICATION_ERROR ((DWORD)0x000003F2L)
|
||||
|
||||
//
|
||||
// MessageId: ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// %1
|
||||
//
|
||||
#define ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT ((DWORD)0x000003F3L)
|
||||
|
||||
|
||||
#endif // _ASPNETCORE_MODULE_MSG_H_
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
LANGUAGE 0x9,0x1
|
||||
1 11 "MSG00001.bin"
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
BOOL g_fNsiApiNotSupported = FALSE;
|
||||
BOOL g_fWebSocketSupported = FALSE;
|
||||
BOOL g_fEnableReferenceCountTracing = FALSE;
|
||||
BOOL g_fGlobalInitialize = FALSE;
|
||||
BOOL g_fOutOfProcessInitialize = FALSE;
|
||||
BOOL g_fOutOfProcessInitializeError = FALSE;
|
||||
BOOL g_fWinHttpNonBlockingCallbackAvailable = FALSE;
|
||||
|
|
@ -17,87 +18,117 @@ SRWLOCK g_srwLockRH;
|
|||
HINTERNET g_hWinhttpSession = NULL;
|
||||
IHttpServer * g_pHttpServer = NULL;
|
||||
HINSTANCE g_hWinHttpModule;
|
||||
HANDLE g_hEventLog = NULL;
|
||||
|
||||
|
||||
VOID
|
||||
InitializeGlobalConfiguration(
|
||||
VOID
|
||||
IHttpServer * pServer
|
||||
)
|
||||
{
|
||||
HKEY hKey;
|
||||
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\Microsoft\\IIS Extensions\\IIS AspNetCore Module\\Parameters",
|
||||
0,
|
||||
KEY_READ,
|
||||
&hKey) == NO_ERROR)
|
||||
{
|
||||
DWORD dwType;
|
||||
DWORD dwData;
|
||||
DWORD cbData;
|
||||
|
||||
cbData = sizeof(dwData);
|
||||
if ((RegQueryValueEx(hKey,
|
||||
L"OptionalWinHttpFlags",
|
||||
NULL,
|
||||
&dwType,
|
||||
(LPBYTE)&dwData,
|
||||
&cbData) == NO_ERROR) &&
|
||||
(dwType == REG_DWORD))
|
||||
{
|
||||
g_OptionalWinHttpFlags = dwData;
|
||||
}
|
||||
|
||||
cbData = sizeof(dwData);
|
||||
if ((RegQueryValueEx(hKey,
|
||||
L"EnableReferenceCountTracing",
|
||||
NULL,
|
||||
&dwType,
|
||||
(LPBYTE)&dwData,
|
||||
&cbData) == NO_ERROR) &&
|
||||
(dwType == REG_DWORD) && (dwData == 1 || dwData == 0))
|
||||
{
|
||||
g_fEnableReferenceCountTracing = !!dwData;
|
||||
}
|
||||
|
||||
cbData = sizeof(dwData);
|
||||
if ((RegQueryValueEx(hKey,
|
||||
L"DebugFlags",
|
||||
NULL,
|
||||
&dwType,
|
||||
(LPBYTE)&dwData,
|
||||
&cbData) == NO_ERROR) &&
|
||||
(dwType == REG_DWORD))
|
||||
{
|
||||
g_dwAspNetCoreDebugFlags = dwData;
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
BOOL fLocked = FALSE;
|
||||
DWORD dwSize = 0;
|
||||
DWORD dwResult = GetExtendedTcpTable(NULL,
|
||||
&dwSize,
|
||||
FALSE,
|
||||
AF_INET,
|
||||
TCP_TABLE_OWNER_PID_LISTENER,
|
||||
0);
|
||||
if (dwResult != NO_ERROR && dwResult != ERROR_INSUFFICIENT_BUFFER)
|
||||
DWORD dwResult = 0;
|
||||
|
||||
if (!g_fGlobalInitialize)
|
||||
{
|
||||
g_fNsiApiNotSupported = TRUE;
|
||||
AcquireSRWLockExclusive(&g_srwLockRH);
|
||||
fLocked = TRUE;
|
||||
|
||||
if (g_fGlobalInitialize)
|
||||
{
|
||||
// Done by another thread
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
g_pHttpServer = pServer;
|
||||
if (pServer->IsCommandLineLaunch())
|
||||
{
|
||||
g_hEventLog = RegisterEventSource(NULL, ASPNETCORE_IISEXPRESS_EVENT_PROVIDER);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_hEventLog = RegisterEventSource(NULL, ASPNETCORE_EVENT_PROVIDER);
|
||||
}
|
||||
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\Microsoft\\IIS Extensions\\IIS AspNetCore Module\\Parameters",
|
||||
0,
|
||||
KEY_READ,
|
||||
&hKey) == NO_ERROR)
|
||||
{
|
||||
DWORD dwType;
|
||||
DWORD dwData;
|
||||
DWORD cbData;
|
||||
|
||||
cbData = sizeof(dwData);
|
||||
if ((RegQueryValueEx(hKey,
|
||||
L"OptionalWinHttpFlags",
|
||||
NULL,
|
||||
&dwType,
|
||||
(LPBYTE)&dwData,
|
||||
&cbData) == NO_ERROR) &&
|
||||
(dwType == REG_DWORD))
|
||||
{
|
||||
g_OptionalWinHttpFlags = dwData;
|
||||
}
|
||||
|
||||
cbData = sizeof(dwData);
|
||||
if ((RegQueryValueEx(hKey,
|
||||
L"EnableReferenceCountTracing",
|
||||
NULL,
|
||||
&dwType,
|
||||
(LPBYTE)&dwData,
|
||||
&cbData) == NO_ERROR) &&
|
||||
(dwType == REG_DWORD) && (dwData == 1 || dwData == 0))
|
||||
{
|
||||
g_fEnableReferenceCountTracing = !!dwData;
|
||||
}
|
||||
|
||||
cbData = sizeof(dwData);
|
||||
if ((RegQueryValueEx(hKey,
|
||||
L"DebugFlags",
|
||||
NULL,
|
||||
&dwType,
|
||||
(LPBYTE)&dwData,
|
||||
&cbData) == NO_ERROR) &&
|
||||
(dwType == REG_DWORD))
|
||||
{
|
||||
g_dwAspNetCoreDebugFlags = dwData;
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
dwResult = GetExtendedTcpTable(NULL,
|
||||
&dwSize,
|
||||
FALSE,
|
||||
AF_INET,
|
||||
TCP_TABLE_OWNER_PID_LISTENER,
|
||||
0);
|
||||
if (dwResult != NO_ERROR && dwResult != ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
g_fNsiApiNotSupported = TRUE;
|
||||
}
|
||||
|
||||
// WebSocket is supported on Win8 and above only
|
||||
// todo: test on win7
|
||||
g_fWebSocketSupported = IsWindows8OrGreater();
|
||||
|
||||
g_fGlobalInitialize = TRUE;
|
||||
}
|
||||
Finished:
|
||||
if (fLocked)
|
||||
{
|
||||
ReleaseSRWLockExclusive(&g_srwLockRH);
|
||||
}
|
||||
|
||||
// WebSocket is supported on Win8 and above only
|
||||
// todo: test on win7
|
||||
g_fWebSocketSupported = IsWindows8OrGreater();
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Global initialization routine for OutOfProcess
|
||||
//
|
||||
HRESULT
|
||||
EnsureOutOfProcessInitializtion( IHttpServer* pServer)
|
||||
EnsureOutOfProcessInitializtion()
|
||||
{
|
||||
|
||||
DBG_ASSERT(pServer);
|
||||
|
|
@ -105,13 +136,12 @@ EnsureOutOfProcessInitializtion( IHttpServer* pServer)
|
|||
HRESULT hr = S_OK;
|
||||
BOOL fLocked = FALSE;
|
||||
|
||||
g_pHttpServer = pServer;
|
||||
|
||||
if (g_fOutOfProcessInitializeError)
|
||||
{
|
||||
hr = E_NOT_VALID_STATE;
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
if (!g_fOutOfProcessInitialize)
|
||||
{
|
||||
AcquireSRWLockExclusive(&g_srwLockRH);
|
||||
|
|
@ -128,9 +158,6 @@ EnsureOutOfProcessInitializtion( IHttpServer* pServer)
|
|||
goto Finished;
|
||||
}
|
||||
|
||||
// Initialze some global variables here
|
||||
InitializeGlobalConfiguration();
|
||||
|
||||
g_hWinHttpModule = GetModuleHandle(TEXT("winhttp.dll"));
|
||||
|
||||
hr = WINHTTP_HELPER::StaticInitialize();
|
||||
|
|
@ -197,7 +224,6 @@ EnsureOutOfProcessInitializtion( IHttpServer* pServer)
|
|||
goto Finished;
|
||||
}
|
||||
|
||||
|
||||
hr = FORWARDING_HANDLER::StaticInitialize(g_fEnableReferenceCountTracing);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
|
|
@ -235,8 +261,6 @@ BOOL APIENTRY DllMain(HMODULE hModule,
|
|||
case DLL_PROCESS_ATTACH:
|
||||
DisableThreadLibraryCalls(hModule);
|
||||
InitializeSRWLock(&g_srwLockRH);
|
||||
// Initialze some global variables here
|
||||
InitializeGlobalConfiguration();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -255,7 +279,8 @@ CreateApplication(
|
|||
HRESULT hr = S_OK;
|
||||
APPLICATION *pApplication = NULL;
|
||||
|
||||
//REQUEST_HANDLER::StaticInitialize(pServer);
|
||||
// Initialze some global variables here
|
||||
InitializeGlobalConfiguration(pServer);
|
||||
|
||||
if (pConfig->QueryHostingModel() == APP_HOSTING_MODEL::HOSTING_IN_PROCESS)
|
||||
{
|
||||
|
|
@ -268,7 +293,7 @@ CreateApplication(
|
|||
}
|
||||
else if (pConfig->QueryHostingModel() == APP_HOSTING_MODEL::HOSTING_OUT_PROCESS)
|
||||
{
|
||||
hr = EnsureOutOfProcessInitializtion(pServer);
|
||||
hr = EnsureOutOfProcessInitializtion();
|
||||
if (FAILED(hr))
|
||||
{
|
||||
goto Finished;
|
||||
|
|
|
|||
|
|
@ -343,33 +343,17 @@ Finished:
|
|||
}
|
||||
if (FAILED(hr) && m_pConfig->QueryStdoutLogEnabled())
|
||||
{
|
||||
//todo log an warning
|
||||
//STRU strEventMsg;
|
||||
//LPCWSTR apsz[1];
|
||||
|
||||
//if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
// ASPNETCORE_EVENT_INVALID_STDOUT_LOG_FILE_MSG,
|
||||
// m_struLogFilePath.QueryStr(),
|
||||
// HRESULT_FROM_GETLASTERROR())))
|
||||
//{
|
||||
// apsz[0] = strEventMsg.QueryStr();
|
||||
// //
|
||||
// // not checking return code because if ReportEvent
|
||||
// // fails, we cannot do anything.
|
||||
// //
|
||||
// if (FORWARDING_HANDLER::QueryEventLog() != NULL)
|
||||
// {
|
||||
// ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
|
||||
// EVENTLOG_WARNING_TYPE,
|
||||
// 0,
|
||||
// ASPNETCORE_EVENT_CONFIG_ERROR,
|
||||
// NULL,
|
||||
// 1,
|
||||
// 0,
|
||||
// apsz,
|
||||
// NULL);
|
||||
// }
|
||||
//}
|
||||
STRU strEventMsg;
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_INVALID_STDOUT_LOG_FILE_MSG,
|
||||
m_struLogFilePath.QueryStr(),
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_WARNING_TYPE,
|
||||
ASPNETCORE_EVENT_CONFIG_ERROR,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -384,8 +368,6 @@ IN_PROCESS_APPLICATION::LoadManagedApplication
|
|||
DWORD dwTimeout;
|
||||
DWORD dwResult;
|
||||
BOOL fLocked = FALSE;
|
||||
//PCWSTR apsz[1];
|
||||
//STACK_STRU(strEventMsg, 256);
|
||||
|
||||
if (m_fManagedAppLoaded || m_fLoadManagedAppError)
|
||||
{
|
||||
|
|
@ -481,36 +463,22 @@ Finished:
|
|||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
// Question: in case of application loading failure, should we allow retry on
|
||||
// following request or block the activation at all
|
||||
m_fLoadManagedAppError = TRUE; // m_hThread != NULL ?
|
||||
|
||||
// TODO
|
||||
//if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
// ASPNETCORE_EVENT_LOAD_CLR_FALIURE_MSG,
|
||||
// m_pConfiguration->QueryApplicationPath()->QueryStr(),
|
||||
// m_pConfiguration->QueryApplicationPhysicalPath()->QueryStr(),
|
||||
// hr)))
|
||||
//{
|
||||
// apsz[0] = strEventMsg.QueryStr();
|
||||
|
||||
// //
|
||||
// // not checking return code because if ReportEvent
|
||||
// // fails, we cannot do anything.
|
||||
// //
|
||||
// if (FORWARDING_HANDLER::QueryEventLog() != NULL)
|
||||
// {
|
||||
// ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
|
||||
// EVENTLOG_ERROR_TYPE,
|
||||
// 0,
|
||||
// ASPNETCORE_EVENT_LOAD_CLR_FALIURE,
|
||||
// NULL,
|
||||
// 1,
|
||||
// 0,
|
||||
// apsz,
|
||||
// NULL);
|
||||
// }
|
||||
//}
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_LOAD_CLR_FALIURE_MSG,
|
||||
m_pConfig->QueryApplicationPath()->QueryStr(),
|
||||
m_pConfig->QueryApplicationPhysicalPath()->QueryStr(),
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_LOAD_CLR_FALIURE,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
}
|
||||
|
||||
if (fLocked)
|
||||
|
|
@ -583,37 +551,22 @@ Finished:
|
|||
//
|
||||
if (!m_fRecycleProcessCalled)
|
||||
{
|
||||
//STRU strEventMsg;
|
||||
//LPCWSTR apsz[1];
|
||||
//if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
// ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_MSG,
|
||||
// m_pConfig->QueryApplicationPath()->QueryStr(),
|
||||
// m_pConfig->QueryApplicationPhysicalPath()->QueryStr(),
|
||||
// m_ProcessExitCode
|
||||
//)))
|
||||
//{
|
||||
// apsz[0] = strEventMsg.QueryStr();
|
||||
|
||||
// //
|
||||
// // not checking return code because if ReportEvent
|
||||
// // fails, we cannot do anything.
|
||||
// //
|
||||
// if (FORWARDING_HANDLER::QueryEventLog() != NULL)
|
||||
// {
|
||||
// ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
|
||||
// EVENTLOG_ERROR_TYPE,
|
||||
// 0,
|
||||
// ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT,
|
||||
// NULL,
|
||||
// 1,
|
||||
// 0,
|
||||
// apsz,
|
||||
// NULL);
|
||||
// }
|
||||
// // error. the thread exits after application started
|
||||
// // Question: should we shutdown current worker process or keep the application in failure state?
|
||||
// // for now, we reccylce to keep the same behavior as that of out-of-process
|
||||
//}
|
||||
STRU strEventMsg;
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_MSG,
|
||||
m_pConfig->QueryApplicationPath()->QueryStr(),
|
||||
m_pConfig->QueryApplicationPhysicalPath()->QueryStr(),
|
||||
m_ProcessExitCode)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
|
||||
// error. the thread exits after application started
|
||||
// Question: should we shutdown current worker process or keep the application in failure state?
|
||||
// for now, we reccylce to keep the same behavior as that of out-of-process
|
||||
if (m_fManagedAppLoaded)
|
||||
{
|
||||
Recycle();
|
||||
|
|
|
|||
|
|
@ -110,7 +110,6 @@ PROCESS_MANAGER::GetProcess(
|
|||
HRESULT hr = S_OK;
|
||||
BOOL fSharedLock = FALSE;
|
||||
BOOL fExclusiveLock = FALSE;
|
||||
//PCWSTR apsz[1];
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
DWORD dwProcessIndex = 0;
|
||||
SERVER_PROCESS *pSelectedServerProcess = NULL;
|
||||
|
|
@ -192,30 +191,15 @@ PROCESS_MANAGER::GetProcess(
|
|||
//
|
||||
// rapid fails per minute exceeded, do not create new process.
|
||||
//
|
||||
|
||||
//if( SUCCEEDED( strEventMsg.SafeSnwprintf(
|
||||
// ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED_MSG,
|
||||
// pConfig->QueryRapidFailsPerMinute() ) ) )
|
||||
//{
|
||||
// apsz[0] = strEventMsg.QueryStr();
|
||||
|
||||
// //
|
||||
// // not checking return code because if ReportEvent
|
||||
// // fails, we cannot do anything.
|
||||
// //
|
||||
// if (FORWARDING_HANDLER::QueryEventLog() != NULL)
|
||||
// {
|
||||
// ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
|
||||
// EVENTLOG_INFORMATION_TYPE,
|
||||
// 0,
|
||||
// ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED,
|
||||
// NULL,
|
||||
// 1,
|
||||
// 0,
|
||||
// apsz,
|
||||
// NULL);
|
||||
// }
|
||||
//}
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED_MSG,
|
||||
pConfig->QueryRapidFailsPerMinute())))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
|
||||
hr = HRESULT_FROM_WIN32(ERROR_SERVER_DISABLED);
|
||||
goto Finished;
|
||||
|
|
@ -293,4 +277,4 @@ Finished:
|
|||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -857,19 +857,12 @@ SERVER_PROCESS::StartProcess(
|
|||
HRESULT hr = S_OK;
|
||||
PROCESS_INFORMATION processInformation = {0};
|
||||
STARTUPINFOW startupInfo = {0};
|
||||
// BOOL fDonePrepareCommandLine = FALSE;
|
||||
DWORD dwRetryCount = 2; // should we allow customer to config it
|
||||
DWORD dwCreationFlags = 0;
|
||||
|
||||
// STACK_STRU( strEventMsg, 256);
|
||||
// STRU strFullProcessPath;
|
||||
// STRU struRelativePath;
|
||||
// STRU struApplicationId;
|
||||
//
|
||||
// LPCWSTR apsz[1];
|
||||
STACK_STRU( strEventMsg, 256);
|
||||
MULTISZ mszNewEnvironment;
|
||||
ENVIRONMENT_VAR_HASH *pHashTable = NULL;
|
||||
//
|
||||
|
||||
GetStartupInfoW(&startupInfo);
|
||||
|
||||
//
|
||||
|
|
@ -945,13 +938,13 @@ SERVER_PROCESS::StartProcess(
|
|||
{
|
||||
hr = HRESULT_FROM_WIN32(GetLastError());
|
||||
// don't the check return code as we already in error report
|
||||
/*strEventMsg.SafeSnwprintf(
|
||||
strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_PROCESS_START_ERROR_MSG,
|
||||
m_struAppFullPath.QueryStr(),
|
||||
m_pszRootApplicationPath.QueryStr(),
|
||||
struCommandLine.QueryStr(),
|
||||
m_struPhysicalPath.QueryStr(),
|
||||
m_struCommandLine.QueryStr(),
|
||||
hr,
|
||||
0);*/
|
||||
dwRetryCount);
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
|
|
@ -987,42 +980,17 @@ SERVER_PROCESS::StartProcess(
|
|||
// Backend process starts successfully. Set retry counter to 0
|
||||
dwRetryCount = 0;
|
||||
|
||||
//
|
||||
// if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
// ASPNETCORE_EVENT_PROCESS_START_SUCCESS_MSG,
|
||||
// m_struAppFullPath.QueryStr(),
|
||||
// m_dwProcessId,
|
||||
// m_dwPort)))
|
||||
// {
|
||||
// apsz[0] = strEventMsg.QueryStr();
|
||||
//
|
||||
// //
|
||||
// // not checking return code because if ReportEvent
|
||||
// // fails, we cannot do anything.
|
||||
// //
|
||||
// if (FORWARDING_HANDLER::QueryEventLog() != NULL)
|
||||
// {
|
||||
// ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
|
||||
// EVENTLOG_INFORMATION_TYPE,
|
||||
// 0,
|
||||
// ASPNETCORE_EVENT_PROCESS_START_SUCCESS,
|
||||
// NULL,
|
||||
// 1,
|
||||
// 0,
|
||||
// apsz,
|
||||
// NULL);
|
||||
// }
|
||||
//
|
||||
// // FREB log
|
||||
//if (ANCMEvents::ANCM_START_APPLICATION_SUCCESS::IsEnabled(context->GetTraceContext()))
|
||||
//{
|
||||
// ANCMEvents::ANCM_START_APPLICATION_SUCCESS::RaiseEvent(
|
||||
// context->GetTraceContext(),
|
||||
// NULL,
|
||||
// apsz[0]);
|
||||
//}
|
||||
// }
|
||||
//
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_PROCESS_START_SUCCESS_MSG,
|
||||
m_struAppFullPath.QueryStr(),
|
||||
m_dwProcessId,
|
||||
m_dwPort)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_PROCESS_START_SUCCESS,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
|
||||
Finished:
|
||||
if (processInformation.hThread != NULL)
|
||||
|
|
@ -1037,57 +1005,29 @@ SERVER_PROCESS::StartProcess(
|
|||
delete pHashTable;
|
||||
pHashTable = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// if (FAILED(hr))
|
||||
// {
|
||||
// if (strEventMsg.IsEmpty())
|
||||
// {
|
||||
// if (!fDonePrepareCommandLine)
|
||||
// {
|
||||
// strEventMsg.SafeSnwprintf(
|
||||
// m_struAppFullPath.QueryStr(),
|
||||
// ASPNETCORE_EVENT_PROCESS_START_INTERNAL_ERROR_MSG,
|
||||
// hr);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// strEventMsg.SafeSnwprintf(
|
||||
// ASPNETCORE_EVENT_PROCESS_START_POSTCREATE_ERROR_MSG,
|
||||
// m_struAppFullPath.QueryStr(),
|
||||
// m_pszRootApplicationPath.QueryStr(),
|
||||
// struCommandLine.QueryStr(),
|
||||
// hr);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// apsz[0] = strEventMsg.QueryStr();
|
||||
//
|
||||
// // not checking return code because if ReportEvent
|
||||
// // fails, we cannot do anything.
|
||||
// //
|
||||
// if (FORWARDING_HANDLER::QueryEventLog() != NULL)
|
||||
// {
|
||||
// ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
|
||||
// EVENTLOG_ERROR_TYPE,
|
||||
// 0,
|
||||
// ASPNETCORE_EVENT_PROCESS_START_ERROR,
|
||||
// NULL,
|
||||
// 1,
|
||||
// 0,
|
||||
// apsz,
|
||||
// NULL);
|
||||
// }
|
||||
//
|
||||
// // FREB log
|
||||
// if (ANCMEvents::ANCM_START_APPLICATION_FAIL::IsEnabled(context->GetTraceContext()))
|
||||
// {
|
||||
// ANCMEvents::ANCM_START_APPLICATION_FAIL::RaiseEvent(
|
||||
// context->GetTraceContext(),
|
||||
// NULL,
|
||||
// strEventMsg.QueryStr());
|
||||
// }
|
||||
// }
|
||||
if (FAILED(hr))
|
||||
{
|
||||
if (strEventMsg.IsEmpty())
|
||||
{
|
||||
strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_PROCESS_START_POSTCREATE_ERROR_MSG,
|
||||
m_struAppFullPath.QueryStr(),
|
||||
m_struPhysicalPath.QueryStr(),
|
||||
m_struCommandLine.QueryStr(),
|
||||
hr,
|
||||
dwRetryCount);
|
||||
}
|
||||
|
||||
if (!strEventMsg.IsEmpty())
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_PROCESS_START_ERROR,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (FAILED(hr) || m_fReady == FALSE)
|
||||
{
|
||||
|
|
@ -1121,7 +1061,6 @@ SERVER_PROCESS::StartProcess(
|
|||
}
|
||||
|
||||
StopProcess();
|
||||
|
||||
StopAllProcessesInJobObject();
|
||||
}
|
||||
return hr;
|
||||
|
|
@ -1165,8 +1104,6 @@ SERVER_PROCESS::SetupStdHandles(
|
|||
SECURITY_ATTRIBUTES saAttr = { 0 };
|
||||
|
||||
STRU struPath;
|
||||
//STRU strEventMsg;
|
||||
//LPCWSTR apsz[1];
|
||||
|
||||
DBG_ASSERT(pStartupInfo);
|
||||
|
||||
|
|
@ -1258,30 +1195,17 @@ Finished:
|
|||
if (m_fStdoutLogEnabled)
|
||||
{
|
||||
// Log the error
|
||||
//if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
// ASPNETCORE_EVENT_INVALID_STDOUT_LOG_FILE_MSG,
|
||||
// m_struFullLogFile.QueryStr(),
|
||||
// HRESULT_FROM_GETLASTERROR())))
|
||||
//{
|
||||
// apsz[0] = strEventMsg.QueryStr();
|
||||
|
||||
// //
|
||||
// // not checking return code because if ReportEvent
|
||||
// // fails, we cannot do anything.
|
||||
// //
|
||||
// /*if (FORWARDING_HANDLER::QueryEventLog() != NULL)
|
||||
// {
|
||||
// ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
|
||||
// EVENTLOG_WARNING_TYPE,
|
||||
// 0,
|
||||
// ASPNETCORE_EVENT_CONFIG_ERROR,
|
||||
// NULL,
|
||||
// 1,
|
||||
// 0,
|
||||
// apsz,
|
||||
// NULL);
|
||||
// }*/
|
||||
//}
|
||||
STRU strEventMsg;
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_INVALID_STDOUT_LOG_FILE_MSG,
|
||||
m_struFullLogFile.QueryStr(),
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_WARNING_TYPE,
|
||||
ASPNETCORE_EVENT_CONFIG_ERROR,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
}
|
||||
}
|
||||
return hr;
|
||||
|
|
@ -2077,9 +2001,7 @@ SERVER_PROCESS::SendShutdownHttpMessage( VOID )
|
|||
STRU strUrl;
|
||||
DWORD dwStatusCode = 0;
|
||||
DWORD dwSize = sizeof(dwStatusCode);
|
||||
|
||||
//LPCWSTR apsz[1];
|
||||
//STACK_STRU(strEventMsg, 256);
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
|
||||
hSession = WinHttpOpen(L"",
|
||||
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
|
||||
|
|
@ -2182,25 +2104,16 @@ SERVER_PROCESS::SendShutdownHttpMessage( VOID )
|
|||
}
|
||||
|
||||
// log
|
||||
/*if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST_MSG,
|
||||
m_dwProcessId,
|
||||
dwStatusCode)))
|
||||
{
|
||||
apsz[0] = strEventMsg.QueryStr();
|
||||
if (FORWARDING_HANDLER::QueryEventLog() != NULL)
|
||||
{
|
||||
ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
0,
|
||||
ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST,
|
||||
NULL,
|
||||
1,
|
||||
0,
|
||||
apsz,
|
||||
NULL);
|
||||
}
|
||||
}*/
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
|
||||
Finished:
|
||||
if (hRequest)
|
||||
|
|
@ -2291,8 +2204,7 @@ SERVER_PROCESS::TerminateBackendProcess(
|
|||
VOID
|
||||
)
|
||||
{
|
||||
//LPCWSTR apsz[1];
|
||||
//STACK_STRU(strEventMsg, 256);
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
|
||||
if (InterlockedCompareExchange(&m_lStopping, 1L, 0L) == 0L)
|
||||
{
|
||||
|
|
@ -2316,23 +2228,14 @@ SERVER_PROCESS::TerminateBackendProcess(
|
|||
}
|
||||
|
||||
// log a warning for ungraceful shutdown
|
||||
/*if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
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);
|
||||
}
|
||||
}*/
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_WARNING_TYPE,
|
||||
ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@
|
|||
#include "..\CommonLib\aspnetcoreconfig.h"
|
||||
#include "..\CommonLib\utility.h"
|
||||
#include "..\CommonLib\application.h"
|
||||
#include "..\CommonLib\resources.h"
|
||||
#include "aspnetcore_event.h"
|
||||
#include "aspnetcore_msg.h"
|
||||
#include "disconnectcontext.h"
|
||||
#include "sttimer.h"
|
||||
#include "resource.h"
|
||||
#include ".\inprocess\InProcessHandler.h"
|
||||
#include ".\inprocess\inprocessapplication.h"
|
||||
#include ".\outofprocess\responseheaderhash.h"
|
||||
|
|
@ -88,8 +88,6 @@ template<typename T> inline T min(T a, T b)
|
|||
}
|
||||
#endif
|
||||
|
||||
#define ASPNETCORE_EVENT_PROVIDER L"IIS AspNetCore Module"
|
||||
#define ASPNETCORE_IISEXPRESS_EVENT_PROVIDER L"IIS Express AspNetCore Module"
|
||||
|
||||
inline bool IsSpace(char ch)
|
||||
{
|
||||
|
|
@ -117,3 +115,4 @@ extern DWORD g_OptionalWinHttpFlags;
|
|||
extern SRWLOCK g_srwLockRH;
|
||||
extern HINTERNET g_hWinhttpSession;
|
||||
extern DWORD g_dwTlsIndex;
|
||||
extern HANDLE g_hEventLog;
|
||||
|
|
|
|||
Loading…
Reference in New Issue