Skip to content

Commit 86a2c2c

Browse files
author
Vlad Alexandru Ionescu
committed
merging defaults
2 parents 7df2d09 + 824437c commit 86a2c2c

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
@@ -86,6 +86,7 @@ public abstract class ModelBase : IFullModel
8686
private BasicRecoverOkEventHandler m_basicRecoverOk;
8787

8888
public ManualResetEvent m_flowControlBlock = new ManualResetEvent(true);
89+
private readonly object m_flowSendLock = new object();
8990

9091
public event ModelShutdownEventHandler ModelShutdown
9192
{
@@ -417,10 +418,18 @@ public bool IsOpen
417418

418419
public void ModelSend(MethodBase method, ContentHeaderBase header, byte[] body)
419420
{
420-
if (method.HasContent) {
421-
m_flowControlBlock.WaitOne();
421+
if (method.HasContent)
422+
{
423+
lock (m_flowSendLock)
424+
{
425+
m_flowControlBlock.WaitOne();
426+
m_session.Transmit(new Command(method, header, body));
427+
}
428+
}
429+
else
430+
{
431+
m_session.Transmit(new Command(method, header, body));
422432
}
423-
m_session.Transmit(new Command(method, header, body));
424433
}
425434

426435
public MethodBase ModelRpc(MethodBase method, ContentHeaderBase header, byte[] body)
@@ -495,10 +504,18 @@ public void HandleBasicReturn(ushort replyCode,
495504
public void HandleChannelFlow(bool active)
496505
{
497506
if (active)
507+
{
498508
m_flowControlBlock.Set();
509+
_Private_ChannelFlowOk(active);
510+
}
499511
else
500-
m_flowControlBlock.Reset();
501-
_Private_ChannelFlowOk(active);
512+
{
513+
lock (m_flowSendLock)
514+
{
515+
m_flowControlBlock.Reset();
516+
_Private_ChannelFlowOk(active);
517+
}
518+
}
502519
OnFlowControl(new FlowControlEventArgs(active));
503520
}
504521

0 commit comments

Comments
 (0)