Skip to content

Commit

Permalink
TcpServer call OnConnected after object disposed #115
Browse files Browse the repository at this point in the history
  • Loading branch information
chronoxor committed Feb 23, 2021
1 parent f2190ff commit d42e268
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Specify version format
version: "5.0.12.{build}"
version: "5.0.13.{build}"

# Image to use
image: Visual Studio 2019
Expand Down
2 changes: 1 addition & 1 deletion source/NetCoreServer/NetCoreServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Version>5.0.12.0</Version>
<Version>5.0.13.0</Version>
<Authors>Ivan Shynkarenka</Authors>
<Copyright>Copyright (c) 2019-2021 Ivan Shynkarenka</Copyright>
<RepositoryUrl>https://github.com/chronoxor/NetCoreServer</RepositoryUrl>
Expand Down
4 changes: 4 additions & 0 deletions source/NetCoreServer/SslClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,10 @@ private void ProcessHandshake(IAsyncResult result)
// Try to receive something from the server
TryReceive();

// Check the socket disposed state: in some rare cases it might be disconnected while receiving!
if (IsSocketDisposed)
return;

// Call the session handshaked handler
OnHandshaked();

Expand Down
4 changes: 4 additions & 0 deletions source/NetCoreServer/SslSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,10 @@ private void ProcessHandshake(IAsyncResult result)
// Try to receive something from the client
TryReceive();

// Check the socket disposed state: in some rare cases it might be disconnected while receiving!
if (IsSocketDisposed)
return;

// Call the session handshaked handler
OnHandshaked();

Expand Down
4 changes: 4 additions & 0 deletions source/NetCoreServer/TcpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,10 @@ private void ProcessConnect(SocketAsyncEventArgs e)
// Try to receive something from the server
TryReceive();

// Check the socket disposed state: in some rare cases it might be disconnected while receiving!
if (IsSocketDisposed)
return;

// Call the client connected handler
OnConnected();

Expand Down
4 changes: 4 additions & 0 deletions source/NetCoreServer/TcpSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ internal void Connect(Socket socket)
// Try to receive something from the client
TryReceive();

// Check the socket disposed state: in some rare cases it might be disconnected while receiving!
if (IsSocketDisposed)
return;

// Call the session connected handler
OnConnected();

Expand Down

0 comments on commit d42e268

Please sign in to comment.