From ee2df12a1571c309a7f92746334b5d7791258df1 Mon Sep 17 00:00:00 2001 From: FUJIWARA Shunichiro Date: Fri, 22 Jun 2018 15:52:47 +0900 Subject: [PATCH] Ignore errors after a server shutdown. When a listener shutdown, scanner.Err() of active connections return an error "use of closed network connection". 2018-06-22T05:07:27.255Z WARN go-katsubushi/app.go:275 error on scanning request: read tcp 127.0.0.1:11212->127.0.0.1:34972: use of closed network connection --- app.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app.go b/app.go index 52bf14b..7782576 100644 --- a/app.go +++ b/app.go @@ -269,6 +269,12 @@ func (app *App) handleConn(ctx context.Context, conn net.Conn) { } } if err := scanner.Err(); err != nil { + select { + case <-ctx.Done(): + // shutting down + return + default: + } if !deadline.IsZero() && time.Now().After(deadline) { log.Debugf("deadline exceeded: %s", err) } else {