call cancel after shutdown

This commit is contained in:
nuczzz 2019-01-18 19:33:45 +08:00
parent 7173fd7490
commit 313be996cd
1 changed files with 3 additions and 1 deletions

View File

@ -268,7 +268,9 @@ func (srv *Server) shutdown() {
log.Println(syscall.Getpid(), "Waiting for connections to finish...")
ctx := context.Background()
if DefaultTimeout >= 0 {
ctx, _ = context.WithTimeout(context.Background(), DefaultTimeout)
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(context.Background(), DefaultTimeout)
defer cancel()
}
srv.terminalChan <- srv.Server.Shutdown(ctx)
}