bring some errors that were being hidden in the dial sequence to the surface
Jeromy committed
Apr 24, 2015 at 14:37 UTC
194dc2bf7bcbbfd5822957360ac3811542d946cc
2 files changed
+7
-4
Godeps/_workspace/src/github.com/jbenet/go-reuseport/impl_unix.go
+4
-2
@@ -115,7 +115,9 @@ func dial(dialer net.Dialer, netw, addr string) (c net.Conn, err error) {
115
// here we just try again 3 times.
116
for i := 0; i < 3; i++ {
117
if !deadline.IsZero() && deadline.Before(time.Now()) {
118
- err = errTimeout
118
+ if err == nil {
119
+ err = errTimeout
120
+ }
121
break
122
}
123
@@ -355,6 +357,6 @@ var errTimeout = &timeoutError{}
357
358
type timeoutError struct{}
359
358
-func (e *timeoutError) Error() string { return "i/o timeout" }
360
+func (e *timeoutError) Error() string { return "i/o timeout (reuseport)" }
361
func (e *timeoutError) Timeout() bool { return true }
362
func (e *timeoutError) Temporary() bool { return true }
p2p/net/swarm/swarm_dial.go
+3
-2
@@ -237,7 +237,8 @@ func (s *Swarm) gatedDialAttempt(ctx context.Context, p peer.ID) (*Conn, error)
237
log.Event(ctx, "swarmDialBackoffAdd", logdial)
238
s.backf.AddBackoff(p) // let others know to backoff
239
240
- return nil, ErrDialFailed // ok, we failed. try again. (if loop is done, our error is output)
240
+ // ok, we failed. try again. (if loop is done, our error is output)
241
+ return nil, fmt.Errorf("dial attempt failed: %s", err)
242
}
243
log.Event(ctx, "swarmDialBackoffClear", logdial)
244
s.backf.Clear(p) // okay, no longer need to backoff
@@ -416,7 +417,7 @@ func (s *Swarm) dialAddrs(ctx context.Context, d *conn.Dialer, p peer.ID, remote
417
for i := 0; i < len(remoteAddrs); i++ {
418
select {
419
case exitErr = <-errs: //
419
- log.Debug(exitErr)
420
+ log.Warning("dial error: ", exitErr)
421
case connC := <-conns:
422
// take the first + return asap
423
close(foundConn)