Skip to content

Commit 3199161

Browse files
authored
cmd/strelaysrv: Handle accept error with debug set (fixes syncthing#9001) (syncthing#9004)
1 parent b08b99e commit 3199161

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cmd/strelaysrv/listener.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,14 @@ func listener(_, addr string, config *tls.Config, token string) {
3636
for {
3737
conn, isTLS, err := listener.AcceptNoWrapTLS()
3838
if err != nil {
39+
// Conn may be nil if accept failed, or non-nil if the initial
40+
// read to figure out if it's TLS or not failed. In the latter
41+
// case, close the connection before moving on.
42+
if conn != nil {
43+
conn.Close()
44+
}
3945
if debug {
40-
log.Println("Listener failed to accept connection from", conn.RemoteAddr(), ". Possibly a TCP Ping.")
46+
log.Println("Listener failed to accept:", err)
4147
}
4248
continue
4349
}

0 commit comments

Comments
 (0)