Skip to content

Commit 824437c

Browse files
author
Vlad Alexandru Ionescu
committed
merging bug23043 into default
2 parents 4d79ded + a608023 commit 824437c

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public abstract class ModelBase : IFullModel
8585
private BasicRecoverOkEventHandler m_basicRecoverOk;
8686

8787
public ManualResetEvent m_flowControlBlock = new ManualResetEvent(true);
88+
private readonly object m_flowSendLock = new object();
8889

8990
public event ModelShutdownEventHandler ModelShutdown
9091
{
@@ -373,10 +374,18 @@ public bool IsOpen
373374

374375
public void ModelSend(MethodBase method, ContentHeaderBase header, byte[] body)
375376
{
376-
if (method.HasContent) {
377-
m_flowControlBlock.WaitOne();
377+
if (method.HasContent)
378+
{
379+
lock (m_flowSendLock)
380+
{
381+
m_flowControlBlock.WaitOne();
382+
m_session.Transmit(new Command(method, header, body));
383+
}
384+
}
385+
else
386+
{
387+
m_session.Transmit(new Command(method, header, body));
378388
}
379-
m_session.Transmit(new Command(method, header, body));
380389
}
381390

382391
public MethodBase ModelRpc(MethodBase method, ContentHeaderBase header, byte[] body)
@@ -451,10 +460,18 @@ public void HandleBasicReturn(ushort replyCode,
451460
public void HandleChannelFlow(bool active)
452461
{
453462
if (active)
463+
{
454464
m_flowControlBlock.Set();
465+
_Private_ChannelFlowOk(active);
466+
}
455467
else
456-
m_flowControlBlock.Reset();
457-
_Private_ChannelFlowOk(active);
468+
{
469+
lock (m_flowSendLock)
470+
{
471+
m_flowControlBlock.Reset();
472+
_Private_ChannelFlowOk(active);
473+
}
474+
}
458475
}
459476

460477
public void HandleConnectionStart(byte versionMajor,

0 commit comments

Comments
 (0)