From 03a98ed1d781f42f48a2385a473acaefaa1704b3 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Wed, 14 May 2014 17:34:24 -0700 Subject: [PATCH] consul: Remove RPC client tracking. Fixes #149. --- consul/rpc.go | 13 +------------ consul/server.go | 12 ------------ 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/consul/rpc.go b/consul/rpc.go index 23617bc390..fd2ebae1d1 100644 --- a/consul/rpc.go +++ b/consul/rpc.go @@ -51,11 +51,6 @@ func (s *Server) listen() { continue } - // Track this client - s.rpcClientLock.Lock() - s.rpcClients[conn] = struct{}{} - s.rpcClientLock.Unlock() - go s.handleConn(conn, false) metrics.IncrCounter([]string{"consul", "rpc", "accept_conn"}, 1) } @@ -125,13 +120,7 @@ func (s *Server) handleMultiplex(conn net.Conn) { // handleConsulConn is used to service a single Consul RPC connection func (s *Server) handleConsulConn(conn net.Conn) { - defer func() { - conn.Close() - s.rpcClientLock.Lock() - delete(s.rpcClients, conn) - s.rpcClientLock.Unlock() - }() - + defer conn.Close() rpcCodec := codec.GoRpc.ServerCodec(conn, &codec.MsgpackHandle{}) for !s.shutdown { if err := s.rpcServer.ServeRequest(rpcCodec); err != nil { diff --git a/consul/server.go b/consul/server.go index 291461b709..32c38f7d4a 100644 --- a/consul/server.go +++ b/consul/server.go @@ -81,10 +81,6 @@ type Server struct { remoteConsuls map[string][]net.Addr remoteLock sync.RWMutex - // rpcClients is used to track active clients - rpcClients map[net.Conn]struct{} - rpcClientLock sync.Mutex - // rpcListener is used to listen for incoming connections rpcListener net.Listener rpcServer *rpc.Server @@ -160,7 +156,6 @@ func NewServer(config *Config) (*Server, error) { logger: logger, reconcileCh: make(chan serf.Member, 32), remoteConsuls: make(map[string][]net.Addr), - rpcClients: make(map[net.Conn]struct{}), rpcServer: rpc.NewServer(), rpcTLS: incomingTLS, shutdownCh: make(chan struct{}), @@ -392,13 +387,6 @@ func (s *Server) Shutdown() error { s.rpcListener.Close() } - // Close all the RPC connections - s.rpcClientLock.Lock() - for conn := range s.rpcClients { - conn.Close() - } - s.rpcClientLock.Unlock() - // Close the connection pool s.connPool.Shutdown()