@marcel91200 / caddy Mirror · read-only / commits / 34cff4af
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 12, 04:30 UTC

core: Only initiate exit once (should fix #6707)

Matthew Holt committed Dec 31, 2024 at 13:08 UTC 34cff4af7db1365bba6decc647ccfb6bf1b21afd
1 file changed +4 -2
caddy.go
+4 -2
@@ -725,8 +725,10 @@ func Validate(cfg *Config) error {
725 // Errors are logged along the way, and an appropriate exit
726 // code is emitted.
727 func exitProcess(ctx context.Context, logger *zap.Logger) {
728 - // let the rest of the program know we're quitting
729 - atomic.StoreInt32(exiting, 1)
728 + // let the rest of the program know we're quitting; only do it once
729 + if !atomic.CompareAndSwapInt32(exiting, 0, 1) {
730 + return
731 + }
732
733 // give the OS or service/process manager our 2 weeks' notice: we quit
734 if err := notify.Stopping(); err != nil {