Use isErrClosed in Server.Serve
This commit is contained in:
parent
e4f22a8f40
commit
1626ffb97b
@ -6,7 +6,6 @@ import (
|
|||||||
"mime"
|
"mime"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
@ -197,8 +196,7 @@ func (s *Server) Serve(ln net.Listener) error {
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
conn, err := ln.Accept()
|
conn, err := ln.Accept()
|
||||||
// TODO: use net.ErrClosed when available
|
if isErrClosed(err) {
|
||||||
if err != nil && strings.Contains(err.Error(), "use of closed network connection") {
|
|
||||||
return nil
|
return nil
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return fmt.Errorf("failed to accept connection: %v", err)
|
return fmt.Errorf("failed to accept connection: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user