Add tracing to shimconfig (#964)

This commit is contained in:
Pavel Krymets 2018-06-25 08:44:02 -07:00 committed by GitHub
parent aeebcdefc1
commit d3d257b90e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 80 deletions

View File

@ -24,66 +24,52 @@ class ASPNETCORE_SHIM_CONFIG
{ {
public: public:
virtual virtual
~ASPNETCORE_SHIM_CONFIG(); ~ASPNETCORE_SHIM_CONFIG() = default;
HRESULT HRESULT
Populate( Populate(
IHttpServer *pHttpServer, IHttpServer *pHttpServer,
IHttpApplication *pHttpContext IHttpApplication *pHttpApplication
); );
STRU* STRU*
QueryApplicationPhysicalPath( QueryApplicationPhysicalPath()
VOID
)
{ {
return &m_struApplicationPhysicalPath; return &m_struApplicationPhysicalPath;
} }
STRU* STRU*
QueryApplicationPath( QueryApplicationPath()
VOID
)
{ {
return &m_struApplication; return &m_struApplication;
} }
STRU* STRU*
QueryConfigPath( QueryConfigPath()
VOID
)
{ {
return &m_struConfigPath; return &m_struConfigPath;
} }
STRU* STRU*
QueryProcessPath( QueryProcessPath()
VOID
)
{ {
return &m_struProcessPath; return &m_struProcessPath;
} }
STRU* STRU*
QueryArguments( QueryArguments()
VOID
)
{ {
return &m_struArguments; return &m_struArguments;
} }
APP_HOSTING_MODEL APP_HOSTING_MODEL
QueryHostingModel( QueryHostingModel()
VOID
)
{ {
return m_hostingModel; return m_hostingModel;
} }
STRU* STRU*
QueryHandlerVersion( QueryHandlerVersion()
VOID
)
{ {
return &m_struHandlerVersion; return &m_struHandlerVersion;
} }

View File

@ -7,63 +7,36 @@
#include "hostfxr_utility.h" #include "hostfxr_utility.h"
#include "ahutil.h" #include "ahutil.h"
ASPNETCORE_SHIM_CONFIG::~ASPNETCORE_SHIM_CONFIG()
{
}
HRESULT HRESULT
ASPNETCORE_SHIM_CONFIG::Populate( ASPNETCORE_SHIM_CONFIG::Populate(
IHttpServer *pHttpServer, IHttpServer *pHttpServer,
IHttpApplication *pHttpApplication IHttpApplication *pHttpApplication
) )
{ {
STACK_STRU(strHostingModel, 300); STACK_STRU(strHostingModel, 12);
HRESULT hr = S_OK;
STRU strApplicationFullPath; STRU strApplicationFullPath;
IAppHostAdminManager *pAdminManager = NULL; IAppHostAdminManager *pAdminManager = NULL;
IAppHostElement *pAspNetCoreElement = NULL; CComPtr<IAppHostElement> pAspNetCoreElement;
BSTR bstrAspNetCoreSection = NULL;
pAdminManager = pHttpServer->GetAdminManager(); pAdminManager = pHttpServer->GetAdminManager();
hr = m_struConfigPath.Copy(pHttpApplication->GetAppConfigPath()); RETURN_IF_FAILED(m_struConfigPath.Copy(pHttpApplication->GetAppConfigPath()));
if (FAILED(hr)) RETURN_IF_FAILED(m_struApplicationPhysicalPath.Copy(pHttpApplication->GetApplicationPhysicalPath()));
{
goto Finished;
}
hr = m_struApplicationPhysicalPath.Copy(pHttpApplication->GetApplicationPhysicalPath()); const CComBSTR bstrAspNetCoreSection = CS_ASPNETCORE_SECTION;
if (FAILED(hr))
{
goto Finished;
}
bstrAspNetCoreSection = SysAllocString(CS_ASPNETCORE_SECTION); RETURN_IF_FAILED(pAdminManager->GetAdminSection(bstrAspNetCoreSection,
hr = pAdminManager->GetAdminSection(bstrAspNetCoreSection,
m_struConfigPath.QueryStr(), m_struConfigPath.QueryStr(),
&pAspNetCoreElement); &pAspNetCoreElement));
if (FAILED(hr))
{
goto Finished;
}
hr = GetElementStringProperty(pAspNetCoreElement, RETURN_IF_FAILED(GetElementStringProperty(pAspNetCoreElement,
CS_ASPNETCORE_PROCESS_EXE_PATH, CS_ASPNETCORE_PROCESS_EXE_PATH,
&m_struProcessPath); &m_struProcessPath));
if (FAILED(hr))
{
goto Finished;
}
hr = GetElementStringProperty(pAspNetCoreElement, // Swallow this error for backward compatability
// Use default behavior for empty string
GetElementStringProperty(pAspNetCoreElement,
CS_ASPNETCORE_HOSTING_MODEL, CS_ASPNETCORE_HOSTING_MODEL,
&strHostingModel); &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)) if (strHostingModel.IsEmpty() || strHostingModel.Equals(L"outofprocess", TRUE))
{ {
@ -76,27 +49,14 @@ ASPNETCORE_SHIM_CONFIG::Populate(
else else
{ {
// block unknown hosting value // block unknown hosting value
hr = HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); RETURN_IF_FAILED(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED));
goto Finished;
} }
hr = GetElementStringProperty(pAspNetCoreElement, RETURN_IF_FAILED(GetElementStringProperty(pAspNetCoreElement,
CS_ASPNETCORE_PROCESS_ARGUMENTS, CS_ASPNETCORE_PROCESS_ARGUMENTS,
&m_struArguments); &m_struArguments));
if (FAILED(hr))
{
goto Finished;
}
hr = ConfigUtility::FindHandlerVersion(pAspNetCoreElement, &m_struHandlerVersion); RETURN_IF_FAILED(ConfigUtility::FindHandlerVersion(pAspNetCoreElement, &m_struHandlerVersion));
Finished: return S_OK;
if (pAspNetCoreElement != NULL)
{
pAspNetCoreElement->Release();
pAspNetCoreElement = NULL;
}
return hr;
} }