@@ -60,6 +60,8 @@ public class AutorecoveringConnection : IConnection, IRecoverable
60
60
public readonly object m_recordedEntitiesLock = new object ( ) ;
61
61
protected readonly TaskFactory recoveryTaskFactory = new TaskFactory ( ) ;
62
62
protected readonly object recoveryLockTarget = new object ( ) ;
63
+ // used to block connection recovery attempts after Close() is unvoked
64
+ protected bool manuallyClosed = false ;
63
65
protected bool performingRecovery = false ;
64
66
65
67
protected List < AutorecoveringModel > m_models = new List < AutorecoveringModel > ( ) ;
@@ -338,14 +340,17 @@ public void BeginAutomaticRecovery()
338
340
339
341
recoveryTaskFactory . StartNew ( ( ) =>
340
342
{
341
- try
342
- {
343
- Thread . Sleep ( m_factory . NetworkRecoveryInterval ) ;
344
- self . PerformAutomaticRecovery ( ) ;
345
- }
346
- finally
343
+ if ( ! self . manuallyClosed )
347
344
{
348
- performingRecovery = false ;
345
+ try
346
+ {
347
+ Thread . Sleep ( m_factory . NetworkRecoveryInterval ) ;
348
+ self . PerformAutomaticRecovery ( ) ;
349
+ }
350
+ finally
351
+ {
352
+ performingRecovery = false ;
353
+ }
349
354
}
350
355
} ) ;
351
356
}
@@ -576,48 +581,56 @@ public void init()
576
581
///<summary>API-side invocation of connection abort.</summary>
577
582
public void Abort ( )
578
583
{
584
+ this . manuallyClosed = true ;
579
585
m_delegate . Abort ( ) ;
580
586
}
581
587
582
588
///<summary>API-side invocation of connection abort.</summary>
583
589
public void Abort ( ushort reasonCode , string reasonText )
584
590
{
591
+ this . manuallyClosed = true ;
585
592
m_delegate . Abort ( reasonCode , reasonText ) ;
586
593
}
587
594
588
595
///<summary>API-side invocation of connection abort with timeout.</summary>
589
596
public void Abort ( int timeout )
590
597
{
598
+ this . manuallyClosed = true ;
591
599
m_delegate . Abort ( timeout ) ;
592
600
}
593
601
594
602
///<summary>API-side invocation of connection abort with timeout.</summary>
595
603
public void Abort ( ushort reasonCode , string reasonText , int timeout )
596
604
{
605
+ this . manuallyClosed = true ;
597
606
m_delegate . Abort ( reasonCode , reasonText , timeout ) ;
598
607
}
599
608
600
609
///<summary>API-side invocation of connection.close.</summary>
601
610
public void Close ( )
602
611
{
612
+ this . manuallyClosed = true ;
603
613
m_delegate . Close ( ) ;
604
614
}
605
615
606
616
///<summary>API-side invocation of connection.close.</summary>
607
617
public void Close ( ushort reasonCode , string reasonText )
608
618
{
619
+ this . manuallyClosed = true ;
609
620
m_delegate . Close ( reasonCode , reasonText ) ;
610
621
}
611
622
612
623
///<summary>API-side invocation of connection.close with timeout.</summary>
613
624
public void Close ( int timeout )
614
625
{
626
+ this . manuallyClosed = true ;
615
627
m_delegate . Close ( timeout ) ;
616
628
}
617
629
618
630
///<summary>API-side invocation of connection.close with timeout.</summary>
619
631
public void Close ( ushort reasonCode , string reasonText , int timeout )
620
632
{
633
+ this . manuallyClosed = true ;
621
634
m_delegate . Close ( reasonCode , reasonText , timeout ) ;
622
635
}
623
636
0 commit comments