don't call moved-from callbacks

This commit is contained in:
Peter Eisenlohr 2022-03-25 16:08:50 +01:00
parent fa1181aa63
commit 060e42a6dd
4 changed files with 12 additions and 12 deletions

View File

@ -219,7 +219,7 @@ public:
_readyCallback = std::move(callback); _readyCallback = std::move(callback);
// direct call if channel is already ready // direct call if channel is already ready
if (_state == state_ready && callback) callback(); if (_state == state_ready && _readyCallback) _readyCallback();
} }
/** /**

View File

@ -270,7 +270,7 @@ public:
_errorCallback = std::move(callback); _errorCallback = std::move(callback);
// if the object is already in a failed state, we call the callback right away // if the object is already in a failed state, we call the callback right away
if (_failed) callback("Frame could not be sent"); if (_failed) _errorCallback("Frame could not be sent");
// allow chaining // allow chaining
return *this; return *this;

View File

@ -74,25 +74,25 @@ void ChannelImpl::onError(ErrorCallback&& callback)
if (usable()) return; if (usable()) return;
// validity check // validity check
if (!callback) return; if (!_errorCallback) return;
// is the channel closing down? // is the channel closing down?
if (_state == state_closing) return callback("Channel is closing down"); if (_state == state_closing) return _errorCallback("Channel is closing down");
// the channel is closed, but what is the connection doing? // the channel is closed, but what is the connection doing?
if (_connection == nullptr) return callback("Channel is not linked to a connection"); if (_connection == nullptr) return _errorCallback("Channel is not linked to a connection");
// if the connection is valid, this is a pure channel error // if the connection is valid, this is a pure channel error
if (_connection->ready()) return callback("Channel is in an error state, but the connection is valid"); if (_connection->ready()) return _errorCallback("Channel is in an error state, but the connection is valid");
// the connection is closing down // the connection is closing down
if (_connection->closing()) return callback("Channel is in an error state, the AMQP connection is closing down"); if (_connection->closing()) return _errorCallback("Channel is in an error state, the AMQP connection is closing down");
// the connection is already closed // the connection is already closed
if (_connection->closed()) return callback("Channel is in an error state, the AMQP connection has been closed"); if (_connection->closed()) return _errorCallback("Channel is in an error state, the AMQP connection has been closed");
// direct call if channel is already in error state // direct call if channel is already in error state
callback("Channel is in error state, something went wrong with the AMQP connection"); _errorCallback("Channel is in error state, something went wrong with the AMQP connection");
} }
/** /**

View File

@ -188,13 +188,13 @@ void Tagger::onError(ErrorCallback&& callback)
_errorCallback = std::move(callback); _errorCallback = std::move(callback);
// check the callback // check the callback
if (!callback) return; if (!_errorCallback) return;
// if the channel is no longer usable, report that // if the channel is no longer usable, report that
if (!_implementation->usable()) return callback("Channel is no longer usable"); if (!_implementation->usable()) return _errorCallback("Channel is no longer usable");
// specify that we're already closing // specify that we're already closing
if (_close) callback("Wrapped channel is closing down"); if (_close) _errorCallback("Wrapped channel is closing down");
} }
/** /**