put back connection closing.

This commit is contained in:
Mark Beamer Jr 2018-06-13 20:21:47 -04:00
parent 317a7d961a
commit 6ff219420b
2 changed files with 18 additions and 4 deletions

View file

@ -84,13 +84,20 @@ func (s *Server) listenAndServe(listener net.Listener) {
log.Error(err)
} else {
s.stop.Add(1)
go s.handleConnection(conn)
go func() {
s.stop.Done()
s.handleConnection(conn)
}()
}
}
}
func (s *Server) handleConnection(conn net.Conn) {
defer s.stop.Done()
defer func() {
if err := conn.Close(); err != nil {
log.Error("error closing client connection for peer server - ", err)
}
}()
timeoutDuration := 5 * time.Second
for {

View file

@ -74,13 +74,20 @@ func (s *Server) listenAndServe(listener net.Listener) {
log.Error(err)
} else {
s.stop.Add(1)
go s.handleConn(conn)
go func() {
s.stop.Done()
s.handleConn(conn)
}()
}
}
}
func (s *Server) handleConn(conn net.Conn) {
defer s.stop.Done()
defer func() {
if err := conn.Close(); err != nil {
log.Error("error closing client connection for reflector server - ", err)
}
}()
// TODO: connection should time out eventually
err := s.doHandshake(conn)
if err != nil {