From 1717e47b4d3652edf95c919a5514b860b07ed94a Mon Sep 17 00:00:00 2001 From: Kory Draughn Date: Mon, 28 Oct 2024 12:45:12 -0400 Subject: [PATCH] [?] Fix error handling logic for heartbeat operation. --- server/main_server/src/agent_main.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/server/main_server/src/agent_main.cpp b/server/main_server/src/agent_main.cpp index 1672bf5bbc..99be61386a 100644 --- a/server/main_server/src/agent_main.cpp +++ b/server/main_server/src/agent_main.cpp @@ -832,14 +832,15 @@ namespace while (bytes_to_send) { const int bytes_sent = send(net_obj->socket_handle(), &(heartbeat[heartbeat_length - bytes_to_send]), bytes_to_send, 0); - const int errsav = errno; - if (errsav != EINTR) { - log_agent::error("{}: Socket error encountered during heartbeat; socket returned {}", - __func__, strerror(errsav)); - break; + if (bytes_sent == -1) { + const int errsav = errno; + if (errsav != EINTR) { + log_agent::error("{}: Socket error encountered during heartbeat; socket returned {}", + __func__, strerror(errsav)); + break; + } } - - if (bytes_sent > 0) { + else if (bytes_sent > 0) { bytes_to_send -= bytes_sent; } }