when an error is detected on a channel, all subsequent and cached deferred objects are notified about the error too
This commit is contained in:
parent
d08270701e
commit
60b59524e7
|
|
@ -485,6 +485,12 @@ public:
|
|||
if (!next) _newestCallback = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report errors to all deferred objects already in an error state
|
||||
* @param force Report errors even for objects not already in error state
|
||||
*/
|
||||
void reportErrors(bool force = false);
|
||||
|
||||
/**
|
||||
* Report an error message on a channel
|
||||
* @param message
|
||||
|
|
@ -514,6 +520,9 @@ public:
|
|||
|
||||
// if there was no next callback, the newest callback was just used
|
||||
if (!next) _newestCallback = nullptr;
|
||||
|
||||
// when one error occured, all subsequent messages are in an error state too
|
||||
reportErrors(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ public:
|
|||
* @param connection the connection that needs the timeout
|
||||
* @param timeout number of seconds to wait
|
||||
* @param callback function to execute once time runs out
|
||||
*
|
||||
*
|
||||
* @todo this one should be removed
|
||||
*/
|
||||
virtual void setTimeout(Connection *connection, double seconds, const std::function<void()>& callback) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,32 @@ Deferred &ChannelImpl::push(const Frame &frame)
|
|||
return push(new Deferred(send(frame)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Report errors to all deferred objects already in an error state
|
||||
* @param force Report errors even for objects not already in error state
|
||||
*/
|
||||
void ChannelImpl::reportErrors(bool force)
|
||||
{
|
||||
// keep looping for as long as the oldest callback is in an error state
|
||||
while (_oldestCallback && (force || !*_oldestCallback))
|
||||
{
|
||||
// construct monitor, because channel could be destructed
|
||||
Monitor monitor(this);
|
||||
|
||||
// report the error
|
||||
auto *next = _oldestCallback->reportError("Frame could not be sent");
|
||||
|
||||
// leap out if object is no longer valid after the callback was called
|
||||
if (!monitor.valid()) return;
|
||||
|
||||
// install the next deferred object
|
||||
_oldestCallback.reset(next);
|
||||
|
||||
// was this also the newest callback
|
||||
if (!next) _newestCallback = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause deliveries on a channel
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue