| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598 |
- commit 7b65bdb6ef4259d64f48c47529a8fd4f06c56bfe
- Author: pan-wang <[email protected]>
- Date: Tue Jan 16 17:21:47 2018 -0800
- Panwang/addinglog (#508)
-
- * adding windows event log
-
- * adding windows event log
-
- * fix a wrong bool variable
-
- * some updates
-
- * fix bad merge
- diff --git a/.gitignore b/.gitignore
- index 5004d81d9d5..58872165a31 100644
- --- a/.gitignore
- +++ b/.gitignore
- @@ -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
- diff --git a/src/AspNetCore/AspNetCore.vcxproj b/src/AspNetCore/AspNetCore.vcxproj
- index 43acff071d8..687e528ecc4 100644
- --- a/src/AspNetCore/AspNetCore.vcxproj
- +++ b/src/AspNetCore/AspNetCore.vcxproj
- @@ -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" />
- diff --git a/src/AspNetCore/Src/applicationinfo.cpp b/src/AspNetCore/Src/applicationinfo.cpp
- index a80794d8501..1950860b855 100644
- --- a/src/AspNetCore/Src/applicationinfo.cpp
- +++ b/src/AspNetCore/Src/applicationinfo.cpp
- @@ -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;
- +
- }
- }
- }
- diff --git a/src/AspNetCore/Src/applicationmanager.cxx b/src/AspNetCore/Src/applicationmanager.cxx
- index 094f1d5e1c4..4b1c9b6a712 100644
- --- a/src/AspNetCore/Src/applicationmanager.cxx
- +++ b/src/AspNetCore/Src/applicationmanager.cxx
- @@ -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());
- }
- }
- }
- diff --git a/src/AspNetCore/Src/dllmain.cpp b/src/AspNetCore/Src/dllmain.cpp
- index 9b6a5b933b7..83b63d6ea8e 100644
- --- a/src/AspNetCore/Src/dllmain.cpp
- +++ b/src/AspNetCore/Src/dllmain.cpp
- @@ -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;
- }
-
- diff --git a/src/AspNetCore/Src/precomp.hxx b/src/AspNetCore/Src/precomp.hxx
- index 4ef797ec6ae..e8f9f0007ee 100644
- --- a/src/AspNetCore/Src/precomp.hxx
- +++ b/src/AspNetCore/Src/precomp.hxx
- @@ -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)
- diff --git a/src/CommonLib/CommonLib.vcxproj b/src/CommonLib/CommonLib.vcxproj
- index 1d5907222ee..3a72db72e7e 100644
- --- a/src/CommonLib/CommonLib.vcxproj
- +++ b/src/CommonLib/CommonLib.vcxproj
- @@ -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>
- diff --git a/src/RequestHandler/aspnetcore_msg.mc b/src/CommonLib/aspnetcore_msg.mc
- similarity index 90%
- rename from src/RequestHandler/aspnetcore_msg.mc
- rename to src/CommonLib/aspnetcore_msg.mc
- index ae8eec4e88c..bcd125850f7 100644
- --- a/src/RequestHandler/aspnetcore_msg.mc
- +++ b/src/CommonLib/aspnetcore_msg.mc
- @@ -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_
- -;
- \ No newline at end of file
- +;
- diff --git a/src/RequestHandler/resource.h b/src/CommonLib/resources.h
- similarity index 80%
- rename from src/RequestHandler/resource.h
- rename to src/CommonLib/resources.h
- index a8f93c62fba..938922d1499 100644
- --- a/src/RequestHandler/resource.h
- +++ b/src/CommonLib/resources.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"
- diff --git a/src/CommonLib/utility.cxx b/src/CommonLib/utility.cxx
- index a642ec1c9f3..b4dd25a9e5b 100644
- --- a/src/CommonLib/utility.cxx
- +++ b/src/CommonLib/utility.cxx
- @@ -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);
- + }
- +}
- \ No newline at end of file
- diff --git a/src/CommonLib/utility.h b/src/CommonLib/utility.h
- index 5f4ae39026e..49549c0f336 100644
- --- a/src/CommonLib/utility.h
- +++ b/src/CommonLib/utility.h
- @@ -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() {}
- -};
- \ No newline at end of file
- +};
- diff --git a/src/RequestHandler/RequestHandler.rc b/src/RequestHandler/RequestHandler.rc
- deleted file mode 100644
- index 6d285329154..00000000000
- Binary files a/src/RequestHandler/RequestHandler.rc and /dev/null differ
- diff --git a/src/RequestHandler/RequestHandler.vcxproj b/src/RequestHandler/RequestHandler.vcxproj
- index 5d003d4120a..a214f87bcec 100644
- --- a/src/RequestHandler/RequestHandler.vcxproj
- +++ b/src/RequestHandler/RequestHandler.vcxproj
- @@ -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>
- diff --git a/src/RequestHandler/RequestHandler.vcxproj.filters b/src/RequestHandler/RequestHandler.vcxproj.filters
- index 1f80fca6966..351a29e5be0 100644
- --- a/src/RequestHandler/RequestHandler.vcxproj.filters
- +++ b/src/RequestHandler/RequestHandler.vcxproj.filters
- @@ -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>
- \ No newline at end of file
- diff --git a/src/RequestHandler/Resource.rc b/src/RequestHandler/Resource.rc
- deleted file mode 100644
- index caf820af68d..00000000000
- --- a/src/RequestHandler/Resource.rc
- +++ /dev/null
- @@ -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
- -
- diff --git a/src/RequestHandler/aspnetcore_msg.h b/src/RequestHandler/aspnetcore_msg.h
- deleted file mode 100644
- index f99bc990841..00000000000
- --- a/src/RequestHandler/aspnetcore_msg.h
- +++ /dev/null
- @@ -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_
- diff --git a/src/RequestHandler/aspnetcore_msg.rc b/src/RequestHandler/aspnetcore_msg.rc
- deleted file mode 100644
- index 0abcb0fa2c5..00000000000
- --- a/src/RequestHandler/aspnetcore_msg.rc
- +++ /dev/null
- @@ -1,2 +0,0 @@
- -LANGUAGE 0x9,0x1
- -1 11 "MSG00001.bin"
- diff --git a/src/RequestHandler/dllmain.cxx b/src/RequestHandler/dllmain.cxx
- index f4b476a8562..cd611265077 100644
- --- a/src/RequestHandler/dllmain.cxx
- +++ b/src/RequestHandler/dllmain.cxx
- @@ -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;
- + BOOL fLocked = FALSE;
- + DWORD dwSize = 0;
- + DWORD dwResult = 0;
-
- - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- - L"SOFTWARE\\Microsoft\\IIS Extensions\\IIS AspNetCore Module\\Parameters",
- - 0,
- - KEY_READ,
- - &hKey) == NO_ERROR)
- + if (!g_fGlobalInitialize)
- {
- - DWORD dwType;
- - DWORD dwData;
- - DWORD cbData;
- -
- - cbData = sizeof(dwData);
- - if ((RegQueryValueEx(hKey,
- - L"OptionalWinHttpFlags",
- - NULL,
- - &dwType,
- - (LPBYTE)&dwData,
- - &cbData) == NO_ERROR) &&
- - (dwType == REG_DWORD))
- + AcquireSRWLockExclusive(&g_srwLockRH);
- + fLocked = TRUE;
- +
- + if (g_fGlobalInitialize)
- {
- - g_OptionalWinHttpFlags = dwData;
- + // Done by another thread
- + goto Finished;
- }
-
- - cbData = sizeof(dwData);
- - if ((RegQueryValueEx(hKey,
- - L"EnableReferenceCountTracing",
- - NULL,
- - &dwType,
- - (LPBYTE)&dwData,
- - &cbData) == NO_ERROR) &&
- - (dwType == REG_DWORD) && (dwData == 1 || dwData == 0))
- + g_pHttpServer = pServer;
- + if (pServer->IsCommandLineLaunch())
- + {
- + g_hEventLog = RegisterEventSource(NULL, ASPNETCORE_IISEXPRESS_EVENT_PROVIDER);
- + }
- + else
- {
- - g_fEnableReferenceCountTracing = !!dwData;
- + g_hEventLog = RegisterEventSource(NULL, ASPNETCORE_EVENT_PROVIDER);
- }
-
- - cbData = sizeof(dwData);
- - if ((RegQueryValueEx(hKey,
- - L"DebugFlags",
- - NULL,
- - &dwType,
- - (LPBYTE)&dwData,
- - &cbData) == NO_ERROR) &&
- - (dwType == REG_DWORD))
- + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- + L"SOFTWARE\\Microsoft\\IIS Extensions\\IIS AspNetCore Module\\Parameters",
- + 0,
- + KEY_READ,
- + &hKey) == NO_ERROR)
- {
- - g_dwAspNetCoreDebugFlags = dwData;
- + 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);
- }
-
- - 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;
- + }
-
- - 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)
- + // WebSocket is supported on Win8 and above only
- + // todo: test on win7
- + g_fWebSocketSupported = IsWindows8OrGreater();
- +
- + g_fGlobalInitialize = TRUE;
- + }
- +Finished:
- + if (fLocked)
- {
- - g_fNsiApiNotSupported = TRUE;
- + 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;
- diff --git a/src/RequestHandler/inprocess/inprocessapplication.cpp b/src/RequestHandler/inprocess/inprocessapplication.cpp
- index 7259131ef99..690c8d48d46 100644
- --- a/src/RequestHandler/inprocess/inprocessapplication.cpp
- +++ b/src/RequestHandler/inprocess/inprocessapplication.cpp
- @@ -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();
- diff --git a/src/RequestHandler/outofprocess/processmanager.cxx b/src/RequestHandler/outofprocess/processmanager.cxx
- index 98ba30441fd..9c9ceb449d7 100644
- --- a/src/RequestHandler/outofprocess/processmanager.cxx
- +++ b/src/RequestHandler/outofprocess/processmanager.cxx
- @@ -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;
- -}
- \ No newline at end of file
- +}
- diff --git a/src/RequestHandler/outofprocess/serverprocess.cxx b/src/RequestHandler/outofprocess/serverprocess.cxx
- index 4c94331de92..97243d8bc27 100644
- --- a/src/RequestHandler/outofprocess/serverprocess.cxx
- +++ b/src/RequestHandler/outofprocess/serverprocess.cxx
- @@ -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());
- + }
- }
- -}
- \ No newline at end of file
- +}
- diff --git a/src/RequestHandler/precomp.hxx b/src/RequestHandler/precomp.hxx
- index a12c49cde91..42ee3e391b2 100644
- --- a/src/RequestHandler/precomp.hxx
- +++ b/src/RequestHandler/precomp.hxx
- @@ -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;
|