Flow request trace context to CreateApplication (#1480)

This commit is contained in:
Pavel Krymets 2018-10-09 16:11:52 -07:00 committed by GitHub
parent 23db53eae6
commit f2fbd803b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 16 deletions

View File

@ -31,13 +31,17 @@ public:
HRESULT Execute(
_In_ IHttpServer *pServer,
_In_ const IHttpApplication *pHttpApplication,
_Outptr_ IAPPLICATION **pApplication) const noexcept
_In_ IHttpContext *pHttpContext,
_Outptr_ IAPPLICATION **pApplication) const
{
std::array<APPLICATION_PARAMETER, 1> parameters {
{"InProcessExeLocation", m_location.data()}
std::array<APPLICATION_PARAMETER, 2> parameters {
{
{"InProcessExeLocation", m_location.data()},
{"TraceContext", pHttpContext->GetTraceContext()}
}
};
return m_pfnAspNetCoreCreateApplication(pServer, pHttpApplication, parameters.data(), static_cast<DWORD>(parameters.size()), pApplication);
return m_pfnAspNetCoreCreateApplication(pServer, pHttpContext->GetApplication(), parameters.data(), static_cast<DWORD>(parameters.size()), pApplication);
}
private:

View File

@ -43,7 +43,7 @@ APPLICATION_INFO::CreateHandler(
// check if other thread created application
RETURN_IF_FAILED(hr = TryCreateHandler(pHttpContext, pHandler));
// In some cases (adding and removing app_offline quickly) application might start and stop immediately
// In some cases (adding and removing app_offline quickly) application might start and stop immediately
// so retry until we get valid handler or error
while (hr != S_OK)
{
@ -59,7 +59,7 @@ APPLICATION_INFO::CreateHandler(
m_pApplicationFactory = nullptr;
}
RETURN_IF_FAILED(CreateApplication(*pHttpContext.GetApplication()));
RETURN_IF_FAILED(CreateApplication(pHttpContext));
RETURN_IF_FAILED(hr = TryCreateHandler(pHttpContext, pHandler));
}
@ -69,8 +69,9 @@ APPLICATION_INFO::CreateHandler(
}
HRESULT
APPLICATION_INFO::CreateApplication(const IHttpApplication& pHttpApplication)
APPLICATION_INFO::CreateApplication(IHttpContext& pHttpContext)
{
auto& pHttpApplication = *pHttpContext.GetApplication();
if (AppOfflineApplication::ShouldBeStarted(pHttpApplication))
{
LOG_INFO(L"Detected app_offline file, creating polling application");
@ -85,7 +86,7 @@ APPLICATION_INFO::CreateApplication(const IHttpApplication& pHttpApplication)
const WebConfigConfigurationSource configurationSource(m_pServer.GetAdminManager(), pHttpApplication);
ShimOptions options(configurationSource);
const auto hr = TryCreateApplication(pHttpApplication, options);
const auto hr = TryCreateApplication(pHttpContext, options);
if (FAILED_LOG(hr))
{
@ -130,15 +131,15 @@ APPLICATION_INFO::CreateApplication(const IHttpApplication& pHttpApplication)
}
HRESULT
APPLICATION_INFO::TryCreateApplication(const IHttpApplication& pHttpApplication, const ShimOptions& options)
APPLICATION_INFO::TryCreateApplication(IHttpContext& pHttpContext, const ShimOptions& options)
{
RETURN_IF_FAILED(m_handlerResolver.GetApplicationFactory(pHttpApplication, m_pApplicationFactory, options));
RETURN_IF_FAILED(m_handlerResolver.GetApplicationFactory(*pHttpContext.GetApplication(), m_pApplicationFactory, options));
LOG_INFO(L"Creating handler application");
IAPPLICATION * newApplication;
RETURN_IF_FAILED(m_pApplicationFactory->Execute(
&m_pServer,
&pHttpApplication,
&pHttpContext,
&newApplication));
m_pApplication.reset(newApplication);

View File

@ -50,7 +50,7 @@ public:
CreateHandler(
IHttpContext& pHttpContext,
std::unique_ptr<IREQUEST_HANDLER, IREQUEST_HANDLER_DELETER>& pHandler);
bool ConfigurationPathApplies(const std::wstring& path)
{
// We need to check that the last character of the config path
@ -67,17 +67,17 @@ public:
}
private:
HRESULT
TryCreateHandler(
IHttpContext& pHttpContext,
std::unique_ptr<IREQUEST_HANDLER, IREQUEST_HANDLER_DELETER>& pHandler);
HRESULT
CreateApplication(const IHttpApplication& pHttpApplication);
CreateApplication(IHttpContext& pHttpContext);
HRESULT
TryCreateApplication(const IHttpApplication& pHttpApplication, const ShimOptions& options);
TryCreateApplication(IHttpContext& pHttpContext, const ShimOptions& options);
IHttpServer &m_pServer;
HandlerResolver &m_handlerResolver;