Skip to content

Commit

Permalink
[irods#8050] Fix error handling logic for heartbeat operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
korydraughn committed Dec 6, 2024
1 parent 9a7a55e commit 4616dbc
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions server/main_server/src/rodsServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2457,14 +2457,20 @@ void readWorkerTask()

while (bytes_to_send) {
const int bytes_sent = send(newSock, &(heartbeat[heartbeat_length - bytes_to_send]), bytes_to_send, 0);
const int errsav = errno;
if (bytes_sent > 0) {
bytes_to_send -= bytes_sent;

// We do not check for 0 because it is not considered an error condition. It only means 0
// bytes were sent. As long as we have more bytes to send and no error has occurred, we
// keep attempting to send bytes.
if (bytes_sent == -1) {
const int errsav = errno;
if (errsav != EINTR) {
log_server::error(
"Socket error encountered during heartbeat; socket returned {}", strerror(errsav));
break;
}
}
else if (errsav != EINTR) {
log_server::error("Socket error encountered during heartbeat; socket returned {}",
strerror(errsav));
break;
else if (bytes_sent > 0) {
bytes_to_send -= bytes_sent;
}
}

Expand Down

0 comments on commit 4616dbc

Please sign in to comment.