Skip to content

Commit

Permalink
transport(tcp): better error reporting on timeout (#425)
Browse files Browse the repository at this point in the history
Turns out there is a situation in which a blocking socket returns EAGAIN
or EWOULDBLOCK. This is when the socket is configured with SO_SNDTIMEO
and the operation times-out.

We amend the error logging to inform of it accordignly.
  • Loading branch information
csegarragonz authored Apr 16, 2024
1 parent a56f111 commit d1c0f96
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/faabric/transport/tcp/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace faabric::transport::tcp {

const int SocketTimeoutMs = 3000;
const int SocketTimeoutMs = 5000;

class Socket
{
Expand Down
22 changes: 16 additions & 6 deletions src/transport/tcp/SendSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,22 @@ void SendSocket::sendOne(const uint8_t* buffer, size_t bufferSize)
continue;
};
#endif
SPDLOG_ERROR("Error error sending TCP message to {}:{} ({}/{}): {}",
host,
port,
totalNumSent,
bufferSize,
std::strerror(errno));
if (errno == EAGAIN || errno == EWOULDBLOCK) {
SPDLOG_ERROR(
"Error sending TCP message to {}:{} ({}/{}: timed-out)",
host,
port,
totalNumSent,
bufferSize);
} else {
SPDLOG_ERROR("Error sending TCP message to {}:{} ({}/{}): {}",
host,
port,
totalNumSent,
bufferSize,
std::strerror(errno));
}

throw std::runtime_error("Error sending TCP message!");
}

Expand Down

0 comments on commit d1c0f96

Please sign in to comment.