Fixed issue where the negotiate was overwritten by the handler and the connection was closed but still a timeout was triggered
This commit is contained in:
parent
949dc933eb
commit
1e44e6b68b
|
|
@ -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
|
* @return bool
|
||||||
*/
|
*/
|
||||||
bool ready() const
|
bool ready() const
|
||||||
{
|
{
|
||||||
return _implementation.ready();
|
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
|
* Is the connection in a usable state, or is it already closed or
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Are we fully connected and ready for instructions? This is true after the initial
|
* 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
|
* @return bool
|
||||||
*/
|
*/
|
||||||
bool ready() const
|
bool ready() const
|
||||||
|
|
@ -228,6 +228,17 @@ public:
|
||||||
return _state == state_connected;
|
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?
|
* Are we closing down?
|
||||||
* @return bool
|
* @return bool
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,7 @@ private:
|
||||||
|
|
||||||
// timer is no longer active, so the refcounter in the loop is restored
|
// timer is no longer active, so the refcounter in the loop is restored
|
||||||
ev_ref(_loop);
|
ev_ref(_loop);
|
||||||
|
|
||||||
// if the onNegotiate method was not yet called, and no heartbeat timeout was negotiated
|
// if the onNegotiate method was not yet called, and no heartbeat timeout was negotiated
|
||||||
if (_timeout == 0)
|
if (_timeout == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -243,10 +243,10 @@ private:
|
||||||
// in either case we're no longer going to run further timers.
|
// in either case we're no longer going to run further timers.
|
||||||
_next = _expire = 0.0;
|
_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
|
// 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
|
// this is a connection timeout, close the connection from our side too
|
||||||
return (void)_connection->close(true);
|
return (void)_connection->close(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ private:
|
||||||
* @friend
|
* @friend
|
||||||
*/
|
*/
|
||||||
friend TcpChannel;
|
friend TcpChannel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method that is called when the RabbitMQ server and your client application
|
* Method that is called when the RabbitMQ server and your client application
|
||||||
|
|
@ -237,13 +237,24 @@ public:
|
||||||
bool close(bool immediate = false);
|
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
|
* @return bool
|
||||||
*/
|
*/
|
||||||
bool ready() const
|
bool ready() const
|
||||||
{
|
{
|
||||||
return _connection.ready();
|
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
|
* Is the connection in a usable state / not yet closed or being closed
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue