From d1c0f96f59ea3df41c6f5e8c21f6f75401babc9d Mon Sep 17 00:00:00 2001 From: Carlos Date: Tue, 16 Apr 2024 18:13:25 +0100 Subject: [PATCH] transport(tcp): better error reporting on timeout (#425) 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. --- include/faabric/transport/tcp/Socket.h | 2 +- src/transport/tcp/SendSocket.cpp | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/faabric/transport/tcp/Socket.h b/include/faabric/transport/tcp/Socket.h index 746b74cd5..93abcc0a6 100644 --- a/include/faabric/transport/tcp/Socket.h +++ b/include/faabric/transport/tcp/Socket.h @@ -5,7 +5,7 @@ namespace faabric::transport::tcp { -const int SocketTimeoutMs = 3000; +const int SocketTimeoutMs = 5000; class Socket { diff --git a/src/transport/tcp/SendSocket.cpp b/src/transport/tcp/SendSocket.cpp index ff92900a6..00b353f82 100644 --- a/src/transport/tcp/SendSocket.cpp +++ b/src/transport/tcp/SendSocket.cpp @@ -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!"); }