Skip to content

Commit

Permalink
slow down when there is not enough file descriptors. fixes #1574
Browse files Browse the repository at this point in the history
  • Loading branch information
DarienRaymond committed Feb 25, 2019
1 parent 95583b5 commit d5de8e2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion transport/internet/tcp/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
gotls "crypto/tls"
"strings"
"time"

"v2ray.com/core/common"
"v2ray.com/core/common/net"
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit d5de8e2

Please sign in to comment.