Skip to content

Commit 7a78df4

Browse files
Get rid of m_consumerLock
m_consumer is volatile + its readers assign it to a local variable before using it.
1 parent 5a3fe32 commit 7a78df4

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

projects/client/RabbitMQ.Client/src/client/messagepatterns/Subscription.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public class Subscription: IEnumerable, IEnumerator, IDisposable {
7979
protected string m_queueName;
8080
protected bool m_noAck;
8181

82-
protected readonly object m_consumerLock = new object();
8382
protected readonly object m_eventLock = new object();
8483
protected volatile QueueingBasicConsumer m_consumer;
8584
protected string m_consumerTag;
@@ -149,11 +148,9 @@ public void Close()
149148
try {
150149
bool shouldCancelConsumer = false;
151150

152-
lock (m_consumerLock) {
153-
if (m_consumer != null) {
154-
shouldCancelConsumer = true;
155-
m_consumer = null;
156-
}
151+
if (m_consumer != null) {
152+
shouldCancelConsumer = true;
153+
m_consumer = null;
157154
}
158155

159156
if (shouldCancelConsumer) {

0 commit comments

Comments
 (0)