Skip to content

Commit 3567768

Browse files
committed
Merged PR 14745: Call RaiseEvent later
For 5.0
1 parent 6842f90 commit 3567768

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/Servers/IIS/AspNetCoreModuleV2/InProcessRequestHandler/inprocesshandler.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,22 @@ REQUEST_NOTIFICATION_STATUS IN_PROCESS_HANDLER::ServerShutdownMessage() const
9191
VOID
9292
IN_PROCESS_HANDLER::NotifyDisconnect()
9393
{
94-
::RaiseEvent<ANCMEvents::ANCM_INPROC_REQUEST_DISCONNECT>(m_pW3Context, nullptr);
95-
96-
if (m_pApplication->QueryBlockCallbacksIntoManaged() ||
97-
m_fManagedRequestComplete)
98-
{
99-
return;
100-
}
101-
10294
// NotifyDisconnect can be called before the m_pManagedHttpContext is set,
10395
// so save that in a bool.
10496
// Don't lock when calling m_pDisconnect to avoid the potential deadlock between this
10597
// and SetManagedHttpContext
10698
void* pManagedHttpContext = nullptr;
10799
{
108100
SRWExclusiveLock lock(m_srwDisconnectLock);
101+
102+
if (m_pApplication->QueryBlockCallbacksIntoManaged() ||
103+
m_fManagedRequestComplete)
104+
{
105+
return;
106+
}
107+
108+
::RaiseEvent<ANCMEvents::ANCM_INPROC_REQUEST_DISCONNECT>(m_pW3Context, nullptr);
109+
109110
pManagedHttpContext = m_pManagedHttpContext;
110111
m_disconnectFired = true;
111112
}
@@ -121,8 +122,11 @@ IN_PROCESS_HANDLER::IndicateManagedRequestComplete(
121122
VOID
122123
)
123124
{
124-
m_fManagedRequestComplete = TRUE;
125-
m_pManagedHttpContext = nullptr;
125+
{
126+
SRWExclusiveLock lock(m_srwDisconnectLock);
127+
m_fManagedRequestComplete = TRUE;
128+
m_pManagedHttpContext = nullptr;
129+
}
126130
::RaiseEvent<ANCMEvents::ANCM_INPROC_MANAGED_REQUEST_COMPLETION>(m_pW3Context, nullptr);
127131
}
128132

0 commit comments

Comments
 (0)