优化连接关闭速度

This commit is contained in:
GoEdgeLab
2021-10-25 19:00:42 +08:00
parent 22ca557691
commit d8943f3816
5 changed files with 51 additions and 22 deletions

View File

@@ -48,11 +48,13 @@ type ClientConn struct {
isClosed bool
}
func NewClientConn(conn net.Conn) net.Conn {
tcpConn, ok := conn.(*net.TCPConn)
if ok {
// TODO 可以设置此值
_ = tcpConn.SetLinger(0)
func NewClientConn(conn net.Conn, quickClose bool) net.Conn {
if quickClose {
tcpConn, ok := conn.(*net.TCPConn)
if ok {
// TODO 可以设置此值
_ = tcpConn.SetLinger(0)
}
}
return &ClientConn{rawConn: conn}