agent: set tcpKeepAliveListener when there is no error

This commit is contained in:
Frank Schroeder 2017-05-31 10:24:32 +02:00
parent e48df7b572
commit a9451d596f
No known key found for this signature in database
GPG Key ID: 4D65C6EAEC87DECD
1 changed files with 4 additions and 6 deletions

View File

@ -371,9 +371,6 @@ func (a *Agent) listenHTTP(addrs []ProtoAddr) ([]net.Listener, error) {
case p.Net == "tcp" && p.Proto == "http": case p.Net == "tcp" && p.Proto == "http":
l, err = net.Listen("tcp", p.Addr) l, err = net.Listen("tcp", p.Addr)
if err != nil {
l = &tcpKeepAliveListener{l.(*net.TCPListener)}
}
case p.Net == "tcp" && p.Proto == "https": case p.Net == "tcp" && p.Proto == "https":
var tlscfg *tls.Config var tlscfg *tls.Config
@ -382,9 +379,6 @@ func (a *Agent) listenHTTP(addrs []ProtoAddr) ([]net.Listener, error) {
break break
} }
l, err = tls.Listen("tcp", p.Addr, tlscfg) l, err = tls.Listen("tcp", p.Addr, tlscfg)
if err != nil {
l = &tcpKeepAliveListener{l.(*net.TCPListener)}
}
default: default:
return nil, fmt.Errorf("%s:%s listener not supported", p.Net, p.Proto) return nil, fmt.Errorf("%s:%s listener not supported", p.Net, p.Proto)
@ -397,6 +391,10 @@ func (a *Agent) listenHTTP(addrs []ProtoAddr) ([]net.Listener, error) {
return nil, err return nil, err
} }
if tcpl, ok := l.(*net.TCPListener); ok {
l = &tcpKeepAliveListener{tcpl}
}
ln = append(ln, l) ln = append(ln, l)
} }
return ln, nil return ln, nil