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:
aljar 2020-02-19 11:19:12 +01:00
parent 949dc933eb
commit 1e44e6b68b
4 changed files with 39 additions and 8 deletions

View File

@ -197,7 +197,7 @@ 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
@ -205,6 +205,15 @@ public:
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
* in the process of being closed?

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

@ -243,9 +243,9 @@ 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

@ -237,7 +237,8 @@ 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
@ -245,6 +246,16 @@ public:
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
* When a connection is usable, you can send further commands over it. When it is