@@ -71,6 +71,10 @@ ASPNET_CORE_PROXY_MODULE::ASPNET_CORE_PROXY_MODULE(HTTP_MODULE_ID moduleId, std:
71
71
72
72
ASPNET_CORE_PROXY_MODULE::~ASPNET_CORE_PROXY_MODULE ()
73
73
{
74
+ // At this point m_pDisconnectHandler should be disconnected in
75
+ // HandleNotificationStatus
76
+ assert (m_pDisconnectHandler == nullptr );
77
+
74
78
if (m_pDisconnectHandler != nullptr )
75
79
{
76
80
m_pDisconnectHandler->SetHandler (nullptr );
@@ -112,15 +116,15 @@ ASPNET_CORE_PROXY_MODULE::OnExecuteRequestHandler(
112
116
FINISHED_IF_FAILED (moduleContainer->SetConnectionModuleContext (static_cast <IHttpConnectionStoredContext*>(disconnectHandler.release ()), m_moduleId));
113
117
}
114
118
115
- m_pDisconnectHandler->SetHandler (this );
116
-
117
119
FINISHED_IF_FAILED (m_pApplicationManager->GetOrCreateApplicationInfo (
118
120
*pHttpContext,
119
121
m_pApplicationInfo));
120
122
121
123
FINISHED_IF_FAILED (m_pApplicationInfo->CreateHandler (*pHttpContext, m_pHandler));
122
124
123
125
retVal = m_pHandler->OnExecuteRequestHandler ();
126
+
127
+ m_pDisconnectHandler->SetHandler (::ReferenceRequestHandler (m_pHandler.get ()));
124
128
}
125
129
catch (...)
126
130
{
@@ -141,7 +145,7 @@ ASPNET_CORE_PROXY_MODULE::OnExecuteRequestHandler(
141
145
}
142
146
}
143
147
144
- return retVal;
148
+ return HandleNotificationStatus ( retVal) ;
145
149
}
146
150
147
151
__override
@@ -156,18 +160,27 @@ ASPNET_CORE_PROXY_MODULE::OnAsyncCompletion(
156
160
{
157
161
try
158
162
{
159
- return m_pHandler->OnAsyncCompletion (
163
+ return HandleNotificationStatus ( m_pHandler->OnAsyncCompletion (
160
164
pCompletionInfo->GetCompletionBytes (),
161
- pCompletionInfo->GetCompletionStatus ());
165
+ pCompletionInfo->GetCompletionStatus ())) ;
162
166
}
163
167
catch (...)
164
168
{
165
169
OBSERVE_CAUGHT_EXCEPTION ();
166
- return RQ_NOTIFICATION_FINISH_REQUEST;
170
+ return HandleNotificationStatus ( RQ_NOTIFICATION_FINISH_REQUEST) ;
167
171
}
168
172
}
169
173
170
- void ASPNET_CORE_PROXY_MODULE::NotifyDisconnect () const
174
+ REQUEST_NOTIFICATION_STATUS ASPNET_CORE_PROXY_MODULE::HandleNotificationStatus (REQUEST_NOTIFICATION_STATUS status) noexcept
171
175
{
172
- m_pHandler->NotifyDisconnect ();
176
+ if (status != RQ_NOTIFICATION_PENDING)
177
+ {
178
+ if (m_pDisconnectHandler != nullptr )
179
+ {
180
+ m_pDisconnectHandler->SetHandler (nullptr );
181
+ m_pDisconnectHandler = nullptr ;
182
+ }
183
+ }
184
+
185
+ return status;
173
186
}
0 commit comments