server-mux: Keep listening after Accept() err (#3613)

Accept() can return errors like: `too many open files`, no need to totally quit listening in this case.
This commit is contained in:
Anis Elleuch 2017-01-23 18:55:34 +01:00 committed by Harshavardhana
parent d1d89116f1
commit fc6f804865
1 changed files with 8 additions and 8 deletions

View File

@ -191,20 +191,20 @@ func newListenerMux(listener net.Listener, config *tls.Config) *ListenerMux {
}
// Start listening, wrap connections with tls when needed
go func() {
// Extract tcp listener.
tcpListener, ok := l.Listener.(*net.TCPListener)
if !ok {
l.acceptResCh <- ListenerMuxAcceptRes{err: errInvalidArgument}
return
}
// Loop for accepting new connections
for {
// Extract tcp listener.
tcpListener, ok := l.Listener.(*net.TCPListener)
if !ok {
l.acceptResCh <- ListenerMuxAcceptRes{err: errInvalidArgument}
return
}
// Use accept TCP method to receive the connection.
conn, err := tcpListener.AcceptTCP()
if err != nil {
l.acceptResCh <- ListenerMuxAcceptRes{err: err}
return
continue
}
// Enable Read timeout