Skip to content

Commit 243d866

Browse files
authored
Merge pull request #25 from Mayank77maruti/master
Fix Daily CI
2 parents 44c011a + 152684e commit 243d866

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

xhttp/serve.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,14 @@ func Serve(ctx context.Context, shutdownTimeout time.Duration, s *http.Server, l
3636
case err := <-done:
3737
return err
3838
case <-ctx.Done():
39-
ctx = xcontext.WithoutCancel(ctx)
40-
ctx, cancel := context.WithTimeout(ctx, shutdownTimeout)
39+
shutdownCtx := xcontext.WithoutCancel(ctx)
40+
shutdownCtx, cancel := context.WithTimeout(shutdownCtx, shutdownTimeout)
4141
defer cancel()
42-
return s.Shutdown(ctx)
42+
shutdownErr := s.Shutdown(shutdownCtx)
43+
serveErr := <-done
44+
if serveErr != nil && serveErr != http.ErrServerClosed {
45+
return serveErr
46+
}
47+
return shutdownErr
4348
}
4449
}

0 commit comments

Comments
 (0)