fixed issue when end-of-file was encountered, this fixes #266

This commit is contained in:
Emiel Bruijntjes 2018-11-30 06:42:16 +01:00
parent 53f994d61d
commit d2e3792abc
2 changed files with 3 additions and 5 deletions

View File

@ -86,7 +86,7 @@ public:
* Return 0 if you want to disable heartbeats.
*
* If heartbeats are enabled, you yourself are responsible to send
* out a heartbeat every *interval* number of seconds by calling
* out a heartbeat every *interval / 2* number of seconds by calling
* the Connection::heartbeat() method.
*
* @param connection The connection that suggested a heartbeat interval

View File

@ -151,11 +151,9 @@ public:
// read data from buffer
ssize_t result = _in.receivefrom(_socket, _parent->expected());
// are we in an error state?
if (result < 0 && reportError()) return finalState(monitor);
// did we encounter end-of-file or are we in an error state?
if (result == 0 || (result < 0 && reportError())) return finalState(monitor);
// @todo should we also check for result == 0
// we need a local copy of the buffer - because it is possible that "this"
// object gets destructed halfway through the call to the parse() method
TcpInBuffer buffer(std::move(_in));