Skip to content

Commit bfd5a07

Browse files
committed
Changed error detection check when sending data via socket
1 parent d242cc8 commit bfd5a07

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clickhouse/base/socket.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,12 @@ size_t SocketOutput::DoWrite(const void* data, size_t len) {
457457
static const int flags = 0;
458458
#endif
459459

460-
if (::send(s_, (const char*)data, (int)len, flags) != (int)len) {
460+
const ssize_t ret = ::send(s_, (const char*)data, (int)len, flags);
461+
if (ret < 0) {
461462
throw std::system_error(getSocketErrorCode(), getErrorCategory(), "fail to send " + std::to_string(len) + " bytes of data");
462463
}
463464

464-
return len;
465+
return (size_t)ret;
465466
}
466467

467468

0 commit comments

Comments
 (0)