If Accept() fails due to a closing listener, return
Other types of Accept() failures should result in a retry.pull/2333/head
parent
4a1df4c45a
commit
0b1fc43f88
|
@ -52,9 +52,13 @@ func (t *TCPServer) ListenAndServe(iface string) error {
|
|||
defer t.wg.Done()
|
||||
for {
|
||||
conn, err := ln.Accept()
|
||||
if opErr, ok := err.(*net.OpError); ok && !opErr.Temporary() {
|
||||
t.Logger.Println("graphite TCP listener closed")
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
t.Logger.Println("error accepting TCP connection", err.Error())
|
||||
return
|
||||
continue
|
||||
}
|
||||
|
||||
t.wg.Add(1)
|
||||
|
|
|
@ -73,9 +73,13 @@ func (s *Server) ListenAndServe(listenAddress string) {
|
|||
defer s.wg.Done()
|
||||
for {
|
||||
conn, err := s.listener.Accept()
|
||||
if opErr, ok := err.(*net.OpError); ok && !opErr.Temporary() {
|
||||
log.Println("openTSDB TCP listener closed")
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
log.Println("error accepting openTSDB: ", err.Error())
|
||||
return
|
||||
continue
|
||||
}
|
||||
s.wg.Add(1)
|
||||
go s.HandleConnection(conn)
|
||||
|
|
Loading…
Reference in New Issue