Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chronoxor committed Mar 11, 2020
1 parent 7b73bb8 commit 1777931
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion source/NetCoreServer/SslClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ public virtual string Receive(long size)
public virtual void ReceiveAsync()
{
// Try to receive datagram
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
if (Thread.CurrentThread.ManagedThreadId == _receiveThreadId)
ThreadPool.QueueUserWorkItem(_ => TryReceive());
else
TryReceive();
Expand Down
2 changes: 1 addition & 1 deletion source/NetCoreServer/SslSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public virtual string Receive(long size)
public virtual void ReceiveAsync()
{
// Try to receive datagram
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
if (Thread.CurrentThread.ManagedThreadId == _receiveThreadId)
ThreadPool.QueueUserWorkItem(_ => TryReceive());
else
TryReceive();
Expand Down
8 changes: 5 additions & 3 deletions source/NetCoreServer/TcpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ public virtual string Receive(long size)
public virtual void ReceiveAsync()
{
// Try to receive datagram
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
if (Thread.CurrentThread.ManagedThreadId == _receiveThreadId)
ThreadPool.QueueUserWorkItem(_ => TryReceive());
else
TryReceive();
Expand Down Expand Up @@ -694,6 +694,7 @@ private void ProcessReceive(SocketAsyncEventArgs e)
if (!IsConnected)
return;

bool recursive = (Thread.CurrentThread.ManagedThreadId == _receiveThreadId);
long size = e.BytesTransferred;

// Received some data from the server
Expand All @@ -719,7 +720,7 @@ private void ProcessReceive(SocketAsyncEventArgs e)
// If zero is returned from a read operation, the remote end has closed the connection
if (size > 0)
{
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
if (recursive)
ThreadPool.QueueUserWorkItem(_ => TryReceive());
else
TryReceive();
Expand All @@ -744,6 +745,7 @@ private void ProcessSend(SocketAsyncEventArgs e)
if (!IsConnected)
return;

bool recursive = (Thread.CurrentThread.ManagedThreadId == _sendThreadId);
long size = e.BytesTransferred;

// Send some data to the server
Expand Down Expand Up @@ -774,7 +776,7 @@ private void ProcessSend(SocketAsyncEventArgs e)
// Try to send again if the client is valid
if (e.SocketError == SocketError.Success)
{
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
if (recursive)
ThreadPool.QueueUserWorkItem(_ => TrySend());
else
TrySend();
Expand Down
8 changes: 5 additions & 3 deletions source/NetCoreServer/TcpSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ public virtual string Receive(long size)
public virtual void ReceiveAsync()
{
// Try to receive datagram
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
if (Thread.CurrentThread.ManagedThreadId == _receiveThreadId)
ThreadPool.QueueUserWorkItem(_ => TryReceive());
else
TryReceive();
Expand Down Expand Up @@ -526,6 +526,7 @@ private void ProcessReceive(SocketAsyncEventArgs e)
if (!IsConnected)
return;

bool recursive = (Thread.CurrentThread.ManagedThreadId == _receiveThreadId);
long size = e.BytesTransferred;

// Received some data from the client
Expand All @@ -552,7 +553,7 @@ private void ProcessReceive(SocketAsyncEventArgs e)
// If zero is returned from a read operation, the remote end has closed the connection
if (size > 0)
{
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
if (recursive)
ThreadPool.QueueUserWorkItem(_ => TryReceive());
else
TryReceive();
Expand All @@ -577,6 +578,7 @@ private void ProcessSend(SocketAsyncEventArgs e)
if (!IsConnected)
return;

bool recursive = (Thread.CurrentThread.ManagedThreadId == _sendThreadId);
long size = e.BytesTransferred;

// Send some data to the client
Expand Down Expand Up @@ -608,7 +610,7 @@ private void ProcessSend(SocketAsyncEventArgs e)
// Try to send again if the session is valid
if (e.SocketError == SocketError.Success)
{
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
if (recursive)
ThreadPool.QueueUserWorkItem(_ => TrySend());
else
TrySend();
Expand Down
2 changes: 1 addition & 1 deletion source/NetCoreServer/UdpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ public virtual string Receive(ref EndPoint endpoint, long size)
public virtual void ReceiveAsync()
{
// Try to receive datagram
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
if (Thread.CurrentThread.ManagedThreadId == _receiveThreadId)
ThreadPool.QueueUserWorkItem(_ => TryReceive());
else
TryReceive();
Expand Down
2 changes: 1 addition & 1 deletion source/NetCoreServer/UdpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ public virtual string Receive(ref EndPoint endpoint, long size)
public virtual void ReceiveAsync()
{
// Try to receive datagram
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
if (Thread.CurrentThread.ManagedThreadId == _receiveThreadId)
ThreadPool.QueueUserWorkItem(_ => TryReceive());
else
TryReceive();
Expand Down

0 comments on commit 1777931

Please sign in to comment.