mirror of https://github.com/status-im/consul.git
consul: close raft transport before layer
This commit is contained in:
parent
e780255dd4
commit
06306ad66f
|
@ -44,9 +44,10 @@ type Server struct {
|
||||||
|
|
||||||
// The raft instance is used among Consul nodes within the
|
// The raft instance is used among Consul nodes within the
|
||||||
// DC to protect operations that require strong consistency
|
// DC to protect operations that require strong consistency
|
||||||
raft *raft.Raft
|
raft *raft.Raft
|
||||||
raftLayer *RaftLayer
|
raftLayer *RaftLayer
|
||||||
raftStore *raft.SQLiteStore
|
raftStore *raft.SQLiteStore
|
||||||
|
raftTransport *raft.NetworkTransport
|
||||||
|
|
||||||
// rpcClients is used to track active clients
|
// rpcClients is used to track active clients
|
||||||
rpcClients map[net.Conn]struct{}
|
rpcClients map[net.Conn]struct{}
|
||||||
|
@ -179,6 +180,7 @@ func (s *Server) setupRaft() error {
|
||||||
|
|
||||||
// Create a transport layer
|
// Create a transport layer
|
||||||
trans := raft.NewNetworkTransport(s.raftLayer, 3, 10*time.Second)
|
trans := raft.NewNetworkTransport(s.raftLayer, 3, 10*time.Second)
|
||||||
|
s.raftTransport = trans
|
||||||
|
|
||||||
// Setup the peer store
|
// Setup the peer store
|
||||||
peers := raft.NewJSONPeers(path, trans)
|
peers := raft.NewJSONPeers(path, trans)
|
||||||
|
@ -233,8 +235,9 @@ func (s *Server) Shutdown() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.raft != nil {
|
if s.raft != nil {
|
||||||
s.raft.Shutdown()
|
s.raftTransport.Close()
|
||||||
s.raftLayer.Close()
|
s.raftLayer.Close()
|
||||||
|
s.raft.Shutdown()
|
||||||
s.raftStore.Close()
|
s.raftStore.Close()
|
||||||
s.raft = nil
|
s.raft = nil
|
||||||
s.raftLayer = nil
|
s.raftLayer = nil
|
||||||
|
|
|
@ -99,5 +99,4 @@ func TestServer_JoinWAN(t *testing.T) {
|
||||||
if err := s2.JoinWAN(addr); err != nil {
|
if err := s2.JoinWAN(addr); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
t.Fatalf("fail")
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue