From 06306ad66f1ac64277870d358ca74e190a6290eb Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Mon, 9 Dec 2013 14:20:56 -0800 Subject: [PATCH] consul: close raft transport before layer --- consul/server.go | 11 +++++++---- consul/server_test.go | 1 - 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/consul/server.go b/consul/server.go index adf361db59..d865fff124 100644 --- a/consul/server.go +++ b/consul/server.go @@ -44,9 +44,10 @@ type Server struct { // The raft instance is used among Consul nodes within the // DC to protect operations that require strong consistency - raft *raft.Raft - raftLayer *RaftLayer - raftStore *raft.SQLiteStore + 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 diff --git a/consul/server_test.go b/consul/server_test.go index 4d13d73518..240d9550b6 100644 --- a/consul/server_test.go +++ b/consul/server_test.go @@ -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") }