THRIFT-1302. cpp: raise an exception if send() times out in
authorBryan Duxbury <bryanduxbury@apache.org>
Mon, 29 Aug 2011 18:05:26 +0000 (18:05 +0000)
committerBryan Duxbury <bryanduxbury@apache.org>
Mon, 29 Aug 2011 18:05:26 +0000 (18:05 +0000)
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

index 2f5a0b0..b5ed829 100644 (file)
@@ -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;
   }