From b48df94f40697c7150000947d73fcec2ca719b12 Mon Sep 17 00:00:00 2001 From: Shuaipeng Yu Date: Fri, 5 Feb 2021 14:48:43 +0800 Subject: [PATCH] server: fix tcp-keep-alive config Signed-off-by: Shuaipeng Yu --- server/server.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/server/server.go b/server/server.go index cad3518d9c7ba..8714be5347b2e 100644 --- a/server/server.go +++ b/server/server.go @@ -169,11 +169,9 @@ func (s *Server) InitGlobalConnID(serverIDGetter func() uint64) { // It allocates a connection ID and random salt data for authentication. func (s *Server) newConn(conn net.Conn) *clientConn { cc := newClientConn(s) - if s.cfg.Performance.TCPKeepAlive { - if tcpConn, ok := conn.(*net.TCPConn); ok { - if err := tcpConn.SetKeepAlive(true); err != nil { - logutil.BgLogger().Error("failed to set tcp keep alive option", zap.Error(err)) - } + if tcpConn, ok := conn.(*net.TCPConn); ok { + if err := tcpConn.SetKeepAlive(s.cfg.Performance.TCPKeepAlive); err != nil { + logutil.BgLogger().Error("failed to set tcp keep alive option", zap.Error(err)) } } cc.setConn(conn)