IISIntegration 831 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598
  1. commit 7b65bdb6ef4259d64f48c47529a8fd4f06c56bfe
  2. Author: pan-wang <[email protected]>
  3. Date: Tue Jan 16 17:21:47 2018 -0800
  4. Panwang/addinglog (#508)
  5. * adding windows event log
  6. * adding windows event log
  7. * fix a wrong bool variable
  8. * some updates
  9. * fix bad merge
  10. diff --git a/.gitignore b/.gitignore
  11. index 5004d81d9d5..58872165a31 100644
  12. --- a/.gitignore
  13. +++ b/.gitignore
  14. @@ -52,6 +52,8 @@ x64/
  15. src/AspNetCore/aspnetcore_msg.h
  16. src/AspNetCore/aspnetcore_msg.rc
  17. src/AspNetCore/version.h
  18. +src/CommonLib/aspnetcore_msg.h
  19. +src/CommonLib/aspnetcore_msg.rc
  20. .build
  21. *.VC.*db
  22. diff --git a/src/AspNetCore/AspNetCore.vcxproj b/src/AspNetCore/AspNetCore.vcxproj
  23. index 43acff071d8..687e528ecc4 100644
  24. --- a/src/AspNetCore/AspNetCore.vcxproj
  25. +++ b/src/AspNetCore/AspNetCore.vcxproj
  26. @@ -202,7 +202,6 @@
  27. <ClInclude Include="Inc\applicationinfo.h" />
  28. <ClInclude Include="Inc\appoffline.h" />
  29. <ClInclude Include="inc\globalmodule.h" />
  30. - <ClInclude Include="Inc\resource.h" />
  31. <ClInclude Include="Inc\applicationmanager.h" />
  32. <ClInclude Include="Inc\filewatcher.h" />
  33. <ClInclude Include="Inc\proxymodule.h" />
  34. diff --git a/src/AspNetCore/Src/applicationinfo.cpp b/src/AspNetCore/Src/applicationinfo.cpp
  35. index a80794d8501..1950860b855 100644
  36. --- a/src/AspNetCore/Src/applicationinfo.cpp
  37. +++ b/src/AspNetCore/Src/applicationinfo.cpp
  38. @@ -135,9 +135,21 @@ APPLICATION_INFO::UpdateAppOfflineFileHandle()
  39. // recycle the application
  40. if (m_pApplication != NULL)
  41. {
  42. + STACK_STRU(strEventMsg, 256);
  43. + if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  44. + ASPNETCORE_EVENT_RECYCLE_APPOFFLINE_MSG,
  45. + m_pApplication->QueryConfig()->QueryApplicationPath()->QueryStr())))
  46. + {
  47. + UTILITY::LogEvent(g_hEventLog,
  48. + EVENTLOG_INFORMATION_TYPE,
  49. + ASPNETCORE_EVENT_RECYCLE_APPOFFLINE,
  50. + strEventMsg.QueryStr());
  51. + }
  52. +
  53. m_pApplication->ShutDown();
  54. m_pApplication->DereferenceApplication();
  55. m_pApplication = NULL;
  56. +
  57. }
  58. }
  59. }
  60. diff --git a/src/AspNetCore/Src/applicationmanager.cxx b/src/AspNetCore/Src/applicationmanager.cxx
  61. index 094f1d5e1c4..4b1c9b6a712 100644
  62. --- a/src/AspNetCore/Src/applicationmanager.cxx
  63. +++ b/src/AspNetCore/Src/applicationmanager.cxx
  64. @@ -19,7 +19,6 @@ APPLICATION_MANAGER::GetApplicationInfo(
  65. BOOL fMixedHostingModelError = FALSE;
  66. BOOL fDuplicatedInProcessApp = FALSE;
  67. PCWSTR pszApplicationId = NULL;
  68. - LPCWSTR apsz[1];
  69. STACK_STRU ( strEventMsg, 256 );
  70. *ppApplicationInfo = NULL;
  71. @@ -153,42 +152,24 @@ Finished:
  72. ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP_MSG,
  73. pszApplicationId)))
  74. {
  75. - /*apsz[0] = strEventMsg.QueryStr();
  76. - if (FORWARDING_HANDLER::QueryEventLog() != NULL)
  77. - {
  78. - ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
  79. - EVENTLOG_ERROR_TYPE,
  80. - 0,
  81. - ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP,
  82. - NULL,
  83. - 1,
  84. - 0,
  85. - apsz,
  86. - NULL);
  87. - }*/
  88. + UTILITY::LogEvent(g_hEventLog,
  89. + EVENTLOG_ERROR_TYPE,
  90. + ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP,
  91. + strEventMsg.QueryStr());
  92. }
  93. }
  94. else if (fMixedHostingModelError)
  95. {
  96. - //if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  97. - // ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR_MSG,
  98. - // pszApplicationId,
  99. - // pConfig->QueryHostingModelStr())))
  100. - //{
  101. - // apsz[0] = strEventMsg.QueryStr();
  102. - // /*if (FORWARDING_HANDLER::QueryEventLog() != NULL)
  103. - // {
  104. - // ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
  105. - // EVENTLOG_ERROR_TYPE,
  106. - // 0,
  107. - // ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR,
  108. - // NULL,
  109. - // 1,
  110. - // 0,
  111. - // apsz,
  112. - // NULL);
  113. - // }*/
  114. - //}
  115. + if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  116. + ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR_MSG,
  117. + pszApplicationId,
  118. + pConfig->QueryHostingModel())))
  119. + {
  120. + UTILITY::LogEvent(g_hEventLog,
  121. + EVENTLOG_ERROR_TYPE,
  122. + ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR,
  123. + strEventMsg.QueryStr());
  124. + }
  125. }
  126. else
  127. {
  128. @@ -197,19 +178,10 @@ Finished:
  129. pszApplicationId,
  130. hr)))
  131. {
  132. - apsz[0] = strEventMsg.QueryStr();
  133. - /*if (FORWARDING_HANDLER::QueryEventLog() != NULL)
  134. - {
  135. - ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
  136. - EVENTLOG_ERROR_TYPE,
  137. - 0,
  138. - ASPNETCORE_EVENT_ADD_APPLICATION_ERROR,
  139. - NULL,
  140. - 1,
  141. - 0,
  142. - apsz,
  143. - NULL);
  144. - }*/
  145. + UTILITY::LogEvent(g_hEventLog,
  146. + EVENTLOG_ERROR_TYPE,
  147. + ASPNETCORE_EVENT_ADD_APPLICATION_ERROR,
  148. + strEventMsg.QueryStr());
  149. }
  150. }
  151. }
  152. diff --git a/src/AspNetCore/Src/dllmain.cpp b/src/AspNetCore/Src/dllmain.cpp
  153. index 9b6a5b933b7..83b63d6ea8e 100644
  154. --- a/src/AspNetCore/Src/dllmain.cpp
  155. +++ b/src/AspNetCore/Src/dllmain.cpp
  156. @@ -6,6 +6,7 @@
  157. HTTP_MODULE_ID g_pModuleId = NULL;
  158. IHttpServer * g_pHttpServer = NULL;
  159. +HANDLE g_hEventLog = NULL;
  160. BOOL g_fRecycleProcessCalled = FALSE;
  161. PCWSTR g_pszModuleName = NULL;
  162. HINSTANCE g_hModule;
  163. @@ -25,6 +26,11 @@ VOID
  164. StaticCleanup()
  165. {
  166. APPLICATION_MANAGER::Cleanup();
  167. + if (g_hEventLog != NULL)
  168. + {
  169. + DeregisterEventSource(g_hEventLog);
  170. + g_hEventLog = NULL;
  171. + }
  172. }
  173. BOOL WINAPI DllMain(HMODULE hModule,
  174. @@ -100,6 +106,15 @@ HRESULT
  175. g_pszModuleName = pModuleInfo->GetName();
  176. g_pHttpServer = pHttpServer;
  177. + if (g_pHttpServer->IsCommandLineLaunch())
  178. + {
  179. + g_hEventLog = RegisterEventSource(NULL, ASPNETCORE_IISEXPRESS_EVENT_PROVIDER);
  180. + }
  181. + else
  182. + {
  183. + g_hEventLog = RegisterEventSource(NULL, ASPNETCORE_EVENT_PROVIDER);
  184. + }
  185. +
  186. // check whether the feature is disabled due to security reason
  187. if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  188. L"SOFTWARE\\Microsoft\\IIS Extensions\\IIS AspNetCore Module\\Parameters",
  189. @@ -127,6 +142,17 @@ HRESULT
  190. if (fDisableANCM)
  191. {
  192. // Logging
  193. + STACK_STRU(strEventMsg, 256);
  194. + if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  195. + ASPNETCORE_EVENT_MODULE_DISABLED_MSG)))
  196. + {
  197. + UTILITY::LogEvent(g_hEventLog,
  198. + EVENTLOG_WARNING_TYPE,
  199. + ASPNETCORE_EVENT_MODULE_DISABLED,
  200. + strEventMsg.QueryStr());
  201. + }
  202. + // this will return 500 error to client
  203. + // as we did not register the module
  204. goto Finished;
  205. }
  206. diff --git a/src/AspNetCore/Src/precomp.hxx b/src/AspNetCore/Src/precomp.hxx
  207. index 4ef797ec6ae..e8f9f0007ee 100644
  208. --- a/src/AspNetCore/Src/precomp.hxx
  209. +++ b/src/AspNetCore/Src/precomp.hxx
  210. @@ -108,14 +108,14 @@ inline bool IsSpace(char ch)
  211. #include "..\..\CommonLib\utility.h"
  212. #include "..\..\CommonLib\debugutil.h"
  213. #include "..\..\CommonLib\requesthandler.h"
  214. -//#include "..\aspnetcore_msg.h"
  215. +#include "..\..\CommonLib\resources.h"
  216. +#include "..\..\CommonLib\aspnetcore_msg.h"
  217. //#include "aspnetcore_event.h"
  218. #include "appoffline.h"
  219. #include "filewatcher.h"
  220. #include "applicationinfo.h"
  221. #include "applicationmanager.h"
  222. #include "globalmodule.h"
  223. -#include "resource.h"
  224. #include "proxymodule.h"
  225. #include "applicationinfo.h"
  226. @@ -152,7 +152,7 @@ extern HINSTANCE g_hModule;
  227. extern HMODULE g_hAspnetCoreRH;
  228. extern SRWLOCK g_srwLock;
  229. extern PCWSTR g_pwzAspnetcoreRequestHandlerName;
  230. -
  231. +extern HANDLE g_hEventLog;
  232. extern PFN_ASPNETCORE_CREATE_APPLICATION g_pfnAspNetCoreCreateApplication;
  233. extern PFN_ASPNETCORE_CREATE_REQUEST_HANDLER g_pfnAspNetCoreCreateRequestHandler;
  234. #pragma warning( error : 4091)
  235. diff --git a/src/CommonLib/CommonLib.vcxproj b/src/CommonLib/CommonLib.vcxproj
  236. index 1d5907222ee..3a72db72e7e 100644
  237. --- a/src/CommonLib/CommonLib.vcxproj
  238. +++ b/src/CommonLib/CommonLib.vcxproj
  239. @@ -177,6 +177,7 @@
  240. <ClInclude Include="fx_ver.h" />
  241. <ClInclude Include="hostfxr_utility.h" />
  242. <ClInclude Include="requesthandler.h" />
  243. + <ClInclude Include="resources.h" />
  244. <ClInclude Include="stdafx.h" />
  245. <ClInclude Include="utility.h" />
  246. </ItemGroup>
  247. @@ -199,6 +200,23 @@
  248. <Project>{4787a64f-9a3e-4867-a55a-70cb4b2b2ffe}</Project>
  249. </ProjectReference>
  250. </ItemGroup>
  251. + <ItemGroup>
  252. + <CustomBuild Include="aspnetcore_msg.mc">
  253. + <FileType>Document</FileType>
  254. + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">mc %(FullPath)</Command>
  255. + <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compiling Event Messages ...</Message>
  256. + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).rc;%(Filename).h;MSG0409.bin</Outputs>
  257. + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">mc %(FullPath)</Command>
  258. + <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compiling Event Messages ...</Message>
  259. + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).rc;%(Filename).h;MSG0409.bin</Outputs>
  260. + <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">mc %(FullPath)</Command>
  261. + <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compiling Event Messages ...</Message>
  262. + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).rc;%(Filename).h;MSG0409.bin</Outputs>
  263. + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">mc %(FullPath)</Command>
  264. + <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compiling Event Messages ...</Message>
  265. + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).rc;%(Filename).h;MSG0409.bin</Outputs>
  266. + </CustomBuild>
  267. + </ItemGroup>
  268. <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  269. <ImportGroup Label="ExtensionTargets">
  270. </ImportGroup>
  271. diff --git a/src/RequestHandler/aspnetcore_msg.mc b/src/CommonLib/aspnetcore_msg.mc
  272. similarity index 90%
  273. rename from src/RequestHandler/aspnetcore_msg.mc
  274. rename to src/CommonLib/aspnetcore_msg.mc
  275. index ae8eec4e88c..bcd125850f7 100644
  276. --- a/src/RequestHandler/aspnetcore_msg.mc
  277. +++ b/src/CommonLib/aspnetcore_msg.mc
  278. @@ -98,6 +98,18 @@ Language=English
  279. %1
  280. .
  281. +Messageid=1012
  282. +SymbolicName=ASPNETCORE_EVENT_RECYCLE_APPOFFLINE
  283. +Language=English
  284. +%1
  285. +.
  286. +
  287. +Messageid=1013
  288. +SymbolicName=ASPNETCORE_EVENT_MODULE_DISABLED
  289. +Language=English
  290. +%1
  291. +.
  292. +
  293. ;
  294. ;#endif // _ASPNETCORE_MODULE_MSG_H_
  295. -;
  296. \ No newline at end of file
  297. +;
  298. diff --git a/src/RequestHandler/resource.h b/src/CommonLib/resources.h
  299. similarity index 80%
  300. rename from src/RequestHandler/resource.h
  301. rename to src/CommonLib/resources.h
  302. index a8f93c62fba..938922d1499 100644
  303. --- a/src/RequestHandler/resource.h
  304. +++ b/src/CommonLib/resources.h
  305. @@ -6,12 +6,15 @@
  306. #define IDS_INVALID_PROPERTY 1000
  307. #define IDS_SERVER_ERROR 1001
  308. +#define ASPNETCORE_EVENT_PROVIDER L"IIS AspNetCore Module"
  309. +#define ASPNETCORE_IISEXPRESS_EVENT_PROVIDER L"IIS Express AspNetCore Module"
  310. +
  311. #define ASPNETCORE_EVENT_MSG_BUFFER_SIZE 256
  312. #define ASPNETCORE_EVENT_PROCESS_START_SUCCESS_MSG L"Application '%s' started process '%d' successfully and is listening on port '%d'."
  313. #define ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED_MSG L"Maximum rapid fail count per minute of '%d' exceeded."
  314. #define ASPNETCORE_EVENT_PROCESS_START_INTERNAL_ERROR_MSG L"Application '%s' failed to parse processPath and arguments due to internal error, ErrorCode = '0x%x'."
  315. -#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'."
  316. -#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'."
  317. +#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'."
  318. +#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'."
  319. #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'"
  320. #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'"
  321. #define ASPNETCORE_EVENT_INVALID_STDOUT_LOG_FILE_MSG L"Warning: Could not create stdoutLogFile %s, ErrorCode = %d."
  322. @@ -19,6 +22,8 @@
  323. #define ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST_MSG L"Sent shutdown HTTP message to process '%d' and received http status '%d'."
  324. #define ASPNETCORE_EVENT_LOAD_CLR_FALIURE_MSG L"Application '%s' with physical root '%s' failed to load clr and managed application, ErrorCode = '0x%x."
  325. #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."
  326. -#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)."
  327. +#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)."
  328. #define ASPNETCORE_EVENT_ADD_APPLICATION_ERROR_MSG L"Failed to start application '%s', ErrorCode '0x%x'."
  329. -#define ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_MSG L"Application '%s' with physical root '%s' hit unexpected managed background thread exit, ErrorCode = '0x%x."
  330. +#define ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_MSG L"Application '%s' with physical root '%s' hit unexpected managed background thread eixt, ErrorCode = '0x%x."
  331. +#define ASPNETCORE_EVENT_RECYCLE_APPOFFLINE_MSG L"Application '%s' is recycled due to app_offline file was detected."
  332. +#define ASPNETCORE_EVENT_MODULE_DISABLED_MSG L"AspNetCore Module is disabled"
  333. diff --git a/src/CommonLib/utility.cxx b/src/CommonLib/utility.cxx
  334. index a642ec1c9f3..b4dd25a9e5b 100644
  335. --- a/src/CommonLib/utility.cxx
  336. +++ b/src/CommonLib/utility.cxx
  337. @@ -599,3 +599,31 @@ UTILITY::CheckIfFileExists(
  338. return fFileExists;
  339. }
  340. +
  341. +VOID
  342. +UTILITY::LogEvent(
  343. + _In_ HANDLE hEventLog,
  344. + _In_ WORD dwEventInfoType,
  345. + _In_ DWORD dwEventId,
  346. + _In_ LPCWSTR pstrMsg
  347. +)
  348. +{
  349. + if (hEventLog != NULL)
  350. + {
  351. + ReportEventW(hEventLog,
  352. + dwEventInfoType,
  353. + 0, // wCategory
  354. + dwEventId,
  355. + NULL, // lpUserSid
  356. + 1, // wNumStrings
  357. + 0, // dwDataSize,
  358. + &pstrMsg,
  359. + NULL // lpRawData
  360. + );
  361. + }
  362. +
  363. + if (dwEventInfoType == EVENTLOG_ERROR_TYPE)
  364. + {
  365. + fwprintf(stderr, L"ERROR: %s\n", pstrMsg);
  366. + }
  367. +}
  368. \ No newline at end of file
  369. diff --git a/src/CommonLib/utility.h b/src/CommonLib/utility.h
  370. index 5f4ae39026e..49549c0f336 100644
  371. --- a/src/CommonLib/utility.h
  372. +++ b/src/CommonLib/utility.h
  373. @@ -111,8 +111,17 @@ public:
  374. PCWSTR pszFilePath
  375. );
  376. + static
  377. + VOID
  378. + LogEvent(
  379. + _In_ HANDLE hEventLog,
  380. + _In_ WORD dwEventInfoType,
  381. + _In_ DWORD dwEventId,
  382. + _In_ LPCWSTR pstrMsg
  383. + );
  384. +
  385. private:
  386. UTILITY() {}
  387. ~UTILITY() {}
  388. -};
  389. \ No newline at end of file
  390. +};
  391. diff --git a/src/RequestHandler/RequestHandler.rc b/src/RequestHandler/RequestHandler.rc
  392. deleted file mode 100644
  393. index 6d285329154..00000000000
  394. Binary files a/src/RequestHandler/RequestHandler.rc and /dev/null differ
  395. diff --git a/src/RequestHandler/RequestHandler.vcxproj b/src/RequestHandler/RequestHandler.vcxproj
  396. index 5d003d4120a..a214f87bcec 100644
  397. --- a/src/RequestHandler/RequestHandler.vcxproj
  398. +++ b/src/RequestHandler/RequestHandler.vcxproj
  399. @@ -201,7 +201,7 @@
  400. </ItemDefinitionGroup>
  401. <ItemGroup>
  402. <ClInclude Include="aspnetcore_event.h" />
  403. - <ClInclude Include="aspnetcore_msg.h" />
  404. + <ClInclude Include="disconnectcontext.h" />
  405. <ClInclude Include="sttimer.h" />
  406. <ClInclude Include="outofprocess\forwarderconnection.h" />
  407. <ClInclude Include="outofprocess\processmanager.h" />
  408. @@ -211,7 +211,6 @@
  409. <ClInclude Include="outofprocess\websockethandler.h" />
  410. <ClInclude Include="outofprocess\winhttphelper.h" />
  411. <ClInclude Include="precomp.hxx" />
  412. - <ClInclude Include="resource.h" />
  413. <ClInclude Include=".\inprocess\inprocessapplication.h" />
  414. <ClInclude Include=".\inprocess\inprocesshandler.h" />
  415. <ClInclude Include=".\outofprocess\forwardinghandler.h" />
  416. @@ -232,23 +231,6 @@
  417. <ClCompile Include="outofprocess\websockethandler.cxx" />
  418. <ClCompile Include="outofprocess\winhttphelper.cxx" />
  419. </ItemGroup>
  420. - <ItemGroup>
  421. - <CustomBuild Include="aspnetcore_msg.mc">
  422. - <FileType>Document</FileType>
  423. - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">mc %(FullPath)</Command>
  424. - <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compiling Event Messages ...</Message>
  425. - <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).rc;%(Filename).h;MSG0409.bin</Outputs>
  426. - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">mc %(FullPath)</Command>
  427. - <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compiling Event Messages ...</Message>
  428. - <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).rc;%(Filename).h;MSG0409.bin</Outputs>
  429. - <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">mc %(FullPath)</Command>
  430. - <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compiling Event Messages ...</Message>
  431. - <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).rc;%(Filename).h;MSG0409.bin</Outputs>
  432. - <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">mc %(FullPath)</Command>
  433. - <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compiling Event Messages ...</Message>
  434. - <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).rc;%(Filename).h;MSG0409.bin</Outputs>
  435. - </CustomBuild>
  436. - </ItemGroup>
  437. <ItemGroup>
  438. <ProjectReference Include="..\CommonLib\CommonLib.vcxproj">
  439. <Project>{55494e58-e061-4c4c-a0a8-837008e72f85}</Project>
  440. @@ -257,9 +239,6 @@
  441. <Project>{4787a64f-9a3e-4867-a55a-70cb4b2b2ffe}</Project>
  442. </ProjectReference>
  443. </ItemGroup>
  444. - <ItemGroup>
  445. - <ResourceCompile Include="RequestHandler.rc" />
  446. - </ItemGroup>
  447. <ItemGroup>
  448. <None Include="Source.def" />
  449. </ItemGroup>
  450. diff --git a/src/RequestHandler/RequestHandler.vcxproj.filters b/src/RequestHandler/RequestHandler.vcxproj.filters
  451. index 1f80fca6966..351a29e5be0 100644
  452. --- a/src/RequestHandler/RequestHandler.vcxproj.filters
  453. +++ b/src/RequestHandler/RequestHandler.vcxproj.filters
  454. @@ -41,7 +41,6 @@
  455. </ItemGroup>
  456. <ItemGroup>
  457. <ClInclude Include="precomp.hxx" />
  458. - <ClInclude Include="resource.h" />
  459. <ClInclude Include=".\inprocess\inprocessapplication.h">
  460. <Filter>InProcess</Filter>
  461. </ClInclude>
  462. @@ -80,7 +79,6 @@
  463. </ClInclude>
  464. <ClInclude Include="aspnetcore_event.h" />
  465. <ClInclude Include="sttimer.h" />
  466. - <ClInclude Include="aspnetcore_msg.h" />
  467. </ItemGroup>
  468. <ItemGroup>
  469. <ResourceCompile Include="RequestHandler.rc" />
  470. @@ -102,7 +100,4 @@
  471. <UniqueIdentifier>{5568209f-269e-4d0a-bbb7-ba14f874ccb7}</UniqueIdentifier>
  472. </Filter>
  473. </ItemGroup>
  474. - <ItemGroup>
  475. - <CustomBuild Include="aspnetcore_msg.mc" />
  476. - </ItemGroup>
  477. </Project>
  478. \ No newline at end of file
  479. diff --git a/src/RequestHandler/Resource.rc b/src/RequestHandler/Resource.rc
  480. deleted file mode 100644
  481. index caf820af68d..00000000000
  482. --- a/src/RequestHandler/Resource.rc
  483. +++ /dev/null
  484. @@ -1,98 +0,0 @@
  485. -// Microsoft Visual C++ generated resource script.
  486. -//
  487. -#include "resource.h"
  488. -#include "version.h"
  489. -
  490. -#define APSTUDIO_READONLY_SYMBOLS
  491. -/////////////////////////////////////////////////////////////////////////////
  492. -//
  493. -// Generated from the TEXTINCLUDE 2 resource.
  494. -//
  495. -#include "winres.h"
  496. -
  497. -/////////////////////////////////////////////////////////////////////////////
  498. -#undef APSTUDIO_READONLY_SYMBOLS
  499. -
  500. -/////////////////////////////////////////////////////////////////////////////
  501. -// English (United States) resources
  502. -
  503. -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
  504. -LANGUAGE 9, 1
  505. -
  506. -#ifdef APSTUDIO_INVOKED
  507. -/////////////////////////////////////////////////////////////////////////////
  508. -//
  509. -// TEXTINCLUDE
  510. -//
  511. -
  512. -1 TEXTINCLUDE
  513. -BEGIN
  514. - "resource.h\0"
  515. -END
  516. -
  517. -2 TEXTINCLUDE
  518. -BEGIN
  519. - "#include ""winres.h""\r\n"
  520. - "\0"
  521. -END
  522. -
  523. -3 TEXTINCLUDE
  524. -BEGIN
  525. - "\r\n"
  526. - "\0"
  527. -END
  528. -
  529. -#endif // APSTUDIO_INVOKED
  530. -
  531. -#endif // English (United States) resources
  532. -/////////////////////////////////////////////////////////////////////////////
  533. -
  534. -/////////////////////////////////////////////////////////////////////////////
  535. -//
  536. -// Version
  537. -//
  538. -
  539. -VS_VERSION_INFO VERSIONINFO
  540. -FILEVERSION FileVersion
  541. -PRODUCTVERSION ProductVersion
  542. -FILEFLAGSMASK 0x3fL
  543. -#ifdef _DEBUG
  544. -FILEFLAGS 0x1L
  545. -#else
  546. -FILEFLAGS 0x0L
  547. -#endif
  548. -FILEOS 0x40004L
  549. -FILETYPE 0x2L
  550. -FILESUBTYPE 0x0L
  551. -BEGIN
  552. -BLOCK "StringFileInfo"
  553. -BEGIN
  554. -BLOCK "040904b0"
  555. -BEGIN
  556. -VALUE "CompanyName", "Microsoft"
  557. -VALUE "FileDescription", "IIS ASP.NET Core Module Request Handler"
  558. -VALUE "FileVersion", FileVersionStr
  559. -VALUE "InternalName", "aspnetcorerh.dll"
  560. -VALUE "LegalCopyright", "Copyright (C) 2016"
  561. -VALUE "OriginalFilename", "aspnetcorerh.dll"
  562. -VALUE "ProductName", "ASP.NET Core Module"
  563. -VALUE "ProductVersion", ProductVersionStr
  564. -END
  565. -END
  566. -BLOCK "VarFileInfo"
  567. -BEGIN
  568. -VALUE "Translation", 0x409, 1200
  569. -END
  570. -END
  571. -
  572. -
  573. -#ifndef APSTUDIO_INVOKED
  574. -/////////////////////////////////////////////////////////////////////////////
  575. -//
  576. -// Generated from the TEXTINCLUDE 3 resource.
  577. -//
  578. -
  579. -
  580. -/////////////////////////////////////////////////////////////////////////////
  581. -#endif // not APSTUDIO_INVOKED
  582. -
  583. diff --git a/src/RequestHandler/aspnetcore_msg.h b/src/RequestHandler/aspnetcore_msg.h
  584. deleted file mode 100644
  585. index f99bc990841..00000000000
  586. --- a/src/RequestHandler/aspnetcore_msg.h
  587. +++ /dev/null
  588. @@ -1,165 +0,0 @@
  589. -/*++
  590. -
  591. - Copyright (c) .NET Foundation. All rights reserved.
  592. - Licensed under the MIT License. See License.txt in the project root for license information.
  593. -
  594. -Module Name:
  595. -
  596. - aspnetcore_msg.mc
  597. -
  598. -Abstract:
  599. -
  600. - Asp.Net Core Module localizable messages.
  601. -
  602. ---*/
  603. -
  604. -
  605. -#ifndef _ASPNETCORE_MSG_H_
  606. -#define _ASPNETCORE_MSG_H_
  607. -
  608. -//
  609. -// Values are 32 bit values laid out as follows:
  610. -//
  611. -// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  612. -// 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
  613. -// +---+-+-+-----------------------+-------------------------------+
  614. -// |Sev|C|R| Facility | Code |
  615. -// +---+-+-+-----------------------+-------------------------------+
  616. -//
  617. -// where
  618. -//
  619. -// Sev - is the severity code
  620. -//
  621. -// 00 - Success
  622. -// 01 - Informational
  623. -// 10 - Warning
  624. -// 11 - Error
  625. -//
  626. -// C - is the Customer code flag
  627. -//
  628. -// R - is a reserved bit
  629. -//
  630. -// Facility - is the facility code
  631. -//
  632. -// Code - is the facility's status code
  633. -//
  634. -//
  635. -// Define the facility codes
  636. -//
  637. -
  638. -
  639. -//
  640. -// Define the severity codes
  641. -//
  642. -
  643. -
  644. -//
  645. -// MessageId: ASPNETCORE_EVENT_PROCESS_START_ERROR
  646. -//
  647. -// MessageText:
  648. -//
  649. -// %1
  650. -//
  651. -#define ASPNETCORE_EVENT_PROCESS_START_ERROR ((DWORD)0x000003E8L)
  652. -
  653. -//
  654. -// MessageId: ASPNETCORE_EVENT_PROCESS_START_SUCCESS
  655. -//
  656. -// MessageText:
  657. -//
  658. -// %1
  659. -//
  660. -#define ASPNETCORE_EVENT_PROCESS_START_SUCCESS ((DWORD)0x000003E9L)
  661. -
  662. -//
  663. -// MessageId: ASPNETCORE_EVENT_PROCESS_CRASH
  664. -//
  665. -// MessageText:
  666. -//
  667. -// %1
  668. -//
  669. -#define ASPNETCORE_EVENT_PROCESS_CRASH ((DWORD)0x000003EAL)
  670. -
  671. -//
  672. -// MessageId: ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED
  673. -//
  674. -// MessageText:
  675. -//
  676. -// %1
  677. -//
  678. -#define ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED ((DWORD)0x000003EBL)
  679. -
  680. -//
  681. -// MessageId: ASPNETCORE_EVENT_CONFIG_ERROR
  682. -//
  683. -// MessageText:
  684. -//
  685. -// %1
  686. -//
  687. -#define ASPNETCORE_EVENT_CONFIG_ERROR ((DWORD)0x000003ECL)
  688. -
  689. -//
  690. -// MessageId: ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE
  691. -//
  692. -// MessageText:
  693. -//
  694. -// %1
  695. -//
  696. -#define ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE ((DWORD)0x000003EDL)
  697. -
  698. -//
  699. -// MessageId: ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST
  700. -//
  701. -// MessageText:
  702. -//
  703. -// %1
  704. -//
  705. -#define ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST ((DWORD)0x000003EEL)
  706. -
  707. -//
  708. -// MessageId: ASPNETCORE_EVENT_LOAD_CLR_FALIURE
  709. -//
  710. -// MessageText:
  711. -//
  712. -// %1
  713. -//
  714. -#define ASPNETCORE_EVENT_LOAD_CLR_FALIURE ((DWORD)0x000003EFL)
  715. -
  716. -//
  717. -// MessageId: ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP
  718. -//
  719. -// MessageText:
  720. -//
  721. -// %1
  722. -//
  723. -#define ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP ((DWORD)0x000003F0L)
  724. -
  725. -//
  726. -// MessageId: ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR
  727. -//
  728. -// MessageText:
  729. -//
  730. -// %1
  731. -//
  732. -#define ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR ((DWORD)0x000003F1L)
  733. -
  734. -//
  735. -// MessageId: ASPNETCORE_EVENT_ADD_APPLICATION_ERROR
  736. -//
  737. -// MessageText:
  738. -//
  739. -// %1
  740. -//
  741. -#define ASPNETCORE_EVENT_ADD_APPLICATION_ERROR ((DWORD)0x000003F2L)
  742. -
  743. -//
  744. -// MessageId: ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT
  745. -//
  746. -// MessageText:
  747. -//
  748. -// %1
  749. -//
  750. -#define ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT ((DWORD)0x000003F3L)
  751. -
  752. -
  753. -#endif // _ASPNETCORE_MODULE_MSG_H_
  754. diff --git a/src/RequestHandler/aspnetcore_msg.rc b/src/RequestHandler/aspnetcore_msg.rc
  755. deleted file mode 100644
  756. index 0abcb0fa2c5..00000000000
  757. --- a/src/RequestHandler/aspnetcore_msg.rc
  758. +++ /dev/null
  759. @@ -1,2 +0,0 @@
  760. -LANGUAGE 0x9,0x1
  761. -1 11 "MSG00001.bin"
  762. diff --git a/src/RequestHandler/dllmain.cxx b/src/RequestHandler/dllmain.cxx
  763. index f4b476a8562..cd611265077 100644
  764. --- a/src/RequestHandler/dllmain.cxx
  765. +++ b/src/RequestHandler/dllmain.cxx
  766. @@ -6,6 +6,7 @@
  767. BOOL g_fNsiApiNotSupported = FALSE;
  768. BOOL g_fWebSocketSupported = FALSE;
  769. BOOL g_fEnableReferenceCountTracing = FALSE;
  770. +BOOL g_fGlobalInitialize = FALSE;
  771. BOOL g_fOutOfProcessInitialize = FALSE;
  772. BOOL g_fOutOfProcessInitializeError = FALSE;
  773. BOOL g_fWinHttpNonBlockingCallbackAvailable = FALSE;
  774. @@ -17,87 +18,117 @@ SRWLOCK g_srwLockRH;
  775. HINTERNET g_hWinhttpSession = NULL;
  776. IHttpServer * g_pHttpServer = NULL;
  777. HINSTANCE g_hWinHttpModule;
  778. +HANDLE g_hEventLog = NULL;
  779. VOID
  780. InitializeGlobalConfiguration(
  781. - VOID
  782. + IHttpServer * pServer
  783. )
  784. {
  785. HKEY hKey;
  786. + BOOL fLocked = FALSE;
  787. + DWORD dwSize = 0;
  788. + DWORD dwResult = 0;
  789. - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  790. - L"SOFTWARE\\Microsoft\\IIS Extensions\\IIS AspNetCore Module\\Parameters",
  791. - 0,
  792. - KEY_READ,
  793. - &hKey) == NO_ERROR)
  794. + if (!g_fGlobalInitialize)
  795. {
  796. - DWORD dwType;
  797. - DWORD dwData;
  798. - DWORD cbData;
  799. -
  800. - cbData = sizeof(dwData);
  801. - if ((RegQueryValueEx(hKey,
  802. - L"OptionalWinHttpFlags",
  803. - NULL,
  804. - &dwType,
  805. - (LPBYTE)&dwData,
  806. - &cbData) == NO_ERROR) &&
  807. - (dwType == REG_DWORD))
  808. + AcquireSRWLockExclusive(&g_srwLockRH);
  809. + fLocked = TRUE;
  810. +
  811. + if (g_fGlobalInitialize)
  812. {
  813. - g_OptionalWinHttpFlags = dwData;
  814. + // Done by another thread
  815. + goto Finished;
  816. }
  817. - cbData = sizeof(dwData);
  818. - if ((RegQueryValueEx(hKey,
  819. - L"EnableReferenceCountTracing",
  820. - NULL,
  821. - &dwType,
  822. - (LPBYTE)&dwData,
  823. - &cbData) == NO_ERROR) &&
  824. - (dwType == REG_DWORD) && (dwData == 1 || dwData == 0))
  825. + g_pHttpServer = pServer;
  826. + if (pServer->IsCommandLineLaunch())
  827. + {
  828. + g_hEventLog = RegisterEventSource(NULL, ASPNETCORE_IISEXPRESS_EVENT_PROVIDER);
  829. + }
  830. + else
  831. {
  832. - g_fEnableReferenceCountTracing = !!dwData;
  833. + g_hEventLog = RegisterEventSource(NULL, ASPNETCORE_EVENT_PROVIDER);
  834. }
  835. - cbData = sizeof(dwData);
  836. - if ((RegQueryValueEx(hKey,
  837. - L"DebugFlags",
  838. - NULL,
  839. - &dwType,
  840. - (LPBYTE)&dwData,
  841. - &cbData) == NO_ERROR) &&
  842. - (dwType == REG_DWORD))
  843. + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  844. + L"SOFTWARE\\Microsoft\\IIS Extensions\\IIS AspNetCore Module\\Parameters",
  845. + 0,
  846. + KEY_READ,
  847. + &hKey) == NO_ERROR)
  848. {
  849. - g_dwAspNetCoreDebugFlags = dwData;
  850. + DWORD dwType;
  851. + DWORD dwData;
  852. + DWORD cbData;
  853. +
  854. + cbData = sizeof(dwData);
  855. + if ((RegQueryValueEx(hKey,
  856. + L"OptionalWinHttpFlags",
  857. + NULL,
  858. + &dwType,
  859. + (LPBYTE)&dwData,
  860. + &cbData) == NO_ERROR) &&
  861. + (dwType == REG_DWORD))
  862. + {
  863. + g_OptionalWinHttpFlags = dwData;
  864. + }
  865. +
  866. + cbData = sizeof(dwData);
  867. + if ((RegQueryValueEx(hKey,
  868. + L"EnableReferenceCountTracing",
  869. + NULL,
  870. + &dwType,
  871. + (LPBYTE)&dwData,
  872. + &cbData) == NO_ERROR) &&
  873. + (dwType == REG_DWORD) && (dwData == 1 || dwData == 0))
  874. + {
  875. + g_fEnableReferenceCountTracing = !!dwData;
  876. + }
  877. +
  878. + cbData = sizeof(dwData);
  879. + if ((RegQueryValueEx(hKey,
  880. + L"DebugFlags",
  881. + NULL,
  882. + &dwType,
  883. + (LPBYTE)&dwData,
  884. + &cbData) == NO_ERROR) &&
  885. + (dwType == REG_DWORD))
  886. + {
  887. + g_dwAspNetCoreDebugFlags = dwData;
  888. + }
  889. + RegCloseKey(hKey);
  890. }
  891. - RegCloseKey(hKey);
  892. - }
  893. + dwResult = GetExtendedTcpTable(NULL,
  894. + &dwSize,
  895. + FALSE,
  896. + AF_INET,
  897. + TCP_TABLE_OWNER_PID_LISTENER,
  898. + 0);
  899. + if (dwResult != NO_ERROR && dwResult != ERROR_INSUFFICIENT_BUFFER)
  900. + {
  901. + g_fNsiApiNotSupported = TRUE;
  902. + }
  903. - DWORD dwSize = 0;
  904. - DWORD dwResult = GetExtendedTcpTable(NULL,
  905. - &dwSize,
  906. - FALSE,
  907. - AF_INET,
  908. - TCP_TABLE_OWNER_PID_LISTENER,
  909. - 0);
  910. - if (dwResult != NO_ERROR && dwResult != ERROR_INSUFFICIENT_BUFFER)
  911. + // WebSocket is supported on Win8 and above only
  912. + // todo: test on win7
  913. + g_fWebSocketSupported = IsWindows8OrGreater();
  914. +
  915. + g_fGlobalInitialize = TRUE;
  916. + }
  917. +Finished:
  918. + if (fLocked)
  919. {
  920. - g_fNsiApiNotSupported = TRUE;
  921. + ReleaseSRWLockExclusive(&g_srwLockRH);
  922. }
  923. -
  924. - // WebSocket is supported on Win8 and above only
  925. - // todo: test on win7
  926. - g_fWebSocketSupported = IsWindows8OrGreater();
  927. -
  928. }
  929. //
  930. // Global initialization routine for OutOfProcess
  931. //
  932. HRESULT
  933. -EnsureOutOfProcessInitializtion( IHttpServer* pServer)
  934. +EnsureOutOfProcessInitializtion()
  935. {
  936. DBG_ASSERT(pServer);
  937. @@ -105,13 +136,12 @@ EnsureOutOfProcessInitializtion( IHttpServer* pServer)
  938. HRESULT hr = S_OK;
  939. BOOL fLocked = FALSE;
  940. - g_pHttpServer = pServer;
  941. -
  942. if (g_fOutOfProcessInitializeError)
  943. {
  944. hr = E_NOT_VALID_STATE;
  945. goto Finished;
  946. }
  947. +
  948. if (!g_fOutOfProcessInitialize)
  949. {
  950. AcquireSRWLockExclusive(&g_srwLockRH);
  951. @@ -128,9 +158,6 @@ EnsureOutOfProcessInitializtion( IHttpServer* pServer)
  952. goto Finished;
  953. }
  954. - // Initialze some global variables here
  955. - InitializeGlobalConfiguration();
  956. -
  957. g_hWinHttpModule = GetModuleHandle(TEXT("winhttp.dll"));
  958. hr = WINHTTP_HELPER::StaticInitialize();
  959. @@ -197,7 +224,6 @@ EnsureOutOfProcessInitializtion( IHttpServer* pServer)
  960. goto Finished;
  961. }
  962. -
  963. hr = FORWARDING_HANDLER::StaticInitialize(g_fEnableReferenceCountTracing);
  964. if (FAILED(hr))
  965. {
  966. @@ -235,8 +261,6 @@ BOOL APIENTRY DllMain(HMODULE hModule,
  967. case DLL_PROCESS_ATTACH:
  968. DisableThreadLibraryCalls(hModule);
  969. InitializeSRWLock(&g_srwLockRH);
  970. - // Initialze some global variables here
  971. - InitializeGlobalConfiguration();
  972. break;
  973. default:
  974. break;
  975. @@ -255,7 +279,8 @@ CreateApplication(
  976. HRESULT hr = S_OK;
  977. APPLICATION *pApplication = NULL;
  978. - //REQUEST_HANDLER::StaticInitialize(pServer);
  979. + // Initialze some global variables here
  980. + InitializeGlobalConfiguration(pServer);
  981. if (pConfig->QueryHostingModel() == APP_HOSTING_MODEL::HOSTING_IN_PROCESS)
  982. {
  983. @@ -268,7 +293,7 @@ CreateApplication(
  984. }
  985. else if (pConfig->QueryHostingModel() == APP_HOSTING_MODEL::HOSTING_OUT_PROCESS)
  986. {
  987. - hr = EnsureOutOfProcessInitializtion(pServer);
  988. + hr = EnsureOutOfProcessInitializtion();
  989. if (FAILED(hr))
  990. {
  991. goto Finished;
  992. diff --git a/src/RequestHandler/inprocess/inprocessapplication.cpp b/src/RequestHandler/inprocess/inprocessapplication.cpp
  993. index 7259131ef99..690c8d48d46 100644
  994. --- a/src/RequestHandler/inprocess/inprocessapplication.cpp
  995. +++ b/src/RequestHandler/inprocess/inprocessapplication.cpp
  996. @@ -343,33 +343,17 @@ Finished:
  997. }
  998. if (FAILED(hr) && m_pConfig->QueryStdoutLogEnabled())
  999. {
  1000. - //todo log an warning
  1001. - //STRU strEventMsg;
  1002. - //LPCWSTR apsz[1];
  1003. -
  1004. - //if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  1005. - // ASPNETCORE_EVENT_INVALID_STDOUT_LOG_FILE_MSG,
  1006. - // m_struLogFilePath.QueryStr(),
  1007. - // HRESULT_FROM_GETLASTERROR())))
  1008. - //{
  1009. - // apsz[0] = strEventMsg.QueryStr();
  1010. - // //
  1011. - // // not checking return code because if ReportEvent
  1012. - // // fails, we cannot do anything.
  1013. - // //
  1014. - // if (FORWARDING_HANDLER::QueryEventLog() != NULL)
  1015. - // {
  1016. - // ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
  1017. - // EVENTLOG_WARNING_TYPE,
  1018. - // 0,
  1019. - // ASPNETCORE_EVENT_CONFIG_ERROR,
  1020. - // NULL,
  1021. - // 1,
  1022. - // 0,
  1023. - // apsz,
  1024. - // NULL);
  1025. - // }
  1026. - //}
  1027. + STRU strEventMsg;
  1028. + if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  1029. + ASPNETCORE_EVENT_INVALID_STDOUT_LOG_FILE_MSG,
  1030. + m_struLogFilePath.QueryStr(),
  1031. + hr)))
  1032. + {
  1033. + UTILITY::LogEvent(g_hEventLog,
  1034. + EVENTLOG_WARNING_TYPE,
  1035. + ASPNETCORE_EVENT_CONFIG_ERROR,
  1036. + strEventMsg.QueryStr());
  1037. + }
  1038. }
  1039. }
  1040. @@ -384,8 +368,6 @@ IN_PROCESS_APPLICATION::LoadManagedApplication
  1041. DWORD dwTimeout;
  1042. DWORD dwResult;
  1043. BOOL fLocked = FALSE;
  1044. - //PCWSTR apsz[1];
  1045. - //STACK_STRU(strEventMsg, 256);
  1046. if (m_fManagedAppLoaded || m_fLoadManagedAppError)
  1047. {
  1048. @@ -481,36 +463,22 @@ Finished:
  1049. if (FAILED(hr))
  1050. {
  1051. + STACK_STRU(strEventMsg, 256);
  1052. // Question: in case of application loading failure, should we allow retry on
  1053. // following request or block the activation at all
  1054. m_fLoadManagedAppError = TRUE; // m_hThread != NULL ?
  1055. - // TODO
  1056. - //if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  1057. - // ASPNETCORE_EVENT_LOAD_CLR_FALIURE_MSG,
  1058. - // m_pConfiguration->QueryApplicationPath()->QueryStr(),
  1059. - // m_pConfiguration->QueryApplicationPhysicalPath()->QueryStr(),
  1060. - // hr)))
  1061. - //{
  1062. - // apsz[0] = strEventMsg.QueryStr();
  1063. -
  1064. - // //
  1065. - // // not checking return code because if ReportEvent
  1066. - // // fails, we cannot do anything.
  1067. - // //
  1068. - // if (FORWARDING_HANDLER::QueryEventLog() != NULL)
  1069. - // {
  1070. - // ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
  1071. - // EVENTLOG_ERROR_TYPE,
  1072. - // 0,
  1073. - // ASPNETCORE_EVENT_LOAD_CLR_FALIURE,
  1074. - // NULL,
  1075. - // 1,
  1076. - // 0,
  1077. - // apsz,
  1078. - // NULL);
  1079. - // }
  1080. - //}
  1081. + if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  1082. + ASPNETCORE_EVENT_LOAD_CLR_FALIURE_MSG,
  1083. + m_pConfig->QueryApplicationPath()->QueryStr(),
  1084. + m_pConfig->QueryApplicationPhysicalPath()->QueryStr(),
  1085. + hr)))
  1086. + {
  1087. + UTILITY::LogEvent(g_hEventLog,
  1088. + EVENTLOG_ERROR_TYPE,
  1089. + ASPNETCORE_EVENT_LOAD_CLR_FALIURE,
  1090. + strEventMsg.QueryStr());
  1091. + }
  1092. }
  1093. if (fLocked)
  1094. @@ -583,37 +551,22 @@ Finished:
  1095. //
  1096. if (!m_fRecycleProcessCalled)
  1097. {
  1098. - //STRU strEventMsg;
  1099. - //LPCWSTR apsz[1];
  1100. - //if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  1101. - // ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_MSG,
  1102. - // m_pConfig->QueryApplicationPath()->QueryStr(),
  1103. - // m_pConfig->QueryApplicationPhysicalPath()->QueryStr(),
  1104. - // m_ProcessExitCode
  1105. - //)))
  1106. - //{
  1107. - // apsz[0] = strEventMsg.QueryStr();
  1108. -
  1109. - // //
  1110. - // // not checking return code because if ReportEvent
  1111. - // // fails, we cannot do anything.
  1112. - // //
  1113. - // if (FORWARDING_HANDLER::QueryEventLog() != NULL)
  1114. - // {
  1115. - // ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
  1116. - // EVENTLOG_ERROR_TYPE,
  1117. - // 0,
  1118. - // ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT,
  1119. - // NULL,
  1120. - // 1,
  1121. - // 0,
  1122. - // apsz,
  1123. - // NULL);
  1124. - // }
  1125. - // // error. the thread exits after application started
  1126. - // // Question: should we shutdown current worker process or keep the application in failure state?
  1127. - // // for now, we reccylce to keep the same behavior as that of out-of-process
  1128. - //}
  1129. + STRU strEventMsg;
  1130. + if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  1131. + ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_MSG,
  1132. + m_pConfig->QueryApplicationPath()->QueryStr(),
  1133. + m_pConfig->QueryApplicationPhysicalPath()->QueryStr(),
  1134. + m_ProcessExitCode)))
  1135. + {
  1136. + UTILITY::LogEvent(g_hEventLog,
  1137. + EVENTLOG_ERROR_TYPE,
  1138. + ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT,
  1139. + strEventMsg.QueryStr());
  1140. + }
  1141. +
  1142. + // error. the thread exits after application started
  1143. + // Question: should we shutdown current worker process or keep the application in failure state?
  1144. + // for now, we reccylce to keep the same behavior as that of out-of-process
  1145. if (m_fManagedAppLoaded)
  1146. {
  1147. Recycle();
  1148. diff --git a/src/RequestHandler/outofprocess/processmanager.cxx b/src/RequestHandler/outofprocess/processmanager.cxx
  1149. index 98ba30441fd..9c9ceb449d7 100644
  1150. --- a/src/RequestHandler/outofprocess/processmanager.cxx
  1151. +++ b/src/RequestHandler/outofprocess/processmanager.cxx
  1152. @@ -110,7 +110,6 @@ PROCESS_MANAGER::GetProcess(
  1153. HRESULT hr = S_OK;
  1154. BOOL fSharedLock = FALSE;
  1155. BOOL fExclusiveLock = FALSE;
  1156. - //PCWSTR apsz[1];
  1157. STACK_STRU(strEventMsg, 256);
  1158. DWORD dwProcessIndex = 0;
  1159. SERVER_PROCESS *pSelectedServerProcess = NULL;
  1160. @@ -192,30 +191,15 @@ PROCESS_MANAGER::GetProcess(
  1161. //
  1162. // rapid fails per minute exceeded, do not create new process.
  1163. //
  1164. -
  1165. - //if( SUCCEEDED( strEventMsg.SafeSnwprintf(
  1166. - // ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED_MSG,
  1167. - // pConfig->QueryRapidFailsPerMinute() ) ) )
  1168. - //{
  1169. - // apsz[0] = strEventMsg.QueryStr();
  1170. -
  1171. - // //
  1172. - // // not checking return code because if ReportEvent
  1173. - // // fails, we cannot do anything.
  1174. - // //
  1175. - // if (FORWARDING_HANDLER::QueryEventLog() != NULL)
  1176. - // {
  1177. - // ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
  1178. - // EVENTLOG_INFORMATION_TYPE,
  1179. - // 0,
  1180. - // ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED,
  1181. - // NULL,
  1182. - // 1,
  1183. - // 0,
  1184. - // apsz,
  1185. - // NULL);
  1186. - // }
  1187. - //}
  1188. + if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  1189. + ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED_MSG,
  1190. + pConfig->QueryRapidFailsPerMinute())))
  1191. + {
  1192. + UTILITY::LogEvent(g_hEventLog,
  1193. + EVENTLOG_INFORMATION_TYPE,
  1194. + ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED,
  1195. + strEventMsg.QueryStr());
  1196. + }
  1197. hr = HRESULT_FROM_WIN32(ERROR_SERVER_DISABLED);
  1198. goto Finished;
  1199. @@ -293,4 +277,4 @@ Finished:
  1200. }
  1201. return hr;
  1202. -}
  1203. \ No newline at end of file
  1204. +}
  1205. diff --git a/src/RequestHandler/outofprocess/serverprocess.cxx b/src/RequestHandler/outofprocess/serverprocess.cxx
  1206. index 4c94331de92..97243d8bc27 100644
  1207. --- a/src/RequestHandler/outofprocess/serverprocess.cxx
  1208. +++ b/src/RequestHandler/outofprocess/serverprocess.cxx
  1209. @@ -857,19 +857,12 @@ SERVER_PROCESS::StartProcess(
  1210. HRESULT hr = S_OK;
  1211. PROCESS_INFORMATION processInformation = {0};
  1212. STARTUPINFOW startupInfo = {0};
  1213. -// BOOL fDonePrepareCommandLine = FALSE;
  1214. DWORD dwRetryCount = 2; // should we allow customer to config it
  1215. DWORD dwCreationFlags = 0;
  1216. -
  1217. -// STACK_STRU( strEventMsg, 256);
  1218. -// STRU strFullProcessPath;
  1219. -// STRU struRelativePath;
  1220. -// STRU struApplicationId;
  1221. -//
  1222. -// LPCWSTR apsz[1];
  1223. + STACK_STRU( strEventMsg, 256);
  1224. MULTISZ mszNewEnvironment;
  1225. ENVIRONMENT_VAR_HASH *pHashTable = NULL;
  1226. -//
  1227. +
  1228. GetStartupInfoW(&startupInfo);
  1229. //
  1230. @@ -945,13 +938,13 @@ SERVER_PROCESS::StartProcess(
  1231. {
  1232. hr = HRESULT_FROM_WIN32(GetLastError());
  1233. // don't the check return code as we already in error report
  1234. - /*strEventMsg.SafeSnwprintf(
  1235. + strEventMsg.SafeSnwprintf(
  1236. ASPNETCORE_EVENT_PROCESS_START_ERROR_MSG,
  1237. m_struAppFullPath.QueryStr(),
  1238. - m_pszRootApplicationPath.QueryStr(),
  1239. - struCommandLine.QueryStr(),
  1240. + m_struPhysicalPath.QueryStr(),
  1241. + m_struCommandLine.QueryStr(),
  1242. hr,
  1243. - 0);*/
  1244. + dwRetryCount);
  1245. goto Finished;
  1246. }
  1247. @@ -987,42 +980,17 @@ SERVER_PROCESS::StartProcess(
  1248. // Backend process starts successfully. Set retry counter to 0
  1249. dwRetryCount = 0;
  1250. - //
  1251. - // if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  1252. - // ASPNETCORE_EVENT_PROCESS_START_SUCCESS_MSG,
  1253. - // m_struAppFullPath.QueryStr(),
  1254. - // m_dwProcessId,
  1255. - // m_dwPort)))
  1256. - // {
  1257. - // apsz[0] = strEventMsg.QueryStr();
  1258. - //
  1259. - // //
  1260. - // // not checking return code because if ReportEvent
  1261. - // // fails, we cannot do anything.
  1262. - // //
  1263. - // if (FORWARDING_HANDLER::QueryEventLog() != NULL)
  1264. - // {
  1265. - // ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
  1266. - // EVENTLOG_INFORMATION_TYPE,
  1267. - // 0,
  1268. - // ASPNETCORE_EVENT_PROCESS_START_SUCCESS,
  1269. - // NULL,
  1270. - // 1,
  1271. - // 0,
  1272. - // apsz,
  1273. - // NULL);
  1274. - // }
  1275. - //
  1276. - // // FREB log
  1277. - //if (ANCMEvents::ANCM_START_APPLICATION_SUCCESS::IsEnabled(context->GetTraceContext()))
  1278. - //{
  1279. - // ANCMEvents::ANCM_START_APPLICATION_SUCCESS::RaiseEvent(
  1280. - // context->GetTraceContext(),
  1281. - // NULL,
  1282. - // apsz[0]);
  1283. - //}
  1284. - // }
  1285. - //
  1286. + if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  1287. + ASPNETCORE_EVENT_PROCESS_START_SUCCESS_MSG,
  1288. + m_struAppFullPath.QueryStr(),
  1289. + m_dwProcessId,
  1290. + m_dwPort)))
  1291. + {
  1292. + UTILITY::LogEvent(g_hEventLog,
  1293. + EVENTLOG_INFORMATION_TYPE,
  1294. + ASPNETCORE_EVENT_PROCESS_START_SUCCESS,
  1295. + strEventMsg.QueryStr());
  1296. + }
  1297. Finished:
  1298. if (processInformation.hThread != NULL)
  1299. @@ -1037,57 +1005,29 @@ SERVER_PROCESS::StartProcess(
  1300. delete pHashTable;
  1301. pHashTable = NULL;
  1302. }
  1303. - }
  1304. -// if (FAILED(hr))
  1305. -// {
  1306. -// if (strEventMsg.IsEmpty())
  1307. -// {
  1308. -// if (!fDonePrepareCommandLine)
  1309. -// {
  1310. -// strEventMsg.SafeSnwprintf(
  1311. -// m_struAppFullPath.QueryStr(),
  1312. -// ASPNETCORE_EVENT_PROCESS_START_INTERNAL_ERROR_MSG,
  1313. -// hr);
  1314. -// }
  1315. -// else
  1316. -// {
  1317. -// strEventMsg.SafeSnwprintf(
  1318. -// ASPNETCORE_EVENT_PROCESS_START_POSTCREATE_ERROR_MSG,
  1319. -// m_struAppFullPath.QueryStr(),
  1320. -// m_pszRootApplicationPath.QueryStr(),
  1321. -// struCommandLine.QueryStr(),
  1322. -// hr);
  1323. -// }
  1324. -// }
  1325. -//
  1326. -// apsz[0] = strEventMsg.QueryStr();
  1327. -//
  1328. -// // not checking return code because if ReportEvent
  1329. -// // fails, we cannot do anything.
  1330. -// //
  1331. -// if (FORWARDING_HANDLER::QueryEventLog() != NULL)
  1332. -// {
  1333. -// ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
  1334. -// EVENTLOG_ERROR_TYPE,
  1335. -// 0,
  1336. -// ASPNETCORE_EVENT_PROCESS_START_ERROR,
  1337. -// NULL,
  1338. -// 1,
  1339. -// 0,
  1340. -// apsz,
  1341. -// NULL);
  1342. -// }
  1343. -//
  1344. -// // FREB log
  1345. -// if (ANCMEvents::ANCM_START_APPLICATION_FAIL::IsEnabled(context->GetTraceContext()))
  1346. -// {
  1347. -// ANCMEvents::ANCM_START_APPLICATION_FAIL::RaiseEvent(
  1348. -// context->GetTraceContext(),
  1349. -// NULL,
  1350. -// strEventMsg.QueryStr());
  1351. -// }
  1352. -// }
  1353. + if (FAILED(hr))
  1354. + {
  1355. + if (strEventMsg.IsEmpty())
  1356. + {
  1357. + strEventMsg.SafeSnwprintf(
  1358. + ASPNETCORE_EVENT_PROCESS_START_POSTCREATE_ERROR_MSG,
  1359. + m_struAppFullPath.QueryStr(),
  1360. + m_struPhysicalPath.QueryStr(),
  1361. + m_struCommandLine.QueryStr(),
  1362. + hr,
  1363. + dwRetryCount);
  1364. + }
  1365. +
  1366. + if (!strEventMsg.IsEmpty())
  1367. + {
  1368. + UTILITY::LogEvent(g_hEventLog,
  1369. + EVENTLOG_ERROR_TYPE,
  1370. + ASPNETCORE_EVENT_PROCESS_START_ERROR,
  1371. + strEventMsg.QueryStr());
  1372. + }
  1373. + }
  1374. + }
  1375. if (FAILED(hr) || m_fReady == FALSE)
  1376. {
  1377. @@ -1121,7 +1061,6 @@ SERVER_PROCESS::StartProcess(
  1378. }
  1379. StopProcess();
  1380. -
  1381. StopAllProcessesInJobObject();
  1382. }
  1383. return hr;
  1384. @@ -1165,8 +1104,6 @@ SERVER_PROCESS::SetupStdHandles(
  1385. SECURITY_ATTRIBUTES saAttr = { 0 };
  1386. STRU struPath;
  1387. - //STRU strEventMsg;
  1388. - //LPCWSTR apsz[1];
  1389. DBG_ASSERT(pStartupInfo);
  1390. @@ -1258,30 +1195,17 @@ Finished:
  1391. if (m_fStdoutLogEnabled)
  1392. {
  1393. // Log the error
  1394. - //if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  1395. - // ASPNETCORE_EVENT_INVALID_STDOUT_LOG_FILE_MSG,
  1396. - // m_struFullLogFile.QueryStr(),
  1397. - // HRESULT_FROM_GETLASTERROR())))
  1398. - //{
  1399. - // apsz[0] = strEventMsg.QueryStr();
  1400. -
  1401. - // //
  1402. - // // not checking return code because if ReportEvent
  1403. - // // fails, we cannot do anything.
  1404. - // //
  1405. - // /*if (FORWARDING_HANDLER::QueryEventLog() != NULL)
  1406. - // {
  1407. - // ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
  1408. - // EVENTLOG_WARNING_TYPE,
  1409. - // 0,
  1410. - // ASPNETCORE_EVENT_CONFIG_ERROR,
  1411. - // NULL,
  1412. - // 1,
  1413. - // 0,
  1414. - // apsz,
  1415. - // NULL);
  1416. - // }*/
  1417. - //}
  1418. + STRU strEventMsg;
  1419. + if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  1420. + ASPNETCORE_EVENT_INVALID_STDOUT_LOG_FILE_MSG,
  1421. + m_struFullLogFile.QueryStr(),
  1422. + hr)))
  1423. + {
  1424. + UTILITY::LogEvent(g_hEventLog,
  1425. + EVENTLOG_WARNING_TYPE,
  1426. + ASPNETCORE_EVENT_CONFIG_ERROR,
  1427. + strEventMsg.QueryStr());
  1428. + }
  1429. }
  1430. }
  1431. return hr;
  1432. @@ -2077,9 +2001,7 @@ SERVER_PROCESS::SendShutdownHttpMessage( VOID )
  1433. STRU strUrl;
  1434. DWORD dwStatusCode = 0;
  1435. DWORD dwSize = sizeof(dwStatusCode);
  1436. -
  1437. - //LPCWSTR apsz[1];
  1438. - //STACK_STRU(strEventMsg, 256);
  1439. + STACK_STRU(strEventMsg, 256);
  1440. hSession = WinHttpOpen(L"",
  1441. WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
  1442. @@ -2182,25 +2104,16 @@ SERVER_PROCESS::SendShutdownHttpMessage( VOID )
  1443. }
  1444. // log
  1445. - /*if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  1446. + if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  1447. ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST_MSG,
  1448. m_dwProcessId,
  1449. dwStatusCode)))
  1450. {
  1451. - apsz[0] = strEventMsg.QueryStr();
  1452. - if (FORWARDING_HANDLER::QueryEventLog() != NULL)
  1453. - {
  1454. - ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
  1455. - EVENTLOG_INFORMATION_TYPE,
  1456. - 0,
  1457. - ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST,
  1458. - NULL,
  1459. - 1,
  1460. - 0,
  1461. - apsz,
  1462. - NULL);
  1463. - }
  1464. - }*/
  1465. + UTILITY::LogEvent(g_hEventLog,
  1466. + EVENTLOG_INFORMATION_TYPE,
  1467. + ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST,
  1468. + strEventMsg.QueryStr());
  1469. + }
  1470. Finished:
  1471. if (hRequest)
  1472. @@ -2291,8 +2204,7 @@ SERVER_PROCESS::TerminateBackendProcess(
  1473. VOID
  1474. )
  1475. {
  1476. - //LPCWSTR apsz[1];
  1477. - //STACK_STRU(strEventMsg, 256);
  1478. + STACK_STRU(strEventMsg, 256);
  1479. if (InterlockedCompareExchange(&m_lStopping, 1L, 0L) == 0L)
  1480. {
  1481. @@ -2316,23 +2228,14 @@ SERVER_PROCESS::TerminateBackendProcess(
  1482. }
  1483. // log a warning for ungraceful shutdown
  1484. - /*if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  1485. + if (SUCCEEDED(strEventMsg.SafeSnwprintf(
  1486. ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE_MSG,
  1487. m_dwProcessId)))
  1488. {
  1489. - apsz[0] = strEventMsg.QueryStr();
  1490. - if (FORWARDING_HANDLER::QueryEventLog() != NULL)
  1491. - {
  1492. - ReportEventW(FORWARDING_HANDLER::QueryEventLog(),
  1493. - EVENTLOG_WARNING_TYPE,
  1494. - 0,
  1495. - ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE,
  1496. - NULL,
  1497. - 1,
  1498. - 0,
  1499. - apsz,
  1500. - NULL);
  1501. - }
  1502. - }*/
  1503. + UTILITY::LogEvent(g_hEventLog,
  1504. + EVENTLOG_WARNING_TYPE,
  1505. + ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE,
  1506. + strEventMsg.QueryStr());
  1507. + }
  1508. }
  1509. -}
  1510. \ No newline at end of file
  1511. +}
  1512. diff --git a/src/RequestHandler/precomp.hxx b/src/RequestHandler/precomp.hxx
  1513. index a12c49cde91..42ee3e391b2 100644
  1514. --- a/src/RequestHandler/precomp.hxx
  1515. +++ b/src/RequestHandler/precomp.hxx
  1516. @@ -55,11 +55,11 @@
  1517. #include "..\CommonLib\aspnetcoreconfig.h"
  1518. #include "..\CommonLib\utility.h"
  1519. #include "..\CommonLib\application.h"
  1520. +#include "..\CommonLib\resources.h"
  1521. #include "aspnetcore_event.h"
  1522. #include "aspnetcore_msg.h"
  1523. #include "disconnectcontext.h"
  1524. #include "sttimer.h"
  1525. -#include "resource.h"
  1526. #include ".\inprocess\InProcessHandler.h"
  1527. #include ".\inprocess\inprocessapplication.h"
  1528. #include ".\outofprocess\responseheaderhash.h"
  1529. @@ -88,8 +88,6 @@ template<typename T> inline T min(T a, T b)
  1530. }
  1531. #endif
  1532. -#define ASPNETCORE_EVENT_PROVIDER L"IIS AspNetCore Module"
  1533. -#define ASPNETCORE_IISEXPRESS_EVENT_PROVIDER L"IIS Express AspNetCore Module"
  1534. inline bool IsSpace(char ch)
  1535. {
  1536. @@ -117,3 +115,4 @@ extern DWORD g_OptionalWinHttpFlags;
  1537. extern SRWLOCK g_srwLockRH;
  1538. extern HINTERNET g_hWinhttpSession;
  1539. extern DWORD g_dwTlsIndex;
  1540. +extern HANDLE g_hEventLog;