Skip to content

Commit 15d22a9

Browse files
Merged PR 40657: Fix exit AcceptLoop in Http.Sys (#57319)
If an exception occurs during request processing we weren't exiting the accept loop which resulted in duplicating the accept loop. Co-authored-by: Brennan Conroy <brecon@microsoft.com>
1 parent 506512f commit 15d22a9

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

src/Servers/HttpSys/src/MessagePump.cs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -279,29 +279,38 @@ private async Task ExecuteAsync()
279279
continue;
280280
}
281281

282-
try
282+
if (_preferInlineScheduling)
283283
{
284-
if (_preferInlineScheduling)
284+
try
285285
{
286286
await requestContext.ExecuteAsync();
287287
}
288-
else
288+
catch (Exception ex)
289+
{
290+
// Request processing failed
291+
// Log the error message, release throttle and move on
292+
Log.RequestListenerProcessError(_messagePump._logger, ex);
293+
}
294+
}
295+
else
296+
{
297+
try
289298
{
290299
// Queue another accept before we execute the request
291300
ThreadPool.UnsafeQueueUserWorkItem(this, preferLocal: false);
292301

293302
// Use this thread to start the execution of the request (avoid the double threadpool dispatch)
294303
await requestContext.ExecuteAsync();
295-
296-
// We're done with this thread
297-
return;
298304
}
299-
}
300-
catch (Exception ex)
301-
{
302-
// Request processing failed
303-
// Log the error message, release throttle and move on
304-
Log.RequestListenerProcessError(_messagePump._logger, ex);
305+
catch (Exception ex)
306+
{
307+
// Request processing failed
308+
// Log the error message, release throttle and move on
309+
Log.RequestListenerProcessError(_messagePump._logger, ex);
310+
}
311+
312+
// We're done with this thread, accept loop was continued via ThreadPool.UnsafeQueueUserWorkItem
313+
return;
305314
}
306315
}
307316

0 commit comments

Comments
 (0)