Explorar o código

etcdserver: move the mutex before what it guards

Xiang Li %!s(int64=11) %!d(string=hai) anos
pai
achega
04bd06d20b
Modificáronse 1 ficheiros con 6 adicións e 5 borrados
  1. 6 5
      etcdserver/cluster.go

+ 6 - 5
etcdserver/cluster.go

@@ -56,14 +56,15 @@ type ClusterInfo interface {
 
 // Cluster is a list of Members that belong to the same raft cluster
 type Cluster struct {
-	id      types.ID
-	token   string
-	members map[types.ID]*Member
+	id    types.ID
+	token string
+	store store.Store
+
+	sync.Mutex // guards members and removed map
+	members    map[types.ID]*Member
 	// removed contains the ids of removed members in the cluster.
 	// removed id cannot be reused.
 	removed map[types.ID]bool
-	store   store.Store
-	sync.Mutex
 }
 
 // NewClusterFromString returns a Cluster instantiated from the given cluster token