Skip to content

Commit bd4196d

Browse files
committed
Fix 0 request scenario
1 parent 4e79bb0 commit bd4196d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/application.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "iapplication.h"
88
#include "ntassert.h"
99
#include "SRWExclusiveLock.h"
10+
#include "SRWSharedLock.h"
1011
#include "exceptions.h"
1112

1213
class APPLICATION : public IAPPLICATION
@@ -21,14 +22,17 @@ class APPLICATION : public IAPPLICATION
2122
_In_ IHttpContext *pHttpContext,
2223
_Outptr_result_maybenull_ IREQUEST_HANDLER **pRequestHandler) override
2324
{
24-
TraceContextScope traceScope(pHttpContext->GetTraceContext());
2525
*pRequestHandler = nullptr;
2626

27+
SRWSharedLock stopLock(m_stateLock);
28+
2729
if (m_fStopCalled)
2830
{
2931
return S_FALSE;
3032
}
3133

34+
TraceContextScope traceScope(pHttpContext->GetTraceContext());
35+
3236
return CreateHandler(pHttpContext, pRequestHandler);
3337
}
3438

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ IN_PROCESS_APPLICATION::StopClr()
6868
{
6969
shutdownHandler(m_ShutdownHandlerContext);
7070
}
71+
72+
auto requestCount = m_requestCount.load();
73+
if (requestCount == 0)
74+
{
75+
LOG_INFO(L"Drained all requests, notifying managed.");
76+
m_RequestsDrainedHandler(m_ShutdownHandlerContext);
77+
}
7178
}
7279

7380
// Signal shutdown
@@ -537,6 +544,7 @@ IN_PROCESS_APPLICATION::CreateHandler(
537544
void
538545
IN_PROCESS_APPLICATION::HandleRequestCompletion()
539546
{
547+
SRWSharedLock lock(m_stateLock);
540548
auto requestCount = m_requestCount--;
541549
if (m_fStopCalled && requestCount == 0)
542550
{

0 commit comments

Comments
 (0)