Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
proxy: do not log error messages when http Server is closed
Browse files Browse the repository at this point in the history
Signed-off-by: SataQiu <[email protected]>
  • Loading branch information
SataQiu authored and lowzj committed May 6, 2020
1 parent bacc34b commit bd47d0c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dfdaemon/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ func (proxy *Proxy) handleHTTPS(w http.ResponseWriter, r *http.Request) {
// We have to wait until the connection is closed
wg := sync.WaitGroup{}
wg.Add(1)
if err := http.Serve(&singleUseListener{&customCloseConn{sConn, wg.Done}}, rp); err != nil {
// NOTE: http.Serve always returns a non-nil error
if err := http.Serve(&singleUseListener{&customCloseConn{sConn, wg.Done}}, rp); err != errServerClosed && err != http.ErrServerClosed {
logrus.Errorf("failed to accept incoming HTTP connections: %v", err)
}
wg.Wait()
Expand Down Expand Up @@ -455,9 +456,13 @@ type singleUseListener struct {
c net.Conn
}

// errServerClosed is returned by the singleUseListener's Accept method
// when it receives the subsequent calls after the first Accept call
var errServerClosed = errors.New("singleUseListener: Server closed")

func (l *singleUseListener) Accept() (net.Conn, error) {
if l.c == nil {
return nil, errors.New("closed")
return nil, errServerClosed
}
c := l.c
l.c = nil
Expand Down

0 comments on commit bd47d0c

Please sign in to comment.