Skip to content

Commit 5498c70

Browse files
floatascraiggwilson
authored andcommitted
CSHARP-1704: TcpStreamFactory is leaking socket handlers on exception
1 parent 9c2097f commit 5498c70

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/MongoDB.Driver.Core/Core/Connections/TcpStreamFactory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ private void Connect(Socket socket, EndPoint endPoint, CancellationToken cancell
150150
{
151151
if (!cancelled && !timedOut)
152152
{
153+
socket.Dispose();
153154
throw;
154155
}
155156
}
@@ -200,6 +201,7 @@ private async Task ConnectAsync(Socket socket, EndPoint endPoint, CancellationTo
200201
{
201202
if (!cancelled && !timedOut)
202203
{
204+
socket.Dispose();
203205
throw;
204206
}
205207
}

0 commit comments

Comments
 (0)