From a5b81d74cd9f3f74bf901ed32198c4f1e77cd82f Mon Sep 17 00:00:00 2001 From: Wiebe Cazemier Date: Thu, 10 Dec 2020 20:47:58 +0100 Subject: [PATCH] Fix handling lingering bytes after reconnect --- main.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index e0c4ac7..148db8d 100644 --- a/main.cpp +++ b/main.cpp @@ -45,15 +45,14 @@ void do_thread_work(ThreadData *threadData) { if (cur_ev.events & EPOLLIN) { - if (!client->readFdIntoBuffer()) + bool readSuccess = client->readFdIntoBuffer(); + client->bufferToMqttPackets(packetQueueIn, client); + + if (!readSuccess) { std::cout << "Disconnect: " << client->repr() << std::endl; threadData->removeClient(client); } - else - { - client->bufferToMqttPackets(packetQueueIn, client); - } } if (cur_ev.events & EPOLLOUT) { -- libgit2 0.21.4