mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
优化tcp连接
This commit is contained in:
@@ -72,7 +72,10 @@ func (client *TCPClient) init() {
|
|||||||
func (client *TCPClient) dial() net.Conn {
|
func (client *TCPClient) dial() net.Conn {
|
||||||
for {
|
for {
|
||||||
conn, err := net.Dial("tcp", client.Addr)
|
conn, err := net.Dial("tcp", client.Addr)
|
||||||
if err == nil || client.closeFlag {
|
if client.closeFlag {
|
||||||
|
return conn
|
||||||
|
} else if err == nil && conn != nil {
|
||||||
|
conn.(*net.TCPConn).SetNoDelay(true)
|
||||||
return conn
|
return conn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ func (server *TCPServer) run() {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
conn.(*net.TCPConn).SetNoDelay(true)
|
||||||
tempDelay = 0
|
tempDelay = 0
|
||||||
|
|
||||||
server.mutexConns.Lock()
|
server.mutexConns.Lock()
|
||||||
|
|||||||
Reference in New Issue
Block a user