Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
daveads committed Oct 3, 2024
1 parent 4e3c5cb commit f7a627e
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions xhttp/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,23 @@ func Serve(ctx context.Context, shutdownTimeout time.Duration, s *http.Server, l
serverClosed := make(chan struct{})
var serverError error
go func() {
serverError = ss.ListenAndServe(l)
close(serverClosed)
serverError = ss.ListenAndServe(l)
close(serverClosed)
}()

select {
case <-serverClosed:
return serverError
return serverError
case <-ctx.Done():
shutdownCtx, cancel := context.WithTimeout(xcontext.WithoutCancel(ctx), shutdownTimeout)
defer cancel()

err := ss.Shutdown(shutdownCtx)
<-serverClosed // Wait for server to exit
if err != nil {
return err
}
return serverError
shutdownCtx, cancel := context.WithTimeout(xcontext.WithoutCancel(ctx), shutdownTimeout)
defer cancel()

err := ss.Shutdown(shutdownCtx)
<-serverClosed // Wait for server to exit
if err != nil {
return err
}
return serverError
}
}

}

0 comments on commit f7a627e

Please sign in to comment.