Skip to content

Commit 80425dc

Browse files
Merge pull request #292 from rabbitmq/rabbitmq-dotnet-client-291
Synchronize access to the manuallyClosed field in AutorecoveringConne…
2 parents 2191c44 + 6b03274 commit 80425dc

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

@@ -102,6 +104,23 @@ public AutorecoveringConnection(ConnectionFactory factory, string clientProvided
102104
this.ClientProvidedName = clientProvidedName;
103105
}
104106

107+
private bool ManuallyClosed
108+
{
109+
get
110+
{
111+
lock(manuallyClosedLock)
112+
{
113+
return manuallyClosed;
114+
}
115+
}
116+
set
117+
{
118+
lock(manuallyClosedLock)
119+
{
120+
manuallyClosed = value; }
121+
}
122+
}
123+
105124
public event EventHandler<CallbackExceptionEventArgs> CallbackException
106125
{
107126
add
@@ -339,7 +358,7 @@ public void BeginAutomaticRecovery()
339358

340359
recoveryTaskFactory.StartNew(() =>
341360
{
342-
if(!self.manuallyClosed)
361+
if(!self.ManuallyClosed)
343362
{
344363
try
345364
{
@@ -600,56 +619,56 @@ private void Init(IFrameHandler fh)
600619
///<summary>API-side invocation of connection abort.</summary>
601620
public void Abort()
602621
{
603-
this.manuallyClosed = true;
622+
this.ManuallyClosed = true;
604623
m_delegate.Abort();
605624
}
606625

607626
///<summary>API-side invocation of connection abort.</summary>
608627
public void Abort(ushort reasonCode, string reasonText)
609628
{
610-
this.manuallyClosed = true;
629+
this.ManuallyClosed = true;
611630
m_delegate.Abort(reasonCode, reasonText);
612631
}
613632

614633
///<summary>API-side invocation of connection abort with timeout.</summary>
615634
public void Abort(int timeout)
616635
{
617-
this.manuallyClosed = true;
636+
this.ManuallyClosed = true;
618637
m_delegate.Abort(timeout);
619638
}
620639

621640
///<summary>API-side invocation of connection abort with timeout.</summary>
622641
public void Abort(ushort reasonCode, string reasonText, int timeout)
623642
{
624-
this.manuallyClosed = true;
643+
this.ManuallyClosed = true;
625644
m_delegate.Abort(reasonCode, reasonText, timeout);
626645
}
627646

628647
///<summary>API-side invocation of connection.close.</summary>
629648
public void Close()
630649
{
631-
this.manuallyClosed = true;
650+
this.ManuallyClosed = true;
632651
m_delegate.Close();
633652
}
634653

635654
///<summary>API-side invocation of connection.close.</summary>
636655
public void Close(ushort reasonCode, string reasonText)
637656
{
638-
this.manuallyClosed = true;
657+
this.ManuallyClosed = true;
639658
m_delegate.Close(reasonCode, reasonText);
640659
}
641660

642661
///<summary>API-side invocation of connection.close with timeout.</summary>
643662
public void Close(int timeout)
644663
{
645-
this.manuallyClosed = true;
664+
this.ManuallyClosed = true;
646665
m_delegate.Close(timeout);
647666
}
648667

649668
///<summary>API-side invocation of connection.close with timeout.</summary>
650669
public void Close(ushort reasonCode, string reasonText, int timeout)
651670
{
652-
this.manuallyClosed = true;
671+
this.ManuallyClosed = true;
653672
m_delegate.Close(reasonCode, reasonText, timeout);
654673
}
655674

0 commit comments

Comments
 (0)