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) log.Error(err)
} else { } else {
s.stop.Add(1) s.stop.Add(1)
go s.handleConnection(conn) go func() {
s.stop.Done()
s.handleConnection(conn)
}()
} }
} }
} }
func (s *Server) handleConnection(conn net.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 timeoutDuration := 5 * time.Second
for { for {

View file

@ -74,13 +74,20 @@ func (s *Server) listenAndServe(listener net.Listener) {
log.Error(err) log.Error(err)
} else { } else {
s.stop.Add(1) s.stop.Add(1)
go s.handleConn(conn) go func() {
s.stop.Done()
s.handleConn(conn)
}()
} }
} }
} }
func (s *Server) handleConn(conn net.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 // TODO: connection should time out eventually
err := s.doHandshake(conn) err := s.doHandshake(conn)
if err != nil { if err != nil {