Update worker->beacon->dialer
fix keepalive strict checking for tcpConn
@@ -10,11 +10,17 @@ import (
)
func keepaliveDialer(network string, address string, dialTimeout time.Duration, idleTimeout time.Duration) (net.Conn, error) {
+
conn, err := net.DialTimeout(network, address, dialTimeout)
if err != nil {
return nil, err
}
+ err = tcpkeepalive.SetKeepAlive(conn, 10*time.Second, 3, 5*time.Second)
+ if err != nil {
+ println("failed to enable connection keepalive: " + err.Error())
+ }
+
if idleTimeout != 0 {
conn = &ConnectionWithIdleTimeout{
Conn: conn,
@@ -22,10 +28,5 @@ func keepaliveDialer(network string, address string, dialTimeout time.Duration,
}
}
- err = tcpkeepalive.SetKeepAlive(conn, 10*time.Second, 3, 5*time.Second)
- if err != nil {
- println("failed to enable connection keepalive: " + err.Error())
- }
-
return conn, nil
}
