Skip to content

Commit

Permalink
Merge pull request #398 from CopernicaMarketingSoftware/synchronous-s…
Browse files Browse the repository at this point in the history
…uccess-callback

Avoid that multiple frames are sent by the channel-on-ready handler
  • Loading branch information
EmielBruijntjes committed Jun 16, 2021
2 parents dc9d88f + 45775fe commit f52fdf6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
10 changes: 2 additions & 8 deletions include/amqpcpp/channelimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -617,20 +617,14 @@ class ChannelImpl : public Watchable, public std::enable_shared_from_this<Channe
*/
void reportReady()
{
// callbacks could destroy us, so monitor it
Monitor monitor(this);

// if we are still in connected state we are now ready
if (_state == state_connected) _state = state_ready;

// the last (possibly synchronous) operation was received, so we're no longer in synchronous mode
if (_synchronous && _queue.empty()) _synchronous = false;
// send out more instructions if there is a queue
flush();

// inform handler
if (_readyCallback) _readyCallback();

// if the monitor is still valid, we flush any waiting operations
if (monitor.valid()) flush();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/channelimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ bool ChannelImpl::send(CopiedBuffer &&frame)

// are we currently in synchronous mode or are there
// other frames waiting for their turn to be sent?
if (_synchronous || !_queue.empty())
if (waiting())
{
// we need to wait until the synchronous frame has
// been processed, so queue the frame until it was
Expand Down Expand Up @@ -786,7 +786,7 @@ bool ChannelImpl::send(const Frame &frame)

// are we currently in synchronous mode or are there
// other frames waiting for their turn to be sent?
if (_synchronous || !_queue.empty())
if (waiting())
{
// we need to wait until the synchronous frame has
// been processed, so queue the frame until it was
Expand Down

0 comments on commit f52fdf6

Please sign in to comment.