From 9759266f2da68ce665b3b050cf5d8f37f8fc556f Mon Sep 17 00:00:00 2001 From: Bryan Duxbury Date: Mon, 29 Aug 2011 18:05:26 +0000 Subject: [PATCH] THRIFT-1302. cpp: raise an exception if send() times out in TSocket::write() Patch: Adam Simpkins git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1162923 13f79535-47bb-0310-9956-ffa450edef68 --- lib/cpp/src/transport/TSocket.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/cpp/src/transport/TSocket.cpp b/lib/cpp/src/transport/TSocket.cpp index 2f5a0b0a..b5ed8292 100644 --- a/lib/cpp/src/transport/TSocket.cpp +++ b/lib/cpp/src/transport/TSocket.cpp @@ -481,9 +481,10 @@ void TSocket::write(const uint8_t* buf, uint32_t len) { while (sent < len) { uint32_t b = write_partial(buf + sent, len - sent); if (b == 0) { - // We assume that we got 0 because send() errored with EAGAIN due to - // lack of system resources; release the CPU for a bit. - usleep(50); + // This should only happen if the timeout set with SO_SNDTIMEO expired. + // Raise an exception. + throw TTransportException(TTransportException::TIMED_OUT, + "send timeout expired"); } sent += b; } -- 2.17.1