Commit a5b81d74cd9f3f74bf901ed32198c4f1e77cd82f

Authored by Wiebe Cazemier
1 parent 2a3138f9

Fix handling lingering bytes after reconnect

Showing 1 changed file with 4 additions and 5 deletions
main.cpp
... ... @@ -45,15 +45,14 @@ void do_thread_work(ThreadData *threadData)
45 45 {
46 46 if (cur_ev.events & EPOLLIN)
47 47 {
48   - if (!client->readFdIntoBuffer())
  48 + bool readSuccess = client->readFdIntoBuffer();
  49 + client->bufferToMqttPackets(packetQueueIn, client);
  50 +
  51 + if (!readSuccess)
49 52 {
50 53 std::cout << "Disconnect: " << client->repr() << std::endl;
51 54 threadData->removeClient(client);
52 55 }
53   - else
54   - {
55   - client->bufferToMqttPackets(packetQueueIn, client);
56   - }
57 56 }
58 57 if (cur_ev.events & EPOLLOUT)
59 58 {
... ...