From c4accf5525e1a8247d15c7122a8c54fa5d34f9d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Sat, 31 Aug 2019 12:58:37 +0200 Subject: [PATCH] interrupt: also protect cancel with the mutex --- util/interrupt/cleaner.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/util/interrupt/cleaner.go b/util/interrupt/cleaner.go index 42f925c49fa7fd77265444fd30837597638e5282..38c8425bae13870978a3813c74e156e0cf3742ed 100644 --- a/util/interrupt/cleaner.go +++ b/util/interrupt/cleaner.go @@ -33,7 +33,12 @@ func RegisterCleaner(cleaner CleanerFunc) CancelFunc { defer mu.Unlock() w := &wrapper{f: cleaner} - cancel := func() { w.disabled = true } + + cancel := func() { + mu.Lock() + defer mu.Unlock() + w.disabled = true + } // prepend to later execute then in reverse order cleaners = append([]*wrapper{w}, cleaners...)