mirror of
https://github.com/pgsty/minio.git
synced 2026-07-22 21:50:22 +03:00
Protect shutdown callbacks lists with a mutex (#2432)
This commit is contained in:
committed by
Harshavardhana
parent
9606cb9bcd
commit
5526ac13d2
+10
-12
@@ -20,21 +20,19 @@ import "testing"
|
||||
|
||||
// ShutdownCallback simulates a successful and failure exit here.
|
||||
func TestShutdownCallbackSuccess(t *testing.T) {
|
||||
// Register two callbacks that return success
|
||||
registerObjectStorageShutdown(func() errCode {
|
||||
return exitSuccess
|
||||
})
|
||||
registerShutdown(func() errCode {
|
||||
return exitSuccess
|
||||
})
|
||||
|
||||
shutdownSignal = make(chan bool, 1)
|
||||
shutdownSignal <- true
|
||||
// Start executing callbacks and exitFunc receives a success.
|
||||
// initialize graceful shutdown
|
||||
dummySuccess := func(code int) {
|
||||
if code != int(exitSuccess) {
|
||||
t.Fatalf("Expected %d, got %d instead.", code, exitSuccess)
|
||||
}
|
||||
}
|
||||
monitorShutdownSignal(dummySuccess)
|
||||
initGracefulShutdown(dummySuccess)
|
||||
// Register two callbacks that return success
|
||||
globalShutdownCBs.AddObjectLayerCB(func() errCode {
|
||||
return exitSuccess
|
||||
})
|
||||
globalShutdownCBs.AddGenericCB(func() errCode {
|
||||
return exitSuccess
|
||||
})
|
||||
globalShutdownSignalCh <- struct{}{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user