forked from TrueCloudLab/frostfs-node
[#922] shard: Allow multiple gc.stop() calls
Use `sync.Once` to prevent locks of stopping GC. It will also allow to safely call `Shard.Close` multiple times. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
10f0bd91d6
commit
d6457ee485
1 changed files with 4 additions and 1 deletions
|
@ -52,6 +52,7 @@ type eventHandlers struct {
|
|||
type gc struct {
|
||||
*gcCfg
|
||||
|
||||
onceStop sync.Once
|
||||
stopChannel chan struct{}
|
||||
|
||||
workerPool util.WorkerPool
|
||||
|
@ -163,7 +164,9 @@ func (gc *gc) tickRemover() {
|
|||
}
|
||||
|
||||
func (gc *gc) stop() {
|
||||
gc.onceStop.Do(func() {
|
||||
gc.stopChannel <- struct{}{}
|
||||
})
|
||||
}
|
||||
|
||||
// iterates over metabase graveyard and deletes objects
|
||||
|
|
Loading…
Reference in a new issue