Dispose SocketAsyncEventArgs when we dispose the Socket (#2459)

This commit is contained in:
Stephen Halter 2018-04-02 19:48:17 -07:00 committed by GitHub
parent ba2b883db0
commit 623c27ab01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -86,6 +86,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
// Dispose the socket(should noop if already called)
_socket.Dispose();
_receiver.Dispose();
_sender.Dispose();
}
catch (Exception ex)
{

View File

@ -7,7 +7,7 @@ using System.Net.Sockets;
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
{
public class SocketReceiver
public class SocketReceiver : IDisposable
{
private readonly Socket _socket;
private readonly SocketAsyncEventArgs _eventArgs = new SocketAsyncEventArgs();
@ -37,5 +37,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
return _awaitable;
}
public void Dispose()
{
_eventArgs.Dispose();
}
}
}

View File

@ -11,7 +11,7 @@ using System.Runtime.InteropServices;
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
{
public class SocketSender
public class SocketSender : IDisposable
{
private readonly Socket _socket;
private readonly SocketAsyncEventArgs _eventArgs = new SocketAsyncEventArgs();
@ -98,5 +98,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
return _bufferList;
}
public void Dispose()
{
_eventArgs.Dispose();
}
}
}