cpp: Add setLowRTO to TSocket
low tcp RTO might mitigate TCP incast problems. Adding the setLowRTO
function to TSocket allows us to experiment with a solution.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920685 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/transport/TSocket.cpp b/lib/cpp/src/transport/TSocket.cpp
index d27c868..ce1ddcb 100644
--- a/lib/cpp/src/transport/TSocket.cpp
+++ b/lib/cpp/src/transport/TSocket.cpp
@@ -153,6 +153,15 @@
// No delay
setNoDelay(noDelay_);
+ // Uses a low min RTO if asked to.
+#ifdef TCP_LOW_MIN_RTO
+ if (getUseLowMinRto()) {
+ int one = 1;
+ setsockopt(socket_, IPPROTO_TCP, TCP_LOW_MIN_RTO, &one, sizeof(one));
+ }
+#endif
+
+
// Set the socket to be non blocking for connect if a timeout exists
int flags = fcntl(socket_, F_GETFL, 0);
if (connTimeout_ > 0) {
@@ -589,4 +598,12 @@
return peerPort_;
}
+bool TSocket::useLowMinRto_ = false;
+void TSocket::setUseLowMinRto(bool useLowMinRto) {
+ useLowMinRto_ = useLowMinRto;
+}
+bool TSocket::getUseLowMinRto() {
+ return useLowMinRto_;
+}
+
}}} // apache::thrift::transport