mirror of
https://github.com/docker/docs.git
synced 2026-04-12 06:19:22 +07:00
Merge pull request #9543 from ErikDubbelboer/racefix
Removed race condition
This commit is contained in:
@@ -34,9 +34,8 @@ func Trap(cleanup func()) {
|
||||
case os.Interrupt, syscall.SIGTERM:
|
||||
// If the user really wants to interrupt, let him do so.
|
||||
if atomic.LoadUint32(&interruptCount) < 3 {
|
||||
atomic.AddUint32(&interruptCount, 1)
|
||||
// Initiate the cleanup only once
|
||||
if atomic.LoadUint32(&interruptCount) == 1 {
|
||||
if atomic.AddUint32(&interruptCount, 1) == 1 {
|
||||
// Call cleanup handler
|
||||
cleanup()
|
||||
os.Exit(0)
|
||||
|
||||
Reference in New Issue
Block a user