Merge pull request #764 from aspnet/pakrym/cleanup-logs
Cleanup LogEvent calls
This commit is contained in:
commit
6e54256fca
|
|
@ -15,7 +15,7 @@ APPLICATION_INFO::~APPLICATION_INFO()
|
|||
{
|
||||
// Mark the entry as invalid,
|
||||
// StopMonitor will close the file handle and trigger a FCN
|
||||
// the entry will delete itself when processing this FCN
|
||||
// the entry will delete itself when processing this FCN
|
||||
m_pFileWatcherEntry->MarkEntryInValid();
|
||||
m_pFileWatcherEntry->StopMonitor();
|
||||
m_pFileWatcherEntry = NULL;
|
||||
|
|
@ -112,15 +112,10 @@ APPLICATION_INFO::UpdateAppOfflineFileHandle()
|
|||
// if it was, log that app_offline has been dropped.
|
||||
if (m_fAppOfflineFound)
|
||||
{
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_RECYCLE_APPOFFLINE_REMOVED_MSG)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_RECYCLE_APPOFFLINE_REMOVED,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_RECYCLE_APPOFFLINE_REMOVED,
|
||||
ASPNETCORE_EVENT_RECYCLE_APPOFFLINE_REMOVED_MSG);
|
||||
}
|
||||
|
||||
m_fAppOfflineFound = FALSE;
|
||||
|
|
@ -157,16 +152,11 @@ APPLICATION_INFO::UpdateAppOfflineFileHandle()
|
|||
// recycle the application
|
||||
if (m_pApplication != NULL)
|
||||
{
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_RECYCLE_APPOFFLINE,
|
||||
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->QueryConfig()->QueryApplicationPath()->QueryStr());
|
||||
|
||||
RecycleApplication();
|
||||
}
|
||||
|
|
@ -268,32 +258,20 @@ APPLICATION_INFO::FindRequestHandlerAssembly()
|
|||
{
|
||||
if (FAILED(hr = FindNativeAssemblyFromHostfxr(&struFileName)))
|
||||
{
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_INPROCESS_RH_MISSING_MSG)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_INPROCESS_RH_MISSING,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
|
||||
goto Finished;
|
||||
ASPNETCORE_EVENT_INPROCESS_RH_MISSING_MSG);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FAILED(hr = FindNativeAssemblyFromGlobalLocation(&struFileName)))
|
||||
{
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_OUT_OF_PROCESS_RH_MISSING_MSG)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_OUT_OF_PROCESS_RH_MISSING,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_OUT_OF_PROCESS_RH_MISSING,
|
||||
ASPNETCORE_EVENT_OUT_OF_PROCESS_RH_MISSING_MSG);
|
||||
|
||||
goto Finished;
|
||||
}
|
||||
|
|
@ -327,7 +305,7 @@ APPLICATION_INFO::FindRequestHandlerAssembly()
|
|||
Finished:
|
||||
//
|
||||
// Question: we remember the load failure so that we will not try again.
|
||||
// User needs to check whether the fuction pointer is NULL
|
||||
// User needs to check whether the fuction pointer is NULL
|
||||
//
|
||||
m_pfnAspNetCoreCreateApplication = g_pfnAspNetCoreCreateApplication;
|
||||
m_pfnAspNetCoreCreateRequestHandler = g_pfnAspNetCoreCreateRequestHandler;
|
||||
|
|
@ -400,11 +378,11 @@ Finished:
|
|||
return hr;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Tries to find aspnetcorerh.dll from the application
|
||||
// Calls into hostfxr.dll to find it.
|
||||
// Will leave hostfxr.dll loaded as it will be used again to call hostfxr_main.
|
||||
//
|
||||
//
|
||||
HRESULT
|
||||
APPLICATION_INFO::FindNativeAssemblyFromHostfxr(
|
||||
STRU* struFilename
|
||||
|
|
@ -439,7 +417,7 @@ APPLICATION_INFO::FindNativeAssemblyFromHostfxr(
|
|||
if (pFnHostFxrSearchDirectories == NULL)
|
||||
{
|
||||
// Host fxr version is incorrect (need a higher version).
|
||||
// TODO log error
|
||||
// TODO log error
|
||||
hr = E_FAIL;
|
||||
goto Finished;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ APPLICATION_MANAGER::GetOrCreateApplicationInfo(
|
|||
BOOL fMixedHostingModelError = FALSE;
|
||||
BOOL fDuplicatedInProcessApp = FALSE;
|
||||
PCWSTR pszApplicationId = NULL;
|
||||
STACK_STRU ( strEventMsg, 256 );
|
||||
|
||||
DBG_ASSERT(pServer);
|
||||
DBG_ASSERT(pConfig);
|
||||
|
|
@ -32,9 +31,9 @@ APPLICATION_MANAGER::GetOrCreateApplicationInfo(
|
|||
|
||||
*ppApplicationInfo = NULL;
|
||||
|
||||
// The configuration path is unique for each application and is used for the
|
||||
// The configuration path is unique for each application and is used for the
|
||||
// key in the applicationInfoHash.
|
||||
pszApplicationId = pConfig->QueryConfigPath()->QueryStr();
|
||||
pszApplicationId = pConfig->QueryConfigPath()->QueryStr();
|
||||
hr = key.Initialize(pszApplicationId);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
|
|
@ -55,7 +54,7 @@ APPLICATION_MANAGER::GetOrCreateApplicationInfo(
|
|||
|
||||
if (*ppApplicationInfo == NULL)
|
||||
{
|
||||
// Check which hosting model we want to support
|
||||
// Check which hosting model we want to support
|
||||
switch (pConfig->QueryHostingModel())
|
||||
{
|
||||
case HOSTING_IN_PROCESS:
|
||||
|
|
@ -160,41 +159,29 @@ Finished:
|
|||
{
|
||||
if (fDuplicatedInProcessApp)
|
||||
{
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP,
|
||||
ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP_MSG,
|
||||
pszApplicationId)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
pszApplicationId);
|
||||
}
|
||||
else if (fMixedHostingModelError)
|
||||
{
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR,
|
||||
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());
|
||||
}
|
||||
pConfig->QueryHostingModel());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_ADD_APPLICATION_ERROR,
|
||||
ASPNETCORE_EVENT_ADD_APPLICATION_ERROR_MSG,
|
||||
pszApplicationId,
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_ADD_APPLICATION_ERROR,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
hr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -215,7 +202,7 @@ APPLICATION_MANAGER::FindConfigChangedApplication(
|
|||
DBG_ASSERT(pvContext);
|
||||
|
||||
// Config Change context contains the original config path that changed
|
||||
// and a multiStr containing
|
||||
// and a multiStr containing
|
||||
CONFIG_CHANGE_CONTEXT* pContext = static_cast<CONFIG_CHANGE_CONTEXT*>(pvContext);
|
||||
STRU* pstruConfigPath = pEntry->QueryConfig()->QueryConfigPath();
|
||||
|
||||
|
|
@ -250,7 +237,7 @@ APPLICATION_MANAGER::FindConfigChangedApplication(
|
|||
// This will cause a shutdown event to occur through the global stop listening event.
|
||||
// OutOfProcess: Removes all applications in the application manager and calls Recycle, which will call Shutdown,
|
||||
// on each application.
|
||||
//
|
||||
//
|
||||
HRESULT
|
||||
APPLICATION_MANAGER::RecycleApplicationFromManager(
|
||||
_In_ LPCWSTR pszApplicationId
|
||||
|
|
@ -307,7 +294,7 @@ APPLICATION_MANAGER::RecycleApplicationFromManager(
|
|||
// Don't call application shutdown inside the lock
|
||||
m_pApplicationInfoHash->Apply(APPLICATION_INFO_HASH::ReferenceCopyToTable, static_cast<PVOID>(table));
|
||||
DBG_ASSERT(dwPreviousCounter == table->Count());
|
||||
|
||||
|
||||
// Removed the applications which are impacted by the configurtion change
|
||||
m_pApplicationInfoHash->DeleteIf(FindConfigChangedApplication, (PVOID)&context);
|
||||
|
||||
|
|
@ -349,16 +336,11 @@ APPLICATION_MANAGER::RecycleApplicationFromManager(
|
|||
APPLICATION_INFO* pRecord;
|
||||
|
||||
// Application got recycled. Log an event
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_RECYCLE_CONFIGURATION,
|
||||
ASPNETCORE_EVENT_RECYCLE_CONFIGURATION_MSG,
|
||||
path)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_RECYCLE_CONFIGURATION,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
path);
|
||||
|
||||
hr = key.Initialize(path);
|
||||
if (FAILED(hr))
|
||||
|
|
@ -369,7 +351,7 @@ APPLICATION_MANAGER::RecycleApplicationFromManager(
|
|||
table->FindKey(&key, &pRecord);
|
||||
DBG_ASSERT(pRecord != NULL);
|
||||
|
||||
// RecycleApplication is called on a separate thread.
|
||||
// RecycleApplication is called on a separate thread.
|
||||
pRecord->RecycleApplication();
|
||||
pRecord->DereferenceApplicationInfo();
|
||||
path = context.MultiSz.Next(path);
|
||||
|
|
@ -386,16 +368,11 @@ Finished:
|
|||
if (FAILED(hr))
|
||||
{
|
||||
// Failed to recycle an application. Log an event
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_RECYCLE_FAILURE_CONFIGURATION_MSG,
|
||||
pszApplicationId)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_RECYCLE_APP_FAILURE,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_RECYCLE_APP_FAILURE,
|
||||
ASPNETCORE_EVENT_RECYCLE_FAILURE_CONFIGURATION_MSG,
|
||||
pszApplicationId);
|
||||
// Need to recycle the process as we cannot recycle the application
|
||||
if (!g_fRecycleProcessCalled)
|
||||
{
|
||||
|
|
@ -410,7 +387,7 @@ Finished:
|
|||
//
|
||||
// Shutsdown all applications in the application hashtable
|
||||
// Only called by OnGlobalStopListening.
|
||||
//
|
||||
//
|
||||
VOID
|
||||
APPLICATION_MANAGER::ShutDown()
|
||||
{
|
||||
|
|
@ -427,7 +404,7 @@ APPLICATION_MANAGER::ShutDown()
|
|||
}
|
||||
|
||||
DBG_ASSERT(m_pApplicationInfoHash);
|
||||
// During shutdown we lock until we delete the application
|
||||
// During shutdown we lock until we delete the application
|
||||
AcquireSRWLockExclusive(&m_srwLock);
|
||||
|
||||
// Call shutdown on each application in the application manager
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ BOOL WINAPI DllMain(HMODULE hModule,
|
|||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
// IIS can cause dll detach to occur before we receive global notifications
|
||||
// For example, when we switch the bitness of the worker process,
|
||||
// For example, when we switch the bitness of the worker process,
|
||||
// this is a bug in IIS. To try to avoid AVs, we will set a global flag
|
||||
g_fInShutdown = TRUE;
|
||||
StaticCleanup();
|
||||
|
|
@ -160,16 +160,10 @@ 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());
|
||||
}
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_WARNING_TYPE,
|
||||
ASPNETCORE_EVENT_MODULE_DISABLED,
|
||||
ASPNETCORE_EVENT_MODULE_DISABLED_MSG);
|
||||
// this will return 500 error to client
|
||||
// as we did not register the module
|
||||
goto Finished;
|
||||
|
|
@ -204,7 +198,7 @@ HRESULT
|
|||
hr = E_OUTOFMEMORY;
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
|
||||
hr = pApplicationManager->Initialize();
|
||||
if(FAILED(hr))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ HOSTFXR_UTILITY::GetStandaloneHostfxrParameters(
|
|||
STRU struArguments;
|
||||
STRU struHostFxrPath;
|
||||
STRU struRuntimeConfigLocation;
|
||||
STRU strEventMsg;
|
||||
DWORD dwPosition;
|
||||
|
||||
// Obtain the app name from the processPath section.
|
||||
|
|
@ -80,31 +79,23 @@ HOSTFXR_UTILITY::GetStandaloneHostfxrParameters(
|
|||
{
|
||||
|
||||
hr = E_APPLICATION_ACTIVATION_EXEC_FAILURE;
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_INPROCESS_FULL_FRAMEWORK_APP_MSG,
|
||||
pcwzApplicationPhysicalPath,
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent( hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_INPROCESS_FULL_FRAMEWORK_APP,
|
||||
strEventMsg.QueryStr() );
|
||||
}
|
||||
UTILITY::LogEventF(hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_INPROCESS_FULL_FRAMEWORK_APP,
|
||||
ASPNETCORE_EVENT_INPROCESS_FULL_FRAMEWORK_APP_MSG,
|
||||
pcwzApplicationPhysicalPath,
|
||||
hr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If a runtime config file does exist, report a file not found on the app.exe
|
||||
hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_APPLICATION_EXE_NOT_FOUND_MSG,
|
||||
UTILITY::LogEventF(hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_APPLICATION_EXE_NOT_FOUND,
|
||||
ASPNETCORE_EVENT_APPLICATION_EXE_NOT_FOUND_MSG,
|
||||
pcwzApplicationPhysicalPath,
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_APPLICATION_EXE_NOT_FOUND,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
hr);
|
||||
}
|
||||
|
||||
goto Finished;
|
||||
|
|
@ -190,12 +181,12 @@ HOSTFXR_UTILITY::GetHostFxrParameters(
|
|||
goto Finished;
|
||||
}
|
||||
|
||||
// Check if the absolute path is to dotnet or not.
|
||||
// Check if the absolute path is to dotnet or not.
|
||||
if (struAbsolutePathToDotnet.EndsWith(L"dotnet.exe") || struAbsolutePathToDotnet.EndsWith(L"dotnet"))
|
||||
{
|
||||
//
|
||||
// The processPath ends with dotnet.exe or dotnet
|
||||
// like: C:\Program Files\dotnet\dotnet.exe, C:\Program Files\dotnet\dotnet, dotnet.exe, or dotnet.
|
||||
// like: C:\Program Files\dotnet\dotnet.exe, C:\Program Files\dotnet\dotnet, dotnet.exe, or dotnet.
|
||||
// Get the absolute path to dotnet. If the path is already an absolute path, it will return that path
|
||||
//
|
||||
if (FAILED(hr = HOSTFXR_UTILITY::GetAbsolutePathToDotnet(&struAbsolutePathToDotnet))) // Make sure to append the dotnet.exe path correctly here (pass in regular path)?
|
||||
|
|
@ -249,16 +240,12 @@ HOSTFXR_UTILITY::GetHostFxrParameters(
|
|||
// then it is an invalid argument.
|
||||
//
|
||||
hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);;
|
||||
if (SUCCEEDED(struEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_GENERAL_ERROR_MSG,
|
||||
ASPNETCORE_EVENT_INVALID_PROCESS_PATH_MSG,
|
||||
struExpandedProcessPath.QueryStr(),
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_GENERAL_ERROR_MSG,
|
||||
struEventMsg.QueryStr());
|
||||
}
|
||||
hr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -273,8 +260,8 @@ Finished:
|
|||
// Arg structure:
|
||||
// argv[0] = Path to exe activating hostfxr.
|
||||
// argv[1] = L"exec"
|
||||
// argv[2] = absolute path to dll.
|
||||
//
|
||||
// argv[2] = absolute path to dll.
|
||||
//
|
||||
HRESULT
|
||||
HOSTFXR_UTILITY::ParseHostfxrArguments(
|
||||
PCWSTR pwzArgumentsFromConfig,
|
||||
|
|
@ -473,16 +460,13 @@ HOSTFXR_UTILITY::GetAbsolutePathToHostFxr(
|
|||
if (!UTILITY::DirectoryExists(&struHostFxrPath))
|
||||
{
|
||||
hr = ERROR_BAD_ENVIRONMENT;
|
||||
if (SUCCEEDED(struEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_HOSTFXR_DIRECTORY_NOT_FOUND,
|
||||
struEventMsg.QueryStr(),
|
||||
ASPNETCORE_EVENT_HOSTFXR_DIRECTORY_NOT_FOUND_MSG,
|
||||
struHostFxrPath.QueryStr(),
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_HOSTFXR_DIRECTORY_NOT_FOUND,
|
||||
struEventMsg.QueryStr());
|
||||
}
|
||||
hr);
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
|
|
@ -505,16 +489,12 @@ HOSTFXR_UTILITY::GetAbsolutePathToHostFxr(
|
|||
if (vVersionFolders.size() == 0)
|
||||
{
|
||||
hr = HRESULT_FROM_WIN32(ERROR_BAD_ENVIRONMENT);
|
||||
if (SUCCEEDED(struEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_HOSTFXR_DIRECTORY_NOT_FOUND,
|
||||
ASPNETCORE_EVENT_HOSTFXR_DIRECTORY_NOT_FOUND_MSG,
|
||||
struHostFxrPath.QueryStr(),
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_HOSTFXR_DIRECTORY_NOT_FOUND,
|
||||
struEventMsg.QueryStr());
|
||||
}
|
||||
hr);
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
|
|
@ -535,16 +515,12 @@ HOSTFXR_UTILITY::GetAbsolutePathToHostFxr(
|
|||
{
|
||||
// ASPNETCORE_EVENT_HOSTFXR_DLL_NOT_FOUND_MSG
|
||||
hr = HRESULT_FROM_WIN32(ERROR_FILE_INVALID);
|
||||
if (SUCCEEDED(struEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_HOSTFXR_DLL_NOT_FOUND,
|
||||
ASPNETCORE_EVENT_HOSTFXR_DLL_NOT_FOUND_MSG,
|
||||
struHostFxrPath.QueryStr(),
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_HOSTFXR_DLL_NOT_FOUND,
|
||||
struEventMsg.QueryStr());
|
||||
}
|
||||
hr);
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
|
|
@ -657,7 +633,7 @@ HOSTFXR_UTILITY::InvokeWhereToFindDotnet(
|
|||
// where.exe will return 0 on success, 1 if the file is not found
|
||||
// and 2 if there was an error. Check if the exit code is 1 and set
|
||||
// a new hr result saying it couldn't find dotnet.exe
|
||||
//
|
||||
//
|
||||
if (!GetExitCodeProcess(processInformation.hProcess, &dwExitCode))
|
||||
{
|
||||
goto Finished;
|
||||
|
|
@ -666,14 +642,14 @@ HOSTFXR_UTILITY::InvokeWhereToFindDotnet(
|
|||
//
|
||||
// In this block, if anything fails, we will goto our fallback of
|
||||
// looking in C:/Program Files/
|
||||
//
|
||||
//
|
||||
if (dwExitCode != 0)
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
// Where succeeded.
|
||||
// Reset file pointer to the beginning of the file.
|
||||
// Where succeeded.
|
||||
// Reset file pointer to the beginning of the file.
|
||||
dwFilePointer = SetFilePointer(hStdOutReadPipe, 0, NULL, FILE_BEGIN);
|
||||
if (dwFilePointer == INVALID_SET_FILE_POINTER)
|
||||
{
|
||||
|
|
@ -703,7 +679,7 @@ HOSTFXR_UTILITY::InvokeWhereToFindDotnet(
|
|||
}
|
||||
|
||||
// Check the bitness of the currently running process
|
||||
// matches the dotnet.exe found.
|
||||
// matches the dotnet.exe found.
|
||||
if (!IsWow64Process(GetCurrentProcess(), &fIsWow64Process))
|
||||
{
|
||||
// Calling IsWow64Process failed
|
||||
|
|
@ -716,7 +692,7 @@ HOSTFXR_UTILITY::InvokeWhereToFindDotnet(
|
|||
}
|
||||
else
|
||||
{
|
||||
// Check the SystemInfo to see if we are currently 32 or 64 bit.
|
||||
// Check the SystemInfo to see if we are currently 32 or 64 bit.
|
||||
SYSTEM_INFO systemInfo;
|
||||
GetNativeSystemInfo(&systemInfo);
|
||||
fIsCurrentProcess64Bit = systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64;
|
||||
|
|
@ -748,7 +724,7 @@ HOSTFXR_UTILITY::InvokeWhereToFindDotnet(
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Finished:
|
||||
|
||||
if (hStdOutReadPipe != INVALID_HANDLE_VALUE)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ Arguments:
|
|||
pstrDestination - destination
|
||||
pDestinationPort - port
|
||||
pstrUrl - URL
|
||||
|
||||
|
||||
Return Value:
|
||||
|
||||
HRESULT
|
||||
|
|
@ -260,7 +260,7 @@ UTILITY::EscapeAbsPath(
|
|||
}
|
||||
|
||||
strEscapedUrl->Append(pszAbsPath);
|
||||
strEscapedUrl->Append(pRequest->GetRawHttpRequest()->CookedUrl.pQueryString,
|
||||
strEscapedUrl->Append(pRequest->GetRawHttpRequest()->CookedUrl.pQueryString,
|
||||
pRequest->GetRawHttpRequest()->CookedUrl.QueryStringLength / sizeof(WCHAR));
|
||||
|
||||
Finished:
|
||||
|
|
@ -343,8 +343,8 @@ UTILITY::IsValidHeaderName(
|
|||
|
||||
HRESULT
|
||||
UTILITY::IsPathUnc(
|
||||
__in LPCWSTR pszPath,
|
||||
__out BOOL * pfIsUnc
|
||||
__in LPCWSTR pszPath,
|
||||
__out BOOL * pfIsUnc
|
||||
)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
|
@ -484,7 +484,7 @@ UTILITY::EnsureDirectoryPathExist(
|
|||
}
|
||||
else if (struPath.QueryStr()[dwPosition-1] == L':')
|
||||
{
|
||||
// skip volume case
|
||||
// skip volume case
|
||||
continue;
|
||||
}
|
||||
else
|
||||
|
|
@ -627,3 +627,30 @@ UTILITY::LogEvent(
|
|||
fwprintf(stderr, L"ERROR: %s\n", pstrMsg);
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
UTILITY::LogEventF(
|
||||
_In_ HANDLE hEventLog,
|
||||
_In_ WORD dwEventInfoType,
|
||||
_In_ DWORD dwEventId,
|
||||
_In_ LPCWSTR pstrMsg,
|
||||
...
|
||||
)
|
||||
{
|
||||
va_list argsList;
|
||||
va_start(argsList, pstrMsg);
|
||||
|
||||
STACK_STRU ( strEventMsg, 256 );
|
||||
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
pstrMsg,
|
||||
argsList)))
|
||||
{
|
||||
UTILITY::LogEvent(hEventLog,
|
||||
dwEventInfoType,
|
||||
dwEventId,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
|
||||
va_end( argsList );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,8 +67,8 @@ public:
|
|||
static
|
||||
HRESULT
|
||||
IsPathUnc(
|
||||
__in LPCWSTR pszPath,
|
||||
__out BOOL * pfIsUnc
|
||||
__in LPCWSTR pszPath,
|
||||
__out BOOL * pfIsUnc
|
||||
);
|
||||
|
||||
static
|
||||
|
|
@ -120,6 +120,16 @@ public:
|
|||
_In_ LPCWSTR pstrMsg
|
||||
);
|
||||
|
||||
static
|
||||
VOID
|
||||
LogEventF(
|
||||
_In_ HANDLE hEventLog,
|
||||
_In_ WORD dwEventInfoType,
|
||||
_In_ DWORD dwEventId,
|
||||
__in PCWSTR pstrMsg,
|
||||
...
|
||||
);
|
||||
|
||||
private:
|
||||
|
||||
UTILITY() {}
|
||||
|
|
|
|||
|
|
@ -103,17 +103,11 @@ Finished:
|
|||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_WARNING_TYPE,
|
||||
ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE,
|
||||
ASPNETCORE_EVENT_APP_SHUTDOWN_FAILURE_MSG,
|
||||
m_pConfig->QueryConfigPath()->QueryStr())))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_WARNING_TYPE,
|
||||
ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
m_pConfig->QueryConfigPath()->QueryStr());
|
||||
|
||||
//
|
||||
// Managed layer may block the shutdown and lead to shutdown timeout
|
||||
|
|
@ -177,7 +171,7 @@ IN_PROCESS_APPLICATION::ShutDownInternal()
|
|||
ReleaseSRWLockExclusive(&m_srwLock);
|
||||
fLocked = FALSE;
|
||||
|
||||
// Release the lock before we wait on the thread to exit.
|
||||
// Release the lock before we wait on the thread to exit.
|
||||
if (m_hThread != NULL &&
|
||||
GetExitCodeThread(m_hThread, &dwThreadStatus) != 0 &&
|
||||
dwThreadStatus == STILL_ACTIVE)
|
||||
|
|
@ -219,7 +213,7 @@ IN_PROCESS_APPLICATION::ShutDownInternal()
|
|||
// delete empty log file
|
||||
handle = FindFirstFile(m_struLogFilePath.QueryStr(), &fileData);
|
||||
if (handle != INVALID_HANDLE_VALUE &&
|
||||
fileData.nFileSizeHigh == 0 &&
|
||||
fileData.nFileSizeHigh == 0 &&
|
||||
fileData.nFileSizeLow == 0) // skip check of nFileSizeHigh
|
||||
{
|
||||
FindClose(handle);
|
||||
|
|
@ -244,7 +238,7 @@ IN_PROCESS_APPLICATION::Recycle(
|
|||
{
|
||||
BOOL fLockAcquired = FALSE;
|
||||
// We need to guarantee that recycle is only called once, as calling pHttpServer->RecycleProcess
|
||||
// multiple times can lead to AVs.
|
||||
// multiple times can lead to AVs.
|
||||
if (m_fRecycleCalled)
|
||||
{
|
||||
goto Finished;
|
||||
|
|
@ -565,17 +559,12 @@ Finished:
|
|||
}
|
||||
if (FAILED(hr) && m_pConfig->QueryStdoutLogEnabled())
|
||||
{
|
||||
STRU strEventMsg;
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_WARNING_TYPE,
|
||||
ASPNETCORE_EVENT_CONFIG_ERROR,
|
||||
ASPNETCORE_EVENT_INVALID_STDOUT_LOG_FILE_MSG,
|
||||
m_struLogFilePath.QueryStr(),
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_WARNING_TYPE,
|
||||
ASPNETCORE_EVENT_CONFIG_ERROR,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
hr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -739,7 +728,7 @@ IN_PROCESS_APPLICATION::LoadManagedApplication
|
|||
|
||||
// Wait on either the thread to complete or the event to be set
|
||||
dwResult = WaitForMultipleObjects(2, pHandles, FALSE, dwTimeout);
|
||||
|
||||
|
||||
// It all timed out
|
||||
if (dwResult == WAIT_TIMEOUT)
|
||||
{
|
||||
|
|
@ -767,20 +756,15 @@ Finished:
|
|||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
m_status = APPLICATION_STATUS::FAIL;
|
||||
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_LOAD_CLR_FALIURE,
|
||||
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());
|
||||
}
|
||||
hr);
|
||||
}
|
||||
|
||||
if (fLocked)
|
||||
|
|
@ -926,13 +910,12 @@ IN_PROCESS_APPLICATION::LogErrorsOnMainExit(
|
|||
DWORD dwNumBytesRead;
|
||||
STRU struStdErrLog;
|
||||
LARGE_INTEGER li = { 0 };
|
||||
STRU strEventMsg;
|
||||
BOOL fLogged = FALSE;
|
||||
DWORD dwFilePointer = 0;
|
||||
|
||||
if (m_pConfig->QueryStdoutLogEnabled())
|
||||
{
|
||||
// Put stdout/stderr logs into
|
||||
// Put stdout/stderr logs into
|
||||
if (m_hLogFileHandle != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (GetFileSizeEx(m_hLogFileHandle, &li) && li.LowPart > 0 && li.HighPart == 0)
|
||||
|
|
@ -949,18 +932,16 @@ IN_PROCESS_APPLICATION::LogErrorsOnMainExit(
|
|||
{
|
||||
if (ReadFile(m_hLogFileHandle, pzFileContents, 4096, &dwNumBytesRead, NULL))
|
||||
{
|
||||
if (SUCCEEDED(struStdErrLog.CopyA(m_pzFileContents, m_dwStdErrReadTotal)) &&
|
||||
SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
if (SUCCEEDED(struStdErrLog.CopyA(m_pzFileContents, m_dwStdErrReadTotal)))
|
||||
{
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT,
|
||||
ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_STDOUT_MSG,
|
||||
m_pConfig->QueryApplicationPath()->QueryStr(),
|
||||
m_pConfig->QueryApplicationPhysicalPath()->QueryStr(),
|
||||
hr,
|
||||
struStdErrLog.QueryStr())))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT,
|
||||
strEventMsg.QueryStr());
|
||||
struStdErrLog.QueryStr());
|
||||
fLogged = TRUE;
|
||||
|
||||
}
|
||||
|
|
@ -973,18 +954,16 @@ IN_PROCESS_APPLICATION::LogErrorsOnMainExit(
|
|||
{
|
||||
if (m_dwStdErrReadTotal > 0)
|
||||
{
|
||||
if (SUCCEEDED(struStdErrLog.CopyA(m_pzFileContents, m_dwStdErrReadTotal)) &&
|
||||
SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
if (SUCCEEDED(struStdErrLog.CopyA(m_pzFileContents, m_dwStdErrReadTotal)))
|
||||
{
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT,
|
||||
ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_STDERR_MSG,
|
||||
m_pConfig->QueryApplicationPath()->QueryStr(),
|
||||
m_pConfig->QueryApplicationPhysicalPath()->QueryStr(),
|
||||
hr,
|
||||
struStdErrLog.QueryStr())))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT,
|
||||
strEventMsg.QueryStr());
|
||||
struStdErrLog.QueryStr());
|
||||
fLogged = TRUE;
|
||||
}
|
||||
}
|
||||
|
|
@ -993,27 +972,23 @@ IN_PROCESS_APPLICATION::LogErrorsOnMainExit(
|
|||
if (!fLogged)
|
||||
{
|
||||
// If we didn't log, log the generic message.
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT,
|
||||
ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_MSG,
|
||||
m_pConfig->QueryApplicationPath()->QueryStr(),
|
||||
m_pConfig->QueryApplicationPhysicalPath()->QueryStr(),
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT,
|
||||
strEventMsg.QueryStr());
|
||||
fLogged = TRUE;
|
||||
}
|
||||
hr);
|
||||
fLogged = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Calls hostfxr_main with the hostfxr and application as arguments.
|
||||
// Method should be called with only
|
||||
// Method should be called with only
|
||||
// Need to have __try / __except in methods that require unwinding.
|
||||
// Note, this will not
|
||||
//
|
||||
// Note, this will not
|
||||
//
|
||||
HRESULT
|
||||
IN_PROCESS_APPLICATION::RunDotnetApplication(DWORD argc, CONST PCWSTR* argv, hostfxr_main_fn pProc)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ PROCESS_MANAGER::Initialize(
|
|||
{
|
||||
SECURITY_ATTRIBUTES saAttr;
|
||||
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
saAttr.bInheritHandle = TRUE;
|
||||
saAttr.bInheritHandle = TRUE;
|
||||
saAttr.lpSecurityDescriptor = NULL;
|
||||
|
||||
m_hNULHandle = CreateFileW( L"NUL",
|
||||
|
|
@ -101,7 +101,7 @@ PROCESS_MANAGER::~PROCESS_MANAGER()
|
|||
ReleaseSRWLockExclusive(&m_srwLock);
|
||||
}
|
||||
|
||||
HRESULT
|
||||
HRESULT
|
||||
PROCESS_MANAGER::GetProcess(
|
||||
_In_ ASPNETCORE_CONFIG *pConfig,
|
||||
_Out_ SERVER_PROCESS **ppServerProcess
|
||||
|
|
@ -110,7 +110,6 @@ PROCESS_MANAGER::GetProcess(
|
|||
HRESULT hr = S_OK;
|
||||
BOOL fSharedLock = FALSE;
|
||||
BOOL fExclusiveLock = FALSE;
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
DWORD dwProcessIndex = 0;
|
||||
SERVER_PROCESS *pSelectedServerProcess = NULL;
|
||||
|
||||
|
|
@ -189,15 +188,11 @@ PROCESS_MANAGER::GetProcess(
|
|||
//
|
||||
// rapid fails per minute exceeded, do not create new process.
|
||||
//
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED,
|
||||
ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED_MSG,
|
||||
pConfig->QueryRapidFailsPerMinute())))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
pConfig->QueryRapidFailsPerMinute());
|
||||
|
||||
hr = HRESULT_FROM_WIN32(ERROR_SERVER_DISABLED);
|
||||
goto Finished;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ SERVER_PROCESS::SetupJobObject(VOID)
|
|||
m_hJobObject = NULL;
|
||||
// ignore job object creation error.
|
||||
}
|
||||
#pragma warning( error : 4312)
|
||||
#pragma warning( error : 4312)
|
||||
if (m_hJobObject != NULL)
|
||||
{
|
||||
jobInfo.BasicLimitInformation.LimitFlags =
|
||||
|
|
@ -119,7 +119,7 @@ SERVER_PROCESS::GetRandomPort
|
|||
do
|
||||
{
|
||||
//
|
||||
// ignore dwActualProcessId because here we are
|
||||
// ignore dwActualProcessId because here we are
|
||||
// determing whether the randomly generated port is
|
||||
// in use by any other process.
|
||||
//
|
||||
|
|
@ -144,7 +144,6 @@ SERVER_PROCESS::SetupListenPort(
|
|||
{
|
||||
HRESULT hr = S_OK;
|
||||
ENVIRONMENT_VAR_ENTRY *pEntry = NULL;
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
*pfCriticalError = FALSE;
|
||||
|
||||
pEnvironmentVarTable->FindKey(ASPNETCORE_PORT_ENV_STR, &pEntry);
|
||||
|
|
@ -167,7 +166,7 @@ SERVER_PROCESS::SetupListenPort(
|
|||
{
|
||||
//
|
||||
// user set the env variable but did not give value, let's set it up
|
||||
//
|
||||
//
|
||||
pEnvironmentVarTable->DeleteKey(ASPNETCORE_PORT_ENV_STR);
|
||||
}
|
||||
pEntry->Dereference();
|
||||
|
|
@ -209,20 +208,16 @@ Finished:
|
|||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_PROCESS_START_SUCCESS,
|
||||
ASPNETCORE_EVENT_PROCESS_START_PORTSETUP_ERROR_MSG,
|
||||
m_struAppFullPath.QueryStr(),
|
||||
m_struPhysicalPath.QueryStr(),
|
||||
m_dwPort,
|
||||
MIN_PORT,
|
||||
MAX_PORT,
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_PROCESS_START_SUCCESS,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
hr);
|
||||
}
|
||||
|
||||
return hr;
|
||||
|
|
@ -363,10 +358,10 @@ SERVER_PROCESS::OutputEnvironmentVariables
|
|||
ENVIRONMENT_VAR_ENTRY* pEntry = NULL;
|
||||
|
||||
DBG_ASSERT(pmszOutput);
|
||||
DBG_ASSERT(pEnvironmentVarTable); // We added some startup variables
|
||||
DBG_ASSERT(pEnvironmentVarTable); // We added some startup variables
|
||||
DBG_ASSERT(pEnvironmentVarTable->Count() >0);
|
||||
|
||||
// cleanup, as we may in retry logic
|
||||
// cleanup, as we may in retry logic
|
||||
pmszOutput->Reset();
|
||||
|
||||
pszEnvironmentVariables = GetEnvironmentStringsW();
|
||||
|
|
@ -625,7 +620,7 @@ SERVER_PROCESS::PostStartCheck(
|
|||
if(!fProcessMatch)
|
||||
{
|
||||
//
|
||||
// process that we created is not listening
|
||||
// process that we created is not listening
|
||||
// on the port we specified.
|
||||
//
|
||||
fReady = FALSE;
|
||||
|
|
@ -667,7 +662,7 @@ SERVER_PROCESS::PostStartCheck(
|
|||
// This is needed because, the child process might have crashed/exited between
|
||||
// the previous call to checkIfServerIsUp and RegisterProcessWait
|
||||
// and we would not know about it.
|
||||
//
|
||||
//
|
||||
|
||||
hr = CheckIfServerIsUp(m_dwPort, &dwActualProcessId, &fReady);
|
||||
|
||||
|
|
@ -685,8 +680,8 @@ SERVER_PROCESS::PostStartCheck(
|
|||
}
|
||||
|
||||
//
|
||||
// ready to mark the server process ready but before this,
|
||||
// create and initialize the FORWARDER_CONNECTION
|
||||
// ready to mark the server process ready but before this,
|
||||
// create and initialize the FORWARDER_CONNECTION
|
||||
//
|
||||
if (m_pForwarderConnection == NULL)
|
||||
{
|
||||
|
|
@ -744,7 +739,6 @@ SERVER_PROCESS::StartProcess(
|
|||
STARTUPINFOW startupInfo = {0};
|
||||
DWORD dwRetryCount = 2; // should we allow customer to config it
|
||||
DWORD dwCreationFlags = 0;
|
||||
STACK_STRU( strEventMsg, 256);
|
||||
MULTISZ mszNewEnvironment;
|
||||
ENVIRONMENT_VAR_HASH *pHashTable = NULL;
|
||||
PWSTR pStrStage = NULL;
|
||||
|
|
@ -890,17 +884,13 @@ 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)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_PROCESS_START_SUCCESS,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_PROCESS_START_SUCCESS,
|
||||
ASPNETCORE_EVENT_PROCESS_START_SUCCESS_MSG,
|
||||
m_struAppFullPath.QueryStr(),
|
||||
m_dwProcessId,
|
||||
m_dwPort);
|
||||
|
||||
goto Finished;
|
||||
|
||||
|
|
@ -911,21 +901,17 @@ SERVER_PROCESS::StartProcess(
|
|||
dwRetryCount = 0;
|
||||
}
|
||||
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_PROCESS_START_ERROR_MSG,
|
||||
m_struAppFullPath.QueryStr(),
|
||||
m_struPhysicalPath.QueryStr(),
|
||||
m_struCommandLine.QueryStr(),
|
||||
pStrStage,
|
||||
hr,
|
||||
m_dwPort,
|
||||
dwRetryCount)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_WARNING_TYPE,
|
||||
ASPNETCORE_EVENT_PROCESS_START_ERROR,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_WARNING_TYPE,
|
||||
ASPNETCORE_EVENT_PROCESS_START_ERROR,
|
||||
ASPNETCORE_EVENT_PROCESS_START_ERROR_MSG,
|
||||
m_struAppFullPath.QueryStr(),
|
||||
m_struPhysicalPath.QueryStr(),
|
||||
m_struCommandLine.QueryStr(),
|
||||
pStrStage,
|
||||
hr,
|
||||
m_dwPort,
|
||||
dwRetryCount);
|
||||
|
||||
if (processInformation.hThread != NULL)
|
||||
{
|
||||
|
|
@ -960,18 +946,14 @@ Finished:
|
|||
m_Timer.CancelTimer();
|
||||
}
|
||||
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_PROCESS_START_FAILURE,
|
||||
ASPNETCORE_EVENT_PROCESS_START_FAILURE_MSG,
|
||||
m_struAppFullPath.QueryStr(),
|
||||
m_struPhysicalPath.QueryStr(),
|
||||
m_struCommandLine.QueryStr(),
|
||||
m_dwPort)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_PROCESS_START_FAILURE,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
m_dwPort);
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
|
@ -1101,17 +1083,12 @@ Finished:
|
|||
if (m_fStdoutLogEnabled)
|
||||
{
|
||||
// Log the error
|
||||
STRU strEventMsg;
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_WARNING_TYPE,
|
||||
ASPNETCORE_EVENT_CONFIG_ERROR,
|
||||
ASPNETCORE_EVENT_INVALID_STDOUT_LOG_FILE_MSG,
|
||||
m_struFullLogFile.IsEmpty()? m_struLogFile.QueryStr() : m_struFullLogFile.QueryStr(),
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_WARNING_TYPE,
|
||||
ASPNETCORE_EVENT_CONFIG_ERROR,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
hr);
|
||||
}
|
||||
// The log file was not created yet in case of failure. No need to clean it
|
||||
m_struFullLogFile.Reset();
|
||||
|
|
@ -1264,7 +1241,7 @@ SERVER_PROCESS::SendSignal(
|
|||
|
||||
if (m_hShutdownHandle == NULL)
|
||||
{
|
||||
// since we cannot open the process. let's terminate the process
|
||||
// since we cannot open the process. let's terminate the process
|
||||
hr = HRESULT_FROM_WIN32(GetLastError());
|
||||
goto Finished;
|
||||
}
|
||||
|
|
@ -1358,7 +1335,7 @@ SERVER_PROCESS::StopProcess(
|
|||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
BOOL
|
||||
SERVER_PROCESS::IsDebuggerIsAttached(
|
||||
VOID
|
||||
)
|
||||
|
|
@ -1441,7 +1418,7 @@ SERVER_PROCESS::IsDebuggerIsAttached(
|
|||
hr = HRESULT_FROM_WIN32(ERROR_CREATE_FAILED);
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
|
||||
for (DWORD i=0; i<processList->NumberOfProcessIdsInList; i++)
|
||||
{
|
||||
dwPid = (DWORD)processList->ProcessIdList[i];
|
||||
|
|
@ -1481,7 +1458,7 @@ Finished:
|
|||
return fDebuggerPresent;
|
||||
}
|
||||
|
||||
HRESULT
|
||||
HRESULT
|
||||
SERVER_PROCESS::GetChildProcessHandles(
|
||||
VOID
|
||||
)
|
||||
|
|
@ -1560,7 +1537,7 @@ SERVER_PROCESS::GetChildProcessHandles(
|
|||
hr = HRESULT_FROM_WIN32(ERROR_CREATE_FAILED);
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
|
||||
for (DWORD i=0; i<processList->NumberOfProcessIdsInList; i++)
|
||||
{
|
||||
dwPid = (DWORD)processList->ProcessIdList[i];
|
||||
|
|
@ -1569,8 +1546,8 @@ SERVER_PROCESS::GetChildProcessHandles(
|
|||
{
|
||||
m_hChildProcessHandles[m_cChildProcess] = OpenProcess(
|
||||
PROCESS_QUERY_INFORMATION | SYNCHRONIZE | PROCESS_TERMINATE | PROCESS_DUP_HANDLE,
|
||||
FALSE,
|
||||
dwPid
|
||||
FALSE,
|
||||
dwPid
|
||||
);
|
||||
m_dwChildProcessIds[m_cChildProcess] = dwPid;
|
||||
m_cChildProcess ++;
|
||||
|
|
@ -1650,7 +1627,7 @@ SERVER_PROCESS::StopAllProcessesInJobObject(
|
|||
// some error
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
|
||||
for (DWORD i=0; i<processList->NumberOfProcessIdsInList; i++)
|
||||
{
|
||||
if (dwWorkerProcessPid != (DWORD)processList->ProcessIdList[i])
|
||||
|
|
@ -1791,7 +1768,7 @@ SERVER_PROCESS::~SERVER_PROCESS()
|
|||
m_pEnvironmentVarTable = NULL;
|
||||
// no need to free m_pEnvironmentVarTable, as it references to
|
||||
// the same hash table hold by configuration.
|
||||
// the hashtable memory will be freed once onfiguration got recycled
|
||||
// the hashtable memory will be freed once onfiguration got recycled
|
||||
|
||||
if (m_pProcessManager != NULL)
|
||||
{
|
||||
|
|
@ -1812,7 +1789,7 @@ SERVER_PROCESS::~SERVER_PROCESS()
|
|||
{
|
||||
m_Timer.CancelTimer();
|
||||
}
|
||||
|
||||
|
||||
if (!m_fStdoutLogEnabled && !m_struFullLogFile.IsEmpty())
|
||||
{
|
||||
WIN32_FIND_DATA fileData;
|
||||
|
|
@ -1863,7 +1840,7 @@ SERVER_PROCESS::RegisterProcessWait(
|
|||
(WAITORTIMERCALLBACKFUNC)&ProcessHandleCallback,
|
||||
this,
|
||||
INFINITE,
|
||||
WT_EXECUTEONLYONCE | WT_EXECUTEINWAITTHREAD
|
||||
WT_EXECUTEONLYONCE | WT_EXECUTEINWAITTHREAD
|
||||
);
|
||||
|
||||
if (status < 0)
|
||||
|
|
@ -1917,7 +1894,6 @@ SERVER_PROCESS::SendShutdownHttpMessage( VOID )
|
|||
STRU strUrl;
|
||||
DWORD dwStatusCode = 0;
|
||||
DWORD dwSize = sizeof(dwStatusCode);
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
|
||||
hSession = WinHttpOpen(L"",
|
||||
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
|
||||
|
|
@ -2020,16 +1996,12 @@ SERVER_PROCESS::SendShutdownHttpMessage( VOID )
|
|||
}
|
||||
|
||||
// log
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST,
|
||||
ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST_MSG,
|
||||
m_dwProcessId,
|
||||
dwStatusCode)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_INFORMATION_TYPE,
|
||||
ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
dwStatusCode);
|
||||
|
||||
Finished:
|
||||
if (hRequest)
|
||||
|
|
@ -2120,8 +2092,6 @@ SERVER_PROCESS::TerminateBackendProcess(
|
|||
VOID
|
||||
)
|
||||
{
|
||||
STACK_STRU(strEventMsg, 256);
|
||||
|
||||
if (InterlockedCompareExchange(&m_lStopping, 1L, 0L) == 0L)
|
||||
{
|
||||
// backend process will be terminated, remove the waitcallback
|
||||
|
|
@ -2129,7 +2099,7 @@ SERVER_PROCESS::TerminateBackendProcess(
|
|||
{
|
||||
UnregisterWait(m_hProcessWaitHandle);
|
||||
|
||||
// as we skipped process exit callback (ProcessHandleCallback),
|
||||
// as we skipped process exit callback (ProcessHandleCallback),
|
||||
// need to dereference the object otherwise memory leak
|
||||
DereferenceServerProcess();
|
||||
|
||||
|
|
@ -2144,14 +2114,10 @@ SERVER_PROCESS::TerminateBackendProcess(
|
|||
}
|
||||
|
||||
// log a warning for ungraceful shutdown
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
UTILITY::LogEventF(g_hEventLog,
|
||||
EVENTLOG_WARNING_TYPE,
|
||||
ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE,
|
||||
ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE_MSG,
|
||||
m_dwProcessId)))
|
||||
{
|
||||
UTILITY::LogEvent(g_hEventLog,
|
||||
EVENTLOG_WARNING_TYPE,
|
||||
ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
m_dwProcessId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue