@@ -64,6 +64,8 @@ public class AutorecoveringConnection : IConnection, IRecoverable
64
64
public readonly object m_recordedEntitiesLock = new object ( ) ;
65
65
protected readonly TaskFactory recoveryTaskFactory = new TaskFactory ( ) ;
66
66
protected readonly object recoveryLockTarget = new object ( ) ;
67
+ // used to block connection recovery attempts after Close() is unvoked
68
+ protected bool manuallyClosed = false ;
67
69
protected bool performingRecovery = false ;
68
70
69
71
protected List < AutorecoveringModel > m_models = new List < AutorecoveringModel > ( ) ;
@@ -332,18 +334,21 @@ public void BeginAutomaticRecovery()
332
334
333
335
recoveryTaskFactory . StartNew ( ( ) =>
334
336
{
335
- try
337
+ if ( ! self . manuallyClosed )
336
338
{
339
+ try
340
+ {
337
341
#if NETFX_CORE
338
342
System . Threading . Tasks . Task . Delay ( m_factory . NetworkRecoveryInterval ) . Wait ( ) ;
339
343
#else
340
344
Thread . Sleep ( m_factory . NetworkRecoveryInterval ) ;
341
345
#endif
342
- self . PerformAutomaticRecovery ( ) ;
343
- }
344
- finally
345
- {
346
- performingRecovery = false ;
346
+ self . PerformAutomaticRecovery ( ) ;
347
+ }
348
+ finally
349
+ {
350
+ performingRecovery = false ;
351
+ }
347
352
}
348
353
} ) ;
349
354
}
@@ -608,48 +613,56 @@ protected void Init(string hostname)
608
613
///<summary>API-side invocation of connection abort.</summary>
609
614
public void Abort ( )
610
615
{
616
+ this . manuallyClosed = true ;
611
617
m_delegate . Abort ( ) ;
612
618
}
613
619
614
620
///<summary>API-side invocation of connection abort.</summary>
615
621
public void Abort ( ushort reasonCode , string reasonText )
616
622
{
623
+ this . manuallyClosed = true ;
617
624
m_delegate . Abort ( reasonCode , reasonText ) ;
618
625
}
619
626
620
627
///<summary>API-side invocation of connection abort with timeout.</summary>
621
628
public void Abort ( int timeout )
622
629
{
630
+ this . manuallyClosed = true ;
623
631
m_delegate . Abort ( timeout ) ;
624
632
}
625
633
626
634
///<summary>API-side invocation of connection abort with timeout.</summary>
627
635
public void Abort ( ushort reasonCode , string reasonText , int timeout )
628
636
{
637
+ this . manuallyClosed = true ;
629
638
m_delegate . Abort ( reasonCode , reasonText , timeout ) ;
630
639
}
631
640
632
641
///<summary>API-side invocation of connection.close.</summary>
633
642
public void Close ( )
634
643
{
644
+ this . manuallyClosed = true ;
635
645
m_delegate . Close ( ) ;
636
646
}
637
647
638
648
///<summary>API-side invocation of connection.close.</summary>
639
649
public void Close ( ushort reasonCode , string reasonText )
640
650
{
651
+ this . manuallyClosed = true ;
641
652
m_delegate . Close ( reasonCode , reasonText ) ;
642
653
}
643
654
644
655
///<summary>API-side invocation of connection.close with timeout.</summary>
645
656
public void Close ( int timeout )
646
657
{
658
+ this . manuallyClosed = true ;
647
659
m_delegate . Close ( timeout ) ;
648
660
}
649
661
650
662
///<summary>API-side invocation of connection.close with timeout.</summary>
651
663
public void Close ( ushort reasonCode , string reasonText , int timeout )
652
664
{
665
+ this . manuallyClosed = true ;
653
666
m_delegate . Close ( reasonCode , reasonText , timeout ) ;
654
667
}
655
668
0 commit comments