From 41c2655edd167045c2c6e7daee4c2f06868483ca Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Wed, 24 Jun 2020 01:32:19 +0300 Subject: [PATCH] Disconnect sockets when read returns zero --- msgr_receive.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/msgr_receive.cpp b/msgr_receive.cpp index e956622b..a55d1070 100644 --- a/msgr_receive.cpp +++ b/msgr_receive.cpp @@ -52,10 +52,13 @@ bool osd_messenger_t::handle_read(int result, int peer_fd) if (cl_it != clients.end()) { auto & cl = cl_it->second; - if (result < 0 && result != -EAGAIN) + if (result <= 0 && result != -EAGAIN) { - // this is a client socket, so don't panic. just disconnect it - printf("Client %d socket read error: %d (%s). Disconnecting client\n", peer_fd, -result, strerror(-result)); + // this is a client socket, so don't panic on error. just disconnect it + if (result != 0) + { + printf("Client %d socket read error: %d (%s). Disconnecting client\n", peer_fd, -result, strerror(-result)); + } stop_client(peer_fd); return false; }