File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed
Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -510,20 +510,14 @@ public int RequiredReceiveFrameSize()
510510 /// </summary>
511511 public void ClearWsBuffers ( )
512512 {
513- lock ( WsSendLock )
514- {
515- WsSendBuffer . Clear ( ) ;
516- Array . Clear ( WsSendMask , 0 , WsSendMask . Length ) ;
517- }
518-
519- // Sometimes on disconnect the receive lock could be taken by receive thread.
520- // In this case we'll skip the receive buffer clearing. It will happen on
521- // re-connect then or in GC.
522-
513+ // Clear the receive buffer
523514 bool acquiredReceiveLock = false ;
524515
525516 try
526517 {
518+ // Sometimes on disconnect the receive lock could be taken by receive thread.
519+ // In this case we'll skip the receive buffer clearing. It will happen on
520+ // re-connect then or in GC.
527521 Monitor . TryEnter ( WsReceiveLock , ref acquiredReceiveLock ) ;
528522 if ( acquiredReceiveLock )
529523 {
@@ -541,6 +535,13 @@ public void ClearWsBuffers()
541535 if ( acquiredReceiveLock )
542536 Monitor . Exit ( WsReceiveLock ) ;
543537 }
538+
539+ // Clear the send buffer
540+ lock ( WsSendLock )
541+ {
542+ WsSendBuffer . Clear ( ) ;
543+ Array . Clear ( WsSendMask , 0 , WsSendMask . Length ) ;
544+ }
544545 }
545546
546547 /// <summary>
You can’t perform that action at this time.
0 commit comments