From: Bryan Duxbury Date: Mon, 29 Aug 2011 18:05:26 +0000 (+0000) Subject: THRIFT-1302. cpp: raise an exception if send() times out in X-Git-Tag: 0.8.0~115 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=9759266f2da68ce665b3b050cf5d8f37f8fc556f;p=common%2Fthrift.git 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 --- 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; }