From d3d257b90efd4df95557842b0b6c10c2253edd26 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 25 Jun 2018 08:44:02 -0700 Subject: [PATCH] Add tracing to shimconfig (#964) --- .../AspNetCore/Inc/aspnetcore_shim_config.h | 32 +++----- .../AspNetCore/src/aspnetcore_shim_config.cpp | 74 +++++-------------- 2 files changed, 26 insertions(+), 80 deletions(-) diff --git a/src/AspNetCoreModuleV2/AspNetCore/Inc/aspnetcore_shim_config.h b/src/AspNetCoreModuleV2/AspNetCore/Inc/aspnetcore_shim_config.h index 7560df38d1..3fde28273f 100644 --- a/src/AspNetCoreModuleV2/AspNetCore/Inc/aspnetcore_shim_config.h +++ b/src/AspNetCoreModuleV2/AspNetCore/Inc/aspnetcore_shim_config.h @@ -24,66 +24,52 @@ class ASPNETCORE_SHIM_CONFIG { public: virtual - ~ASPNETCORE_SHIM_CONFIG(); + ~ASPNETCORE_SHIM_CONFIG() = default; HRESULT Populate( IHttpServer *pHttpServer, - IHttpApplication *pHttpContext + IHttpApplication *pHttpApplication ); STRU* - QueryApplicationPhysicalPath( - VOID - ) + QueryApplicationPhysicalPath() { return &m_struApplicationPhysicalPath; } STRU* - QueryApplicationPath( - VOID - ) + QueryApplicationPath() { return &m_struApplication; } STRU* - QueryConfigPath( - VOID - ) + QueryConfigPath() { return &m_struConfigPath; } STRU* - QueryProcessPath( - VOID - ) + QueryProcessPath() { return &m_struProcessPath; } STRU* - QueryArguments( - VOID - ) + QueryArguments() { return &m_struArguments; } APP_HOSTING_MODEL - QueryHostingModel( - VOID - ) + QueryHostingModel() { return m_hostingModel; } STRU* - QueryHandlerVersion( - VOID - ) + QueryHandlerVersion() { return &m_struHandlerVersion; } diff --git a/src/AspNetCoreModuleV2/AspNetCore/src/aspnetcore_shim_config.cpp b/src/AspNetCoreModuleV2/AspNetCore/src/aspnetcore_shim_config.cpp index 21c3bd997e..0cfc9b4133 100644 --- a/src/AspNetCoreModuleV2/AspNetCore/src/aspnetcore_shim_config.cpp +++ b/src/AspNetCoreModuleV2/AspNetCore/src/aspnetcore_shim_config.cpp @@ -7,63 +7,36 @@ #include "hostfxr_utility.h" #include "ahutil.h" -ASPNETCORE_SHIM_CONFIG::~ASPNETCORE_SHIM_CONFIG() -{ -} - HRESULT ASPNETCORE_SHIM_CONFIG::Populate( IHttpServer *pHttpServer, IHttpApplication *pHttpApplication ) { - STACK_STRU(strHostingModel, 300); - HRESULT hr = S_OK; + STACK_STRU(strHostingModel, 12); STRU strApplicationFullPath; IAppHostAdminManager *pAdminManager = NULL; - IAppHostElement *pAspNetCoreElement = NULL; - BSTR bstrAspNetCoreSection = NULL; + CComPtr pAspNetCoreElement; pAdminManager = pHttpServer->GetAdminManager(); - hr = m_struConfigPath.Copy(pHttpApplication->GetAppConfigPath()); - if (FAILED(hr)) - { - goto Finished; - } + RETURN_IF_FAILED(m_struConfigPath.Copy(pHttpApplication->GetAppConfigPath())); + RETURN_IF_FAILED(m_struApplicationPhysicalPath.Copy(pHttpApplication->GetApplicationPhysicalPath())); - hr = m_struApplicationPhysicalPath.Copy(pHttpApplication->GetApplicationPhysicalPath()); - if (FAILED(hr)) - { - goto Finished; - } + const CComBSTR bstrAspNetCoreSection = CS_ASPNETCORE_SECTION; - bstrAspNetCoreSection = SysAllocString(CS_ASPNETCORE_SECTION); - - hr = pAdminManager->GetAdminSection(bstrAspNetCoreSection, + RETURN_IF_FAILED(pAdminManager->GetAdminSection(bstrAspNetCoreSection, m_struConfigPath.QueryStr(), - &pAspNetCoreElement); - if (FAILED(hr)) - { - goto Finished; - } + &pAspNetCoreElement)); - hr = GetElementStringProperty(pAspNetCoreElement, + RETURN_IF_FAILED(GetElementStringProperty(pAspNetCoreElement, CS_ASPNETCORE_PROCESS_EXE_PATH, - &m_struProcessPath); - if (FAILED(hr)) - { - goto Finished; - } + &m_struProcessPath)); - hr = GetElementStringProperty(pAspNetCoreElement, + // Swallow this error for backward compatability + // Use default behavior for empty string + GetElementStringProperty(pAspNetCoreElement, CS_ASPNETCORE_HOSTING_MODEL, &strHostingModel); - if (FAILED(hr)) - { - // Swallow this error for backward compatability - // Use default behavior for empty string - hr = S_OK; - } if (strHostingModel.IsEmpty() || strHostingModel.Equals(L"outofprocess", TRUE)) { @@ -76,27 +49,14 @@ ASPNETCORE_SHIM_CONFIG::Populate( else { // block unknown hosting value - hr = HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - goto Finished; + RETURN_IF_FAILED(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)); } - hr = GetElementStringProperty(pAspNetCoreElement, + RETURN_IF_FAILED(GetElementStringProperty(pAspNetCoreElement, CS_ASPNETCORE_PROCESS_ARGUMENTS, - &m_struArguments); - if (FAILED(hr)) - { - goto Finished; - } + &m_struArguments)); - hr = ConfigUtility::FindHandlerVersion(pAspNetCoreElement, &m_struHandlerVersion); + RETURN_IF_FAILED(ConfigUtility::FindHandlerVersion(pAspNetCoreElement, &m_struHandlerVersion)); -Finished: - - if (pAspNetCoreElement != NULL) - { - pAspNetCoreElement->Release(); - pAspNetCoreElement = NULL; - } - - return hr; + return S_OK; }