Skip to content

Commit dfaa663

Browse files
martin-frydlEgorBo
authored andcommitted
Catch exception thrown by HttpConnection constructor and close connection (dotnet#33190)
* Catch exception thrown by HttpConnection constructor and close connection (fixes #32280) * Blank line added (coding style fix)
1 parent 3aad0d2 commit dfaa663

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,17 @@ 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+
}
129+
120130
lock (epl._unregisteredConnections)
121131
{
122132
epl._unregisteredConnections[conn] = conn;

0 commit comments

Comments
 (0)