mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
fix(master): Set the cluster's stop channel to nil upon receiving the signal to prevent it from running again
Signed-off-by: leonrayang <chl696@sina.com>
This commit is contained in:
parent
1594864cb1
commit
39b2d22679
@ -108,6 +108,7 @@ type Cluster struct {
|
||||
MasterSecretKey []byte
|
||||
retainLogs uint64
|
||||
stopc chan bool
|
||||
stopFlag int32
|
||||
wg sync.WaitGroup
|
||||
|
||||
ClusterVolSubItem
|
||||
|
||||
@ -23,6 +23,7 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/cubefs/cubefs/proto"
|
||||
@ -190,6 +191,10 @@ func (m *Server) Start(cfg *config.Config) (err error) {
|
||||
// Shutdown closes the server
|
||||
func (m *Server) Shutdown() {
|
||||
var err error
|
||||
if !atomic.CompareAndSwapInt32(&m.cluster.stopFlag, 0, 1) {
|
||||
log.LogWarnf("action[Shutdown] cluster already stopped!")
|
||||
return
|
||||
}
|
||||
if m.cluster.stopc != nil {
|
||||
close(m.cluster.stopc)
|
||||
m.cluster.wg.Wait()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user