Merge pull request #283 from bboreham/spin-less

Only re-try AcceptTCP() if the error is temporary
This commit is contained in:
Miek Gieben 2015-10-30 21:51:19 +00:00
commit 6a1556664f
1 changed files with 4 additions and 1 deletions

View File

@ -434,7 +434,10 @@ func (srv *Server) serveTCP(l *net.TCPListener) error {
for {
rw, e := l.AcceptTCP()
if e != nil {
continue
if neterr, ok := e.(net.Error); ok && neterr.Temporary() {
continue
}
return e
}
m, e := reader.ReadTCP(rw, rtimeout)
srv.lock.RLock()