mirror of
https://github.com/octoleo/syncthing.git
synced 2025-03-21 10:12:21 +00:00
parent
950f4a8672
commit
ff441d3b3e
@ -79,6 +79,9 @@ func (t *tcpListener) Serve() {
|
|||||||
t.mapping = mapping
|
t.mapping = mapping
|
||||||
t.mut.Unlock()
|
t.mut.Unlock()
|
||||||
|
|
||||||
|
acceptFailures := 0
|
||||||
|
const maxAcceptFailures = 10
|
||||||
|
|
||||||
for {
|
for {
|
||||||
listener.SetDeadline(time.Now().Add(time.Second))
|
listener.SetDeadline(time.Now().Add(time.Second))
|
||||||
conn, err := listener.Accept()
|
conn, err := listener.Accept()
|
||||||
@ -96,10 +99,21 @@ func (t *tcpListener) Serve() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if err, ok := err.(*net.OpError); !ok || !err.Timeout() {
|
if err, ok := err.(*net.OpError); !ok || !err.Timeout() {
|
||||||
l.Warnln("Listen (BEP/tcp): Accepting connection:", err)
|
l.Warnln("Listen (BEP/tcp): Accepting connection:", err)
|
||||||
|
|
||||||
|
acceptFailures++
|
||||||
|
if acceptFailures > maxAcceptFailures {
|
||||||
|
// Return to restart the listener, because something
|
||||||
|
// seems permanently damaged.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slightly increased delay for each failure.
|
||||||
|
time.Sleep(time.Duration(acceptFailures) * time.Second)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
acceptFailures = 0
|
||||||
l.Debugln("Listen (BEP/tcp): connect from", conn.RemoteAddr())
|
l.Debugln("Listen (BEP/tcp): connect from", conn.RemoteAddr())
|
||||||
|
|
||||||
if err := dialer.SetTCPOptions(conn); err != nil {
|
if err := dialer.SetTCPOptions(conn); err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user