From 194dc2bf7bcbbfd5822957360ac3811542d946cc Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 24 Apr 2015 14:37:32 -0700 Subject: [PATCH 1/3] bring some errors that were being hidden in the dial sequence to the surface --- .../src/github.com/jbenet/go-reuseport/impl_unix.go | 6 ++++-- p2p/net/swarm/swarm_dial.go | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Godeps/_workspace/src/github.com/jbenet/go-reuseport/impl_unix.go b/Godeps/_workspace/src/github.com/jbenet/go-reuseport/impl_unix.go index 822de21ab..c58303f34 100644 --- a/Godeps/_workspace/src/github.com/jbenet/go-reuseport/impl_unix.go +++ b/Godeps/_workspace/src/github.com/jbenet/go-reuseport/impl_unix.go @@ -115,7 +115,9 @@ func dial(dialer net.Dialer, netw, addr string) (c net.Conn, err error) { // here we just try again 3 times. for i := 0; i < 3; i++ { if !deadline.IsZero() && deadline.Before(time.Now()) { - err = errTimeout + if err == nil { + err = errTimeout + } break } @@ -355,6 +357,6 @@ var errTimeout = &timeoutError{} type timeoutError struct{} -func (e *timeoutError) Error() string { return "i/o timeout" } +func (e *timeoutError) Error() string { return "i/o timeout (reuseport)" } func (e *timeoutError) Timeout() bool { return true } func (e *timeoutError) Temporary() bool { return true } diff --git a/p2p/net/swarm/swarm_dial.go b/p2p/net/swarm/swarm_dial.go index 51dd39cdf..a79aac8fd 100644 --- a/p2p/net/swarm/swarm_dial.go +++ b/p2p/net/swarm/swarm_dial.go @@ -237,7 +237,8 @@ func (s *Swarm) gatedDialAttempt(ctx context.Context, p peer.ID) (*Conn, error) log.Event(ctx, "swarmDialBackoffAdd", logdial) s.backf.AddBackoff(p) // let others know to backoff - return nil, ErrDialFailed // ok, we failed. try again. (if loop is done, our error is output) + // ok, we failed. try again. (if loop is done, our error is output) + return nil, fmt.Errorf("dial attempt failed: %s", err) } log.Event(ctx, "swarmDialBackoffClear", logdial) 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 for i := 0; i < len(remoteAddrs); i++ { select { case exitErr = <-errs: // - log.Debug(exitErr) + log.Warning("dial error: ", exitErr) case connC := <-conns: // take the first + return asap close(foundConn) From 6f510b322e656f99c528229bcda98b0574b06976 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 28 Apr 2015 14:48:28 -0700 Subject: [PATCH 2/3] label timeout error from reuseport/poll --- .../_workspace/src/github.com/jbenet/go-reuseport/poll/error.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Godeps/_workspace/src/github.com/jbenet/go-reuseport/poll/error.go b/Godeps/_workspace/src/github.com/jbenet/go-reuseport/poll/error.go index c13fb8132..28b26a9d2 100644 --- a/Godeps/_workspace/src/github.com/jbenet/go-reuseport/poll/error.go +++ b/Godeps/_workspace/src/github.com/jbenet/go-reuseport/poll/error.go @@ -4,6 +4,6 @@ var errTimeout = &timeoutError{} type timeoutError struct{} -func (e *timeoutError) Error() string { return "i/o timeout" } +func (e *timeoutError) Error() string { return "i/o timeout (reuseport poll)" } func (e *timeoutError) Timeout() bool { return true } func (e *timeoutError) Temporary() bool { return true } From c43b5c921d3262347b6482db381667ecef8178c1 Mon Sep 17 00:00:00 2001 From: Jeromy Johnson Date: Thu, 30 Apr 2015 13:19:56 -0700 Subject: [PATCH 3/3] Update swarm_dial.go --- p2p/net/swarm/swarm_dial.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/p2p/net/swarm/swarm_dial.go b/p2p/net/swarm/swarm_dial.go index a79aac8fd..aacee6ec4 100644 --- a/p2p/net/swarm/swarm_dial.go +++ b/p2p/net/swarm/swarm_dial.go @@ -417,7 +417,7 @@ func (s *Swarm) dialAddrs(ctx context.Context, d *conn.Dialer, p peer.ID, remote for i := 0; i < len(remoteAddrs); i++ { select { case exitErr = <-errs: // - log.Warning("dial error: ", exitErr) + log.Debug("dial error: ", exitErr) case connC := <-conns: // take the first + return asap close(foundConn)