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 2f5a0b0..b5ed829 100644
--- a/lib/cpp/src/transport/TSocket.cpp
+++ b/lib/cpp/src/transport/TSocket.cpp
@@ -481,9 +481,10 @@
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;
}