1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-25 17:05:23 +00:00

slow down when there is not enough file descriptors. fixes #1574

This commit is contained in:
Darien Raymond 2019-02-25 10:22:04 +01:00
parent 95583b5031
commit d5de8e27cc
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -6,6 +6,7 @@ import (
"context"
gotls "crypto/tls"
"strings"
"time"
"v2ray.com/core/common"
"v2ray.com/core/common/net"
@ -64,10 +65,14 @@ func (v *Listener) keepAccepting() {
for {
conn, err := v.listener.Accept()
if err != nil {
if strings.Contains(err.Error(), "closed") {
errStr := err.Error()
if strings.Contains(errStr, "closed") {
break
}
newError("failed to accepted raw connections").Base(err).AtWarning().WriteToLog()
if strings.Contains(errStr, "too many") {
time.Sleep(time.Millisecond * 500)
}
continue
}