Guard OnAsyncCompletion from completing request before OnExecuteRequestHandler exits (#1489)
This commit is contained in:
parent
ab124fc344
commit
bfa583a9aa
|
|
@ -7,6 +7,7 @@
|
||||||
#include "applicationinfo.h"
|
#include "applicationinfo.h"
|
||||||
#include "exceptions.h"
|
#include "exceptions.h"
|
||||||
#include "DisconnectHandler.h"
|
#include "DisconnectHandler.h"
|
||||||
|
#include "SRWExclusiveLock.h"
|
||||||
|
|
||||||
extern BOOL g_fInShutdown;
|
extern BOOL g_fInShutdown;
|
||||||
|
|
||||||
|
|
@ -67,6 +68,7 @@ ASPNET_CORE_PROXY_MODULE::ASPNET_CORE_PROXY_MODULE(HTTP_MODULE_ID moduleId, std:
|
||||||
m_moduleId(moduleId),
|
m_moduleId(moduleId),
|
||||||
m_pDisconnectHandler(nullptr)
|
m_pDisconnectHandler(nullptr)
|
||||||
{
|
{
|
||||||
|
InitializeSRWLock(&m_requestLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASPNET_CORE_PROXY_MODULE::~ASPNET_CORE_PROXY_MODULE()
|
ASPNET_CORE_PROXY_MODULE::~ASPNET_CORE_PROXY_MODULE()
|
||||||
|
|
@ -84,6 +86,9 @@ ASPNET_CORE_PROXY_MODULE::OnExecuteRequestHandler(
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
REQUEST_NOTIFICATION_STATUS retVal = RQ_NOTIFICATION_CONTINUE;
|
REQUEST_NOTIFICATION_STATUS retVal = RQ_NOTIFICATION_CONTINUE;
|
||||||
|
|
||||||
|
// We don't want OnAsyncCompletion to complete request before OnExecuteRequestHandler exits
|
||||||
|
auto lock = SRWExclusiveLock(m_requestLock);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (g_fInShutdown)
|
if (g_fInShutdown)
|
||||||
|
|
@ -134,6 +139,9 @@ ASPNET_CORE_PROXY_MODULE::OnAsyncCompletion(
|
||||||
IHttpCompletionInfo * pCompletionInfo
|
IHttpCompletionInfo * pCompletionInfo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
// We don't want OnAsyncCompletion to complete request before OnExecuteRequestHandler exits
|
||||||
|
auto lock = SRWExclusiveLock(m_requestLock);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return HandleNotificationStatus(m_pHandler->OnAsyncCompletion(
|
return HandleNotificationStatus(m_pHandler->OnAsyncCompletion(
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ class ASPNET_CORE_PROXY_MODULE : NonCopyable, public CHttpModule
|
||||||
std::unique_ptr<IREQUEST_HANDLER, IREQUEST_HANDLER_DELETER> m_pHandler;
|
std::unique_ptr<IREQUEST_HANDLER, IREQUEST_HANDLER_DELETER> m_pHandler;
|
||||||
HTTP_MODULE_ID m_moduleId;
|
HTTP_MODULE_ID m_moduleId;
|
||||||
DisconnectHandler * m_pDisconnectHandler;
|
DisconnectHandler * m_pDisconnectHandler;
|
||||||
|
SRWLOCK m_requestLock {};
|
||||||
};
|
};
|
||||||
|
|
||||||
class ASPNET_CORE_PROXY_MODULE_FACTORY : NonCopyable, public IHttpModuleFactory
|
class ASPNET_CORE_PROXY_MODULE_FACTORY : NonCopyable, public IHttpModuleFactory
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue