@@ -86,7 +86,7 @@ public abstract class ConnectionBase : IConnection
86
86
public static int HandshakeTimeout = 10000 ;
87
87
88
88
///<summary>Timeout used while waiting for a
89
- ///connection.close-ok reply to a connection close request
89
+ ///connection.close-ok reply to a connection. close request
90
90
///(milliseconds)</summary>
91
91
public static int ConnectionCloseTimeout = 10000 ;
92
92
@@ -368,25 +368,25 @@ void IDisposable.Dispose()
368
368
}
369
369
}
370
370
371
- ///<summary>API-side invocation of connection close.</summary>
371
+ ///<summary>API-side invocation of connection. close.</summary>
372
372
public void Close ( )
373
373
{
374
374
Close ( CommonFraming . Constants . ReplySuccess , "Goodbye" , Timeout . Infinite ) ;
375
375
}
376
376
377
- ///<summary>API-side invocation of connection close.</summary>
377
+ ///<summary>API-side invocation of connection. close.</summary>
378
378
public void Close ( ushort reasonCode , string reasonText )
379
379
{
380
380
Close ( reasonCode , reasonText , Timeout . Infinite ) ;
381
381
}
382
382
383
- ///<summary>API-side invocation of connection close with timeout.</summary>
383
+ ///<summary>API-side invocation of connection. close with timeout.</summary>
384
384
public void Close ( int timeout )
385
385
{
386
386
Close ( CommonFraming . Constants . ReplySuccess , "Goodbye" , timeout ) ;
387
387
}
388
388
389
- ///<summary>API-side invocation of connection close with timeout.</summary>
389
+ ///<summary>API-side invocation of connection. close with timeout.</summary>
390
390
public void Close ( ushort reasonCode , string reasonText , int timeout )
391
391
{
392
392
Close ( new ShutdownEventArgs ( ShutdownInitiator . Application , reasonCode , reasonText ) , false , timeout ) ;
@@ -460,7 +460,7 @@ public void Close(ShutdownEventArgs reason, bool abort, int timeout)
460
460
461
461
try
462
462
{
463
- // Try to send connection close
463
+ // Try to send connection. close
464
464
// Wait for CloseOk in the MainLoop
465
465
m_session0 . Transmit ( ConnectionCloseWrapper ( reason . ReplyCode ,
466
466
reason . ReplyText ) ) ;
@@ -637,7 +637,8 @@ public void MainLoop()
637
637
}
638
638
639
639
// If allowed for clean shutdown
640
- // Run limited version of the main loop
640
+ // Run main loop for a limited amount of time (as defined
641
+ // by ConnectionCloseTimeout).
641
642
if ( shutdownCleanly )
642
643
{
643
644
ClosingLoop ( ) ;
@@ -790,8 +791,9 @@ public void NotifyReceivedCloseOk()
790
791
///<summary>
791
792
/// Sets the channel named in the SoftProtocolException into
792
793
/// "quiescing mode", where we issue a channel.close and
793
- /// ignore everything up to the channel.close-ok reply that
794
- /// should eventually arrive.
794
+ /// ignore everything except for subsequent channel.close
795
+ /// messages and the channel.close-ok reply that should
796
+ /// eventually arrive.
795
797
///</summary>
796
798
///<remarks>
797
799
///<para>
@@ -816,23 +818,12 @@ public void NotifyReceivedCloseOk()
816
818
///</para>
817
819
///</remarks>
818
820
public void QuiesceChannel ( SoftProtocolException pe ) {
819
- // First, construct the close request and QuiescingSession
820
- // that we'll use during the quiesce process.
821
-
822
- Command request ;
823
- int replyClassId ;
824
- int replyMethodId ;
825
- Protocol . CreateChannelClose ( pe . ReplyCode ,
826
- pe . Message ,
827
- out request ,
828
- out replyClassId ,
829
- out replyMethodId ) ;
821
+ // Construct the QuiescingSession that we'll use during
822
+ // the quiesce process.
830
823
831
824
ISession newSession = new QuiescingSession ( this ,
832
825
pe . Channel ,
833
- pe . ShutdownReason ,
834
- replyClassId ,
835
- replyMethodId ) ;
826
+ pe . ShutdownReason ) ;
836
827
837
828
// Here we detach the session from the connection. It's
838
829
// still alive: it just won't receive any further frames
@@ -851,7 +842,7 @@ public void QuiesceChannel(SoftProtocolException pe) {
851
842
// our peer. The peer will respond through the lower
852
843
// layers - specifically, through the QuiescingSession we
853
844
// installed above.
854
- newSession . Transmit ( request ) ;
845
+ newSession . Transmit ( ChannelCloseWrapper ( pe . ReplyCode , pe . Message ) ) ;
855
846
}
856
847
857
848
public void HandleMainLoopException ( ShutdownEventArgs reason ) {
@@ -959,7 +950,19 @@ public Command ConnectionCloseWrapper(ushort reasonCode, string reasonText)
959
950
out replyClassId ,
960
951
out replyMethodId ) ;
961
952
return request ;
962
- }
953
+ }
954
+
955
+ protected Command ChannelCloseWrapper ( ushort reasonCode , string reasonText )
956
+ {
957
+ Command request ;
958
+ int replyClassId , replyMethodId ;
959
+ Protocol . CreateChannelClose ( reasonCode ,
960
+ reasonText ,
961
+ out request ,
962
+ out replyClassId ,
963
+ out replyMethodId ) ;
964
+ return request ;
965
+ }
963
966
964
967
private static uint NegotiatedMaxValue ( uint clientValue , uint serverValue )
965
968
{
0 commit comments