优化网络连接关闭速度

This commit is contained in:
刘祥超
2023-01-07 10:03:32 +08:00
parent a17878f5b2
commit 7abb84c880

View File

@@ -104,10 +104,13 @@ func (this *ClientConn) Read(b []byte) (n int, err error) {
this.hasRead = true this.hasRead = true
} }
// 检测是否为握手错误 // 检测是否为超时错误
var isHandshakeError = err != nil && os.IsTimeout(err) && !this.hasRead var isTimeout = err != nil && os.IsTimeout(err)
if isHandshakeError { var isHandshakeError = isTimeout && !this.hasRead
if isTimeout {
_ = this.SetLinger(0) _ = this.SetLinger(0)
} else {
_ = this.SetLinger(nodeconfigs.DefaultTCPLinger)
} }
// 忽略白名单和局域网 // 忽略白名单和局域网