Skip to content

Commit f7a7dc7

Browse files
kjnilssonmichaelklishin
authored andcommitted
Synchronize access to the manuallyClosed field in AutorecoveringConnection
1 parent f335e2d commit f7a7dc7

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

projects/client/RabbitMQ.Client/src/client/impl/AutorecoveringConnection.cs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ namespace RabbitMQ.Client.Framing.Impl
5353
public class AutorecoveringConnection : IConnection, IRecoverable
5454
{
5555
public readonly object m_eventLock = new object();
56+
57+
public readonly object manuallyClosedLock = new object();
5658
protected Connection m_delegate;
5759
protected ConnectionFactory m_factory;
5860

@@ -104,6 +106,23 @@ public AutorecoveringConnection(ConnectionFactory factory, string clientProvided
104106
this.ClientProvidedName = clientProvidedName;
105107
}
106108

109+
private bool ManuallyClosed
110+
{
111+
get
112+
{
113+
lock(manuallyClosedLock)
114+
{
115+
return manuallyClosed;
116+
}
117+
}
118+
set
119+
{
120+
lock(manuallyClosedLock)
121+
{
122+
manuallyClosed = value; }
123+
}
124+
}
125+
107126
public event EventHandler<CallbackExceptionEventArgs> CallbackException
108127
{
109128
add
@@ -341,7 +360,7 @@ public void BeginAutomaticRecovery()
341360

342361
recoveryTaskFactory.StartNew(() =>
343362
{
344-
if(!self.manuallyClosed)
363+
if(!self.ManuallyClosed)
345364
{
346365
try
347366
{
@@ -633,56 +652,56 @@ private void Init(AmqpTcpEndpoint endpoint)
633652
///<summary>API-side invocation of connection abort.</summary>
634653
public void Abort()
635654
{
636-
this.manuallyClosed = true;
655+
this.ManuallyClosed = true;
637656
m_delegate.Abort();
638657
}
639658

640659
///<summary>API-side invocation of connection abort.</summary>
641660
public void Abort(ushort reasonCode, string reasonText)
642661
{
643-
this.manuallyClosed = true;
662+
this.ManuallyClosed = true;
644663
m_delegate.Abort(reasonCode, reasonText);
645664
}
646665

647666
///<summary>API-side invocation of connection abort with timeout.</summary>
648667
public void Abort(int timeout)
649668
{
650-
this.manuallyClosed = true;
669+
this.ManuallyClosed = true;
651670
m_delegate.Abort(timeout);
652671
}
653672

654673
///<summary>API-side invocation of connection abort with timeout.</summary>
655674
public void Abort(ushort reasonCode, string reasonText, int timeout)
656675
{
657-
this.manuallyClosed = true;
676+
this.ManuallyClosed = true;
658677
m_delegate.Abort(reasonCode, reasonText, timeout);
659678
}
660679

661680
///<summary>API-side invocation of connection.close.</summary>
662681
public void Close()
663682
{
664-
this.manuallyClosed = true;
683+
this.ManuallyClosed = true;
665684
m_delegate.Close();
666685
}
667686

668687
///<summary>API-side invocation of connection.close.</summary>
669688
public void Close(ushort reasonCode, string reasonText)
670689
{
671-
this.manuallyClosed = true;
690+
this.ManuallyClosed = true;
672691
m_delegate.Close(reasonCode, reasonText);
673692
}
674693

675694
///<summary>API-side invocation of connection.close with timeout.</summary>
676695
public void Close(int timeout)
677696
{
678-
this.manuallyClosed = true;
697+
this.ManuallyClosed = true;
679698
m_delegate.Close(timeout);
680699
}
681700

682701
///<summary>API-side invocation of connection.close with timeout.</summary>
683702
public void Close(ushort reasonCode, string reasonText, int timeout)
684703
{
685-
this.manuallyClosed = true;
704+
this.ManuallyClosed = true;
686705
m_delegate.Close(reasonCode, reasonText, timeout);
687706
}
688707

0 commit comments

Comments
 (0)