Skip to content

Commit 2449554

Browse files
author
Martin Frydl
committed
Catch exception thrown by HttpConnection constructor and close connection (fixes #32280)
1 parent 42f0c49 commit 2449554

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/System.Net.HttpListener/src/System/Net/Managed/HttpEndPointListener.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,16 @@ private static void ProcessAccept(SocketAsyncEventArgs args)
116116
return;
117117
}
118118

119-
HttpConnection conn = new HttpConnection(accepted, epl, epl._secure, epl._cert);
119+
HttpConnection conn;
120+
try
121+
{
122+
conn = new HttpConnection(accepted, epl, epl._secure, epl._cert);
123+
}
124+
catch
125+
{
126+
accepted.Close();
127+
return;
128+
}
120129
lock (epl._unregisteredConnections)
121130
{
122131
epl._unregisteredConnections[conn] = conn;

0 commit comments

Comments
 (0)