From d09db368898419c6e1a662cc9d6e1a56ac0da290 Mon Sep 17 00:00:00 2001 From: Dmitry Grudin Date: Fri, 13 Dec 2024 12:52:43 +0300 Subject: [PATCH] Changed error detection check when sending data via socket --- clickhouse/base/socket.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clickhouse/base/socket.cpp b/clickhouse/base/socket.cpp index 3c866299..3bb1aa5a 100644 --- a/clickhouse/base/socket.cpp +++ b/clickhouse/base/socket.cpp @@ -457,11 +457,12 @@ size_t SocketOutput::DoWrite(const void* data, size_t len) { static const int flags = 0; #endif - if (::send(s_, (const char*)data, (int)len, flags) != (int)len) { + const ssize_t ret = ::send(s_, (const char*)data, (int)len, flags); + if (ret < 0) { throw std::system_error(getSocketErrorCode(), getErrorCategory(), "fail to send " + std::to_string(len) + " bytes of data"); } - return len; + return (size_t)ret; }