Skip to content

Commit 5a648fe

Browse files
Merge pull request #298 from CopernicaMarketingSoftware/synchronous-fix
fix for incorrect handling of synchronous flag
2 parents f107b4a + 7b79b7c commit 5a648fe

22 files changed

+29
-29
lines changed

include/amqpcpp/channelimpl.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -574,10 +574,10 @@ class ChannelImpl : public Watchable, public std::enable_shared_from_this<Channe
574574
}
575575

576576
/**
577-
* Signal the channel that a synchronous operation was completed.
578-
* After this operation, waiting frames can be sent out.
577+
* Signal the channel that a synchronous operation was completed, and that any
578+
* queued frames can be sent out.
579579
*/
580-
void onSynchronized();
580+
void flush();
581581

582582
/**
583583
* Report to the handler that the channel is opened
@@ -596,8 +596,8 @@ class ChannelImpl : public Watchable, public std::enable_shared_from_this<Channe
596596
// inform handler
597597
if (_readyCallback) _readyCallback();
598598

599-
// if the monitor is still valid, we exit synchronous mode now
600-
if (monitor.valid()) onSynchronized();
599+
// if the monitor is still valid, we flush any waiting operations
600+
if (monitor.valid()) flush();
601601
}
602602

603603
/**
@@ -644,10 +644,10 @@ class ChannelImpl : public Watchable, public std::enable_shared_from_this<Channe
644644
{
645645
// skip if there is no oldest callback
646646
if (!_oldestCallback) return true;
647-
648-
// the last (possibly synchronous) operation was received, so we're no longer in synchronous mode
649-
if (_synchronous && _queue.empty()) _synchronous = false;
650647

648+
// flush the queue, which will send the next operation if the current operation was synchronous
649+
flush();
650+
651651
// we are going to call callbacks that could destruct the channel
652652
Monitor monitor(this);
653653

src/basiccancelokframe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class BasicCancelOKFrame : public BasicFrame
9494
if (!channel) return false;
9595

9696
// report
97-
if (channel->reportSuccess<const std::string&>(consumerTag())) channel->onSynchronized();
97+
channel->reportSuccess<const std::string&>(consumerTag());
9898

9999
// done
100100
return true;

src/basicconsumeokframe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class BasicConsumeOKFrame : public BasicFrame
9494
if (!channel) return false;
9595

9696
// report
97-
if (channel->reportSuccess(consumerTag())) channel->onSynchronized();
97+
channel->reportSuccess(consumerTag());
9898

9999
// done
100100
return true;

src/basicgetemptyframe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class BasicGetEmptyFrame : public BasicFrame
8484
if (!channel) return false;
8585

8686
// report
87-
if (channel->reportSuccess()) channel->onSynchronized();
87+
channel->reportSuccess();
8888

8989
// done
9090
return true;

src/basicqosokframe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class BasicQosOKFrame : public BasicFrame
6767
if (!channel) return false;
6868

6969
// report
70-
if (channel->reportSuccess()) channel->onSynchronized();
70+
channel->reportSuccess();
7171

7272
// done
7373
return true;

src/channelcloseokframe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class ChannelCloseOKFrame : public ChannelFrame
7272
if (!channel) return false;
7373

7474
// report that the channel is closed
75-
if (channel->reportClosed()) channel->onSynchronized();
75+
channel->reportClosed();
7676

7777
// done
7878
return true;

src/channelflowokframe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class ChannelFlowOKFrame : public ChannelFrame
9393
if (!channel) return false;
9494

9595
// report success for the call
96-
if (channel->reportSuccess()) channel->onSynchronized();
96+
channel->reportSuccess();
9797

9898
// done
9999
return true;

src/channelimpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ bool ChannelImpl::send(const Frame &frame)
754754
* Signal the channel that a synchronous operation was completed. After
755755
* this operation, waiting frames can be sent out.
756756
*/
757-
void ChannelImpl::onSynchronized()
757+
void ChannelImpl::flush()
758758
{
759759
// we are no longer waiting for synchronous operations
760760
_synchronous = false;

src/confirmselectokframe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class ConfirmSelectOKFrame : public ConfirmFrame
7575
if(!channel) return false;
7676

7777
// report that the channel is open
78-
if (channel->reportSuccess()) channel->onSynchronized();
78+
channel->reportSuccess();
7979

8080
// done
8181
return true;

src/deferredget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const std::shared_ptr<Deferred> &DeferredGet::reportSuccess() const
6262
void DeferredGet::complete()
6363
{
6464
// the channel is now synchronized, delayed frames may now be sent
65-
_channel->onSynchronized();
65+
_channel->flush();
6666

6767
// pass on to normal implementation
6868
DeferredExtReceiver::complete();

0 commit comments

Comments
 (0)