Skip to content

Commit

Permalink
core: Only initiate exit once (should fix #6707)
Browse files Browse the repository at this point in the history
  • Loading branch information
mholt committed Dec 31, 2024
1 parent 3f3f8b3 commit 34cff4a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions caddy.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,10 @@ func Validate(cfg *Config) error {
// Errors are logged along the way, and an appropriate exit
// code is emitted.
func exitProcess(ctx context.Context, logger *zap.Logger) {
// let the rest of the program know we're quitting
atomic.StoreInt32(exiting, 1)
// let the rest of the program know we're quitting; only do it once
if !atomic.CompareAndSwapInt32(exiting, 0, 1) {
return
}

// give the OS or service/process manager our 2 weeks' notice: we quit
if err := notify.Stopping(); err != nil {
Expand Down

0 comments on commit 34cff4a

Please sign in to comment.