refine error handling in retry logic

This commit is contained in:
Darien Raymond committed 2017-02-10 11:41:50 +01:00
1 parent 51745e772c
commit 5e7fb6d0dd
10 files changed
+33 -35

No files matched your search

+2 -6
View File
@@ -5,7 +5,6 @@ import (
"sync"
"v2ray.com/core/common/errors"
"v2ray.com/core/app/log"
v2net "v2ray.com/core/common/net"
"v2ray.com/core/common/retry"
)
@@ -73,16 +72,13 @@ func (v *TCPHub) start() {
v.accepting = true
for v.accepting {
var newConn Connection
err := retry.ExponentialBackoff(10, 200).On(func() error {
err := retry.ExponentialBackoff(10, 500).On(func() error {
if !v.accepting {
return nil
}
conn, err := v.listener.Accept()
if err != nil {
if v.accepting {
log.Warning("Internet|Listener: Failed to accept new TCP connection: ", err)
}
return err
return errors.Base(err).Message("Internet|Listener: Failed to accept new TCP connection.")
}
newConn = conn
return nil
+4 -4
View File
@@ -2,12 +2,12 @@ package websocket
import (
"context"
"io/ioutil"
"net"
"github.com/gorilla/websocket"
"v2ray.com/core/app/log"
"v2ray.com/core/common"
"v2ray.com/core/common/errors"
v2net "v2ray.com/core/common/net"
"v2ray.com/core/transport/internet"
"v2ray.com/core/transport/internet/internal"
@@ -78,11 +78,11 @@ func wsDial(ctx context.Context, dest v2net.Destination) (net.Conn, error) {
conn, resp, err := dialer.Dial(uri, nil)
if err != nil {
var reason string
if resp != nil {
reason, reasonerr := ioutil.ReadAll(resp.Body)
log.Info(string(reason), reasonerr)
reason = resp.Status
}
return nil, err
return nil, errors.Base(err).Format("WebSocket|Dialer: Failed to dial to (", uri, "): ", reason)
}
return &wsconn{