From 2b2ad6d605612f6553f15f7bf85f84678ddc2581 Mon Sep 17 00:00:00 2001 From: "lzhou/zhl@dev3-63.(none)" <> Date: Fri, 30 Mar 2007 15:01:03 +0000 Subject: [PATCH] BUG#24793 Add SO_KEEPALIVE socket option to avoid cluster nodes keeping dead connections forever. --- ndb/src/common/transporter/TCP_Transporter.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ndb/src/common/transporter/TCP_Transporter.cpp b/ndb/src/common/transporter/TCP_Transporter.cpp index 91a5fb50c57..897bad8b787 100644 --- a/ndb/src/common/transporter/TCP_Transporter.cpp +++ b/ndb/src/common/transporter/TCP_Transporter.cpp @@ -155,6 +155,8 @@ TCP_Transporter::initTransporter() { void TCP_Transporter::setSocketOptions(){ + int sockOptKeepAlive = 1; + if (setsockopt(theSocket, SOL_SOCKET, SO_RCVBUF, (char*)&sockOptRcvBufSize, sizeof(sockOptRcvBufSize)) < 0) { #ifdef DEBUG_TRANSPORTER @@ -169,6 +171,11 @@ TCP_Transporter::setSocketOptions(){ #endif }//if + if (setsockopt(theSocket, SOL_SOCKET, SO_KEEPALIVE, + (char*)&sockOptKeepAlive, sizeof(sockOptKeepAlive)) < 0) { + ndbout_c("The setsockopt SO_KEEPALIVE error code = %d", InetErrno); + }//if + //----------------------------------------------- // Set the TCP_NODELAY option so also small packets are sent // as soon as possible