Skip to content

Commit 1777931

Browse files
committed
Bugfixes
1 parent 7b73bb8 commit 1777931

File tree

6 files changed

+14
-10
lines changed

6 files changed

+14
-10
lines changed

source/NetCoreServer/SslClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ public virtual string Receive(long size)
581581
public virtual void ReceiveAsync()
582582
{
583583
// Try to receive datagram
584-
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
584+
if (Thread.CurrentThread.ManagedThreadId == _receiveThreadId)
585585
ThreadPool.QueueUserWorkItem(_ => TryReceive());
586586
else
587587
TryReceive();

source/NetCoreServer/SslSession.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ public virtual string Receive(long size)
429429
public virtual void ReceiveAsync()
430430
{
431431
// Try to receive datagram
432-
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
432+
if (Thread.CurrentThread.ManagedThreadId == _receiveThreadId)
433433
ThreadPool.QueueUserWorkItem(_ => TryReceive());
434434
else
435435
TryReceive();

source/NetCoreServer/TcpClient.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ public virtual string Receive(long size)
514514
public virtual void ReceiveAsync()
515515
{
516516
// Try to receive datagram
517-
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
517+
if (Thread.CurrentThread.ManagedThreadId == _receiveThreadId)
518518
ThreadPool.QueueUserWorkItem(_ => TryReceive());
519519
else
520520
TryReceive();
@@ -694,6 +694,7 @@ private void ProcessReceive(SocketAsyncEventArgs e)
694694
if (!IsConnected)
695695
return;
696696

697+
bool recursive = (Thread.CurrentThread.ManagedThreadId == _receiveThreadId);
697698
long size = e.BytesTransferred;
698699

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

748+
bool recursive = (Thread.CurrentThread.ManagedThreadId == _sendThreadId);
747749
long size = e.BytesTransferred;
748750

749751
// Send some data to the server
@@ -774,7 +776,7 @@ private void ProcessSend(SocketAsyncEventArgs e)
774776
// Try to send again if the client is valid
775777
if (e.SocketError == SocketError.Success)
776778
{
777-
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
779+
if (recursive)
778780
ThreadPool.QueueUserWorkItem(_ => TrySend());
779781
else
780782
TrySend();

source/NetCoreServer/TcpSession.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public virtual string Receive(long size)
397397
public virtual void ReceiveAsync()
398398
{
399399
// Try to receive datagram
400-
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
400+
if (Thread.CurrentThread.ManagedThreadId == _receiveThreadId)
401401
ThreadPool.QueueUserWorkItem(_ => TryReceive());
402402
else
403403
TryReceive();
@@ -526,6 +526,7 @@ private void ProcessReceive(SocketAsyncEventArgs e)
526526
if (!IsConnected)
527527
return;
528528

529+
bool recursive = (Thread.CurrentThread.ManagedThreadId == _receiveThreadId);
529530
long size = e.BytesTransferred;
530531

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

581+
bool recursive = (Thread.CurrentThread.ManagedThreadId == _sendThreadId);
580582
long size = e.BytesTransferred;
581583

582584
// Send some data to the client
@@ -608,7 +610,7 @@ private void ProcessSend(SocketAsyncEventArgs e)
608610
// Try to send again if the session is valid
609611
if (e.SocketError == SocketError.Success)
610612
{
611-
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
613+
if (recursive)
612614
ThreadPool.QueueUserWorkItem(_ => TrySend());
613615
else
614616
TrySend();

source/NetCoreServer/UdpClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ public virtual string Receive(ref EndPoint endpoint, long size)
551551
public virtual void ReceiveAsync()
552552
{
553553
// Try to receive datagram
554-
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
554+
if (Thread.CurrentThread.ManagedThreadId == _receiveThreadId)
555555
ThreadPool.QueueUserWorkItem(_ => TryReceive());
556556
else
557557
TryReceive();

source/NetCoreServer/UdpServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ public virtual string Receive(ref EndPoint endpoint, long size)
544544
public virtual void ReceiveAsync()
545545
{
546546
// Try to receive datagram
547-
if (Thread.CurrentThread.ManagedThreadId == _sendThreadId)
547+
if (Thread.CurrentThread.ManagedThreadId == _receiveThreadId)
548548
ThreadPool.QueueUserWorkItem(_ => TryReceive());
549549
else
550550
TryReceive();

0 commit comments

Comments
 (0)