From 56e3bed5af98812e992120db26f7ee0b6616413c Mon Sep 17 00:00:00 2001 From: Tapan Karwa Date: Wed, 29 Jul 2015 14:31:24 -0700 Subject: [PATCH] Set TCP_USER_TIMEOUT on connections to ifmap-server. This is required for cases where the control-node's send buffer is non-empty and the other end becomes unreachable. Without this option, we will wait for 20 mins before giving up on the connection. During this time, the config could change but the control-node will not get any updates since the ifmap-server is unreachable. Using this option and then reconnecting to a different reachable ifmap-server solves the problem. Note, this is not required for cases where the other end crashes since we will get a reset in that case. This is required only for reachability problems. Change-Id: Ie0d5c92a76d8913177e137bd0eacbc6a033119ec Closes-Bug: #1479521 (cherry picked from commit 064379c3447c44a54f77575a93cbfd380a7a73f9) --- src/ifmap/client/ifmap_channel.cc | 10 ++++++++++ src/ifmap/client/ifmap_channel.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/ifmap/client/ifmap_channel.cc b/src/ifmap/client/ifmap_channel.cc index b922f346d38..03bda0eb15c 100644 --- a/src/ifmap/client/ifmap_channel.cc +++ b/src/ifmap/client/ifmap_channel.cc @@ -773,6 +773,16 @@ void IFMapChannel::SetArcSocketOptions() { ec.message()); } #endif + +#ifdef TCP_USER_TIMEOUT + boost::asio::detail::socket_option::integer + user_timeout_option(kSessionTcpUserTimeout); + arc_socket_->next_layer().set_option(user_timeout_option, ec); + if (ec) { + IFMAP_PEER_WARN(IFMapServerConnection, "Error setting user timeout", + ec.message()); + } +#endif } // The connection to the peer 'host_' has timed-out. Create a new entry for diff --git a/src/ifmap/client/ifmap_channel.h b/src/ifmap/client/ifmap_channel.h index 92c75d5a741..a6608594896 100644 --- a/src/ifmap/client/ifmap_channel.h +++ b/src/ifmap/client/ifmap_channel.h @@ -173,6 +173,7 @@ class IFMapChannel { static const int kSessionKeepaliveIdleTime = 30; // in seconds static const int kSessionKeepaliveInterval = 3; // in seconds static const int kSessionKeepaliveProbes = 5; // count + static const int kSessionTcpUserTimeout = 45000; // in milliseconds enum ResponseState { NONE = 0,