Changes PostCompletion to handle OnAsyncCompletion after managed request has completed. (#212)
This commit is contained in:
parent
bfb2c86cda
commit
332b108f41
|
|
@ -9,6 +9,7 @@ public:
|
||||||
IHttpContext* pHttpContext,
|
IHttpContext* pHttpContext,
|
||||||
PVOID pvManagedContext
|
PVOID pvManagedContext
|
||||||
);
|
);
|
||||||
|
|
||||||
~IN_PROCESS_STORED_CONTEXT();
|
~IN_PROCESS_STORED_CONTEXT();
|
||||||
|
|
||||||
virtual
|
virtual
|
||||||
|
|
@ -46,6 +47,26 @@ public:
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
QueryIsManagedRequestComplete(
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
IndicateManagedRequestComplete(
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
REQUEST_NOTIFICATION_STATUS
|
||||||
|
QueryAsyncCompletionStatus(
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
SetAsyncCompletionStatus(
|
||||||
|
REQUEST_NOTIFICATION_STATUS requestNotificationStatus
|
||||||
|
);
|
||||||
|
|
||||||
static
|
static
|
||||||
HRESULT
|
HRESULT
|
||||||
GetInProcessStoredContext(
|
GetInProcessStoredContext(
|
||||||
|
|
@ -63,5 +84,7 @@ public:
|
||||||
private:
|
private:
|
||||||
PVOID m_pManagedHttpContext;
|
PVOID m_pManagedHttpContext;
|
||||||
IHttpContext* m_pHttpContext;
|
IHttpContext* m_pHttpContext;
|
||||||
|
BOOL m_fManagedRequestComplete;
|
||||||
|
REQUEST_NOTIFICATION_STATUS m_requestNotificationStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ IN_PROCESS_APPLICATION::OnAsyncCompletion(
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
IN_PROCESS_STORED_CONTEXT* pInProcessStoredContext = NULL;
|
IN_PROCESS_STORED_CONTEXT* pInProcessStoredContext = NULL;
|
||||||
|
REQUEST_NOTIFICATION_STATUS dwRequestNotificationStatus = RQ_NOTIFICATION_CONTINUE;
|
||||||
|
|
||||||
hr = IN_PROCESS_STORED_CONTEXT::GetInProcessStoredContext(pHttpContext, &pInProcessStoredContext);
|
hr = IN_PROCESS_STORED_CONTEXT::GetInProcessStoredContext(pHttpContext, &pInProcessStoredContext);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
|
|
@ -38,9 +39,18 @@ IN_PROCESS_APPLICATION::OnAsyncCompletion(
|
||||||
pHttpContext->GetResponse()->SetStatus(500, "Internal Server Error", 19, hr);
|
pHttpContext->GetResponse()->SetStatus(500, "Internal Server Error", 19, hr);
|
||||||
return RQ_NOTIFICATION_FINISH_REQUEST;
|
return RQ_NOTIFICATION_FINISH_REQUEST;
|
||||||
}
|
}
|
||||||
|
else if (pInProcessStoredContext->QueryIsManagedRequestComplete())
|
||||||
// Call the managed handler for async completion.
|
{
|
||||||
return m_AsyncCompletionHandler(pInProcessStoredContext->QueryManagedHttpContext(), hrCompletionStatus, cbCompletion);
|
// means PostCompletion has been called and this is the associated callback.
|
||||||
|
dwRequestNotificationStatus = pInProcessStoredContext->QueryAsyncCompletionStatus();
|
||||||
|
// TODO cleanup whatever disconnect listener there is
|
||||||
|
return dwRequestNotificationStatus;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Call the managed handler for async completion.
|
||||||
|
return m_AsyncCompletionHandler(pInProcessStoredContext->QueryManagedHttpContext(), hrCompletionStatus, cbCompletion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,10 @@ IN_PROCESS_STORED_CONTEXT::IN_PROCESS_STORED_CONTEXT(
|
||||||
PVOID pMangedHttpContext
|
PVOID pMangedHttpContext
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
// TODO if we want to go by IIS patterns, we should have these in a separate initialize function
|
||||||
m_pManagedHttpContext = pMangedHttpContext;
|
m_pManagedHttpContext = pMangedHttpContext;
|
||||||
m_pHttpContext = pHttpContext;
|
m_pHttpContext = pHttpContext;
|
||||||
|
m_fManagedRequestComplete = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
IN_PROCESS_STORED_CONTEXT::~IN_PROCESS_STORED_CONTEXT()
|
IN_PROCESS_STORED_CONTEXT::~IN_PROCESS_STORED_CONTEXT()
|
||||||
|
|
@ -32,6 +34,38 @@ IN_PROCESS_STORED_CONTEXT::QueryHttpContext(
|
||||||
return m_pHttpContext;
|
return m_pHttpContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
IN_PROCESS_STORED_CONTEXT::QueryIsManagedRequestComplete(
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return m_fManagedRequestComplete;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
IN_PROCESS_STORED_CONTEXT::IndicateManagedRequestComplete(
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
m_fManagedRequestComplete = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
REQUEST_NOTIFICATION_STATUS
|
||||||
|
IN_PROCESS_STORED_CONTEXT::QueryAsyncCompletionStatus(
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return m_requestNotificationStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
IN_PROCESS_STORED_CONTEXT::SetAsyncCompletionStatus(
|
||||||
|
REQUEST_NOTIFICATION_STATUS requestNotificationStatus
|
||||||
|
)
|
||||||
|
{
|
||||||
|
m_requestNotificationStatus = requestNotificationStatus;
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT
|
HRESULT
|
||||||
IN_PROCESS_STORED_CONTEXT::GetInProcessStoredContext(
|
IN_PROCESS_STORED_CONTEXT::GetInProcessStoredContext(
|
||||||
IHttpContext* pHttpContext,
|
IHttpContext* pHttpContext,
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,30 @@ http_post_completion(
|
||||||
return pHttpContext->PostCompletion(cbBytes);
|
return pHttpContext->PostCompletion(cbBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EXTERN_C __MIDL_DECLSPEC_DLLEXPORT
|
||||||
|
HRESULT
|
||||||
|
http_set_completion_status(
|
||||||
|
_In_ IHttpContext* pHttpContext,
|
||||||
|
REQUEST_NOTIFICATION_STATUS requestNotificationStatus
|
||||||
|
)
|
||||||
|
{
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
IN_PROCESS_STORED_CONTEXT* pInProcessStoredContext = NULL;
|
||||||
|
|
||||||
|
hr = IN_PROCESS_STORED_CONTEXT::GetInProcessStoredContext(
|
||||||
|
pHttpContext,
|
||||||
|
&pInProcessStoredContext
|
||||||
|
);
|
||||||
|
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
pInProcessStoredContext->IndicateManagedRequestComplete();
|
||||||
|
pInProcessStoredContext->SetAsyncCompletionStatus(requestNotificationStatus);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
EXTERN_C __MIDL_DECLSPEC_DLLEXPORT
|
EXTERN_C __MIDL_DECLSPEC_DLLEXPORT
|
||||||
HRESULT
|
HRESULT
|
||||||
http_set_managed_context(
|
http_set_managed_context(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue