Merge pull request #320 from CopernicaMarketingSoftware/timoutFix

Fixed issue where timeout triggered an invalid error
This commit is contained in:
Rafal Goslawski 2020-02-26 12:06:27 +01:00 committed by GitHub
commit 5ca2d77ae3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 8 deletions

View File

@ -197,13 +197,22 @@ public:
}
/**
* Is the connection ready to accept instructions / has passed the login handshake?
* Is the connection ready to accept instructions / has passed the login handshake and not closed?
* @return bool
*/
bool ready() const
{
return _implementation.ready();
}
/**
* Is (or was) the connection initialized
* @return bool
*/
bool initialized() const
{
return _implementation.initialized();
}
/**
* Is the connection in a usable state, or is it already closed or

View File

@ -219,7 +219,7 @@ public:
/**
* Are we fully connected and ready for instructions? This is true after the initial
* protocol and login handshake were completed.
* protocol and login handshake were completed and the connection is not closed.
* @return bool
*/
bool ready() const
@ -228,6 +228,17 @@ public:
return _state == state_connected;
}
/**
* Is (or was) the connection initialized
* @return bool
*/
bool initialized() const
{
// We are initalized if we have passed the initialized state. So we are in
// a connected, closing, or closed state.
return _state == state_connected || _state == state_closing || _state == state_closed;
}
/**
* Are we closing down?
* @return bool

View File

@ -234,7 +234,7 @@ private:
// timer is no longer active, so the refcounter in the loop is restored
ev_ref(_loop);
// if the onNegotiate method was not yet called, and no heartbeat timeout was negotiated
if (_timeout == 0)
{
@ -243,10 +243,10 @@ private:
// in either case we're no longer going to run further timers.
_next = _expire = 0.0;
// if we have a valid connection, user-space must have overridden the onNegotiate
// if we have an initialized connection, user-space must have overridden the onNegotiate
// method, so we keep using the connection
if (_connection->ready()) return;
if (_connection->initialized()) return;
// this is a connection timeout, close the connection from our side too
return (void)_connection->close(true);
}

View File

@ -57,7 +57,7 @@ private:
* @friend
*/
friend TcpChannel;
/**
* Method that is called when the RabbitMQ server and your client application
@ -237,13 +237,24 @@ public:
bool close(bool immediate = false);
/**
* Is the connection connected, meaning: it has passed the login handshake?
* Is the connection connected, meaning: it has passed the login handshake
* and isn't closed yet?
* @return bool
*/
bool ready() const
{
return _connection.ready();
}
/**
* Is the connection initialized, meaning: it has passed the login handshake?
* It may be closing or closed
* @return bool
*/
bool initialized() const
{
return _connection.initialized();
}
/**
* Is the connection in a usable state / not yet closed or being closed