From 551d41335e74e9c3e5c3427e67e78406472478a6 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 27 Mar 2020 22:24:12 +0100 Subject: [PATCH] Get rid of Server.downstreamConns This is unused right now. Let's remove it, we'll add it back if we really need it. --- server.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/server.go b/server.go index 5326b47..6a7c502 100644 --- a/server.go +++ b/server.go @@ -55,9 +55,8 @@ type Server struct { db *DB - lock sync.Mutex - users map[string]*user - downstreamConns []*downstreamConn + lock sync.Mutex + users map[string]*user } func NewServer(db *DB) *Server { @@ -112,10 +111,6 @@ func (s *Server) Serve(ln net.Listener) error { dc := newDownstreamConn(s, netConn, nextDownstreamID) nextDownstreamID++ go func() { - s.lock.Lock() - s.downstreamConns = append(s.downstreamConns, dc) - s.lock.Unlock() - if err := dc.runUntilRegistered(); err != nil { dc.logger.Print(err) } else { @@ -126,15 +121,6 @@ func (s *Server) Serve(ln net.Listener) error { dc.user.events <- eventDownstreamDisconnected{dc} } dc.Close() - - s.lock.Lock() - for i := range s.downstreamConns { - if s.downstreamConns[i] == dc { - s.downstreamConns = append(s.downstreamConns[:i], s.downstreamConns[i+1:]...) - break - } - } - s.lock.Unlock() }() } }