consul: close raft transport before layer

This commit is contained in:
Armon Dadgar 2013-12-09 14:20:56 -08:00
parent 7f4adceae8
commit a5d001034e
2 changed files with 7 additions and 5 deletions

View File

@ -47,6 +47,7 @@ type Server struct {
raft *raft.Raft
raftLayer *RaftLayer
raftStore *raft.SQLiteStore
raftTransport *raft.NetworkTransport
// rpcClients is used to track active clients
rpcClients map[net.Conn]struct{}
@ -179,6 +180,7 @@ func (s *Server) setupRaft() error {
// Create a transport layer
trans := raft.NewNetworkTransport(s.raftLayer, 3, 10*time.Second)
s.raftTransport = trans
// Setup the peer store
peers := raft.NewJSONPeers(path, trans)
@ -233,8 +235,9 @@ func (s *Server) Shutdown() error {
}
if s.raft != nil {
s.raft.Shutdown()
s.raftTransport.Close()
s.raftLayer.Close()
s.raft.Shutdown()
s.raftStore.Close()
s.raft = nil
s.raftLayer = nil

View File

@ -99,5 +99,4 @@ func TestServer_JoinWAN(t *testing.T) {
if err := s2.JoinWAN(addr); err != nil {
t.Fatalf("err: %v", err)
}
t.Fatalf("fail")
}