avoid that multiple frames are sent by the channel-on-ready handler

This commit is contained in:
Emiel Bruijntjes 2021-06-15 11:56:56 +02:00
parent dc9d88f4b1
commit 45775fefe8
2 changed files with 4 additions and 10 deletions

View File

@ -617,20 +617,14 @@ public:
*/
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();
}
/**

View File

@ -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
@ -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