Get rid of Server.downstreamConns

This is unused right now. Let's remove it, we'll add it back if we
really need it.
This commit is contained in:
Simon Ser 2020-03-27 22:24:12 +01:00
parent 8c56e610ff
commit 551d41335e
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -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()
}()
}
}