From d2e3792abc1766693869e1ace1f03f32d2fc0afc Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Fri, 30 Nov 2018 06:42:16 +0100 Subject: [PATCH] fixed issue when end-of-file was encountered, this fixes #266 --- include/amqpcpp/connectionhandler.h | 2 +- src/linux_tcp/tcpconnected.h | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/include/amqpcpp/connectionhandler.h b/include/amqpcpp/connectionhandler.h index fb3532d..ceceb25 100644 --- a/include/amqpcpp/connectionhandler.h +++ b/include/amqpcpp/connectionhandler.h @@ -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 diff --git a/src/linux_tcp/tcpconnected.h b/src/linux_tcp/tcpconnected.h index e78dc23..3030df4 100644 --- a/src/linux_tcp/tcpconnected.h +++ b/src/linux_tcp/tcpconnected.h @@ -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));