diff --git a/include/amqpcpp/channelimpl.h b/include/amqpcpp/channelimpl.h index 1ba6130..3d90266 100644 --- a/include/amqpcpp/channelimpl.h +++ b/include/amqpcpp/channelimpl.h @@ -5,7 +5,7 @@ * that has a private constructor so that it can not be used from outside * the AMQP library * - * @copyright 2014 - 2017 Copernica BV + * @copyright 2014 - 2018 Copernica BV */ /** @@ -122,7 +122,8 @@ private: std::queue> _queue; /** - * Are we currently operating in synchronous mode? + * Are we currently operating in synchronous mode? Meaning: do we first have + * to wait for the answer to previous instructions before we send a new instruction? * @var bool */ bool _synchronous = false; @@ -567,6 +568,9 @@ public: // 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; // inform handler if (_readyCallback) _readyCallback(); @@ -586,7 +590,6 @@ public: { // change state _state = state_closed; - _synchronous = false; // create a monitor, because the callbacks could destruct the current object Monitor monitor(this); @@ -620,6 +623,9 @@ public: { // skip if there is no oldest callback if (!_oldestCallback) return true; + + // the last (possibly synchronous) operation was received, so we're no longer in synchronous mode + if (_synchronous && _queue.empty()) _synchronous = false; // we are going to call callbacks that could destruct the channel Monitor monitor(this); diff --git a/src/channelimpl.cpp b/src/channelimpl.cpp index e655657..a498864 100644 --- a/src/channelimpl.cpp +++ b/src/channelimpl.cpp @@ -3,7 +3,7 @@ * * Implementation for a channel * - * @copyright 2014 - 2017 Copernica BV + * @copyright 2014 - 2018 Copernica BV */ #include "includes.h" #include "basicdeliverframe.h" @@ -693,7 +693,7 @@ bool ChannelImpl::send(const Frame &frame) // added to the list of deferred objects. it will be notified about // the error when the close operation succeeds if (_state == state_closing) return true; - + // are we currently in synchronous mode or are there // other frames waiting for their turn to be sent? if (_synchronous || !_queue.empty())