Merge pull request #398 from CopernicaMarketingSoftware/synchronous-success-callback

Avoid that multiple frames are sent by the channel-on-ready handler
This commit is contained in:
Emiel Bruijntjes 2021-06-16 14:12:18 +02:00 committed by GitHub
commit f52fdf6977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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