One less goroutine for TCP listener
@@ -167,6 +167,8 @@ func (a *Agent) createListenSockets() error {
}
go func() {
+ defer tcpListen.Close()
+
for {
conn, err := tcpListen.Accept()
select {
@@ -175,7 +177,6 @@ func (a *Agent) createListenSockets() error {
default:
if err != nil {
logger.Error(err)
- tcpListen.Close()
return
}
go a.handleTCPMessages(conn)
@@ -183,12 +184,6 @@ func (a *Agent) createListenSockets() error {
}
}()
- go func() {
- <-a.stopping
- logger.Debug("TCP listener stopped")
- tcpListen.Close()
- }()
-
return err
}
