diff --git a/connection_test.go b/connection_test.go index 65d761f4..6bfb55f8 100644 --- a/connection_test.go +++ b/connection_test.go @@ -767,7 +767,7 @@ func TestConnectionDailTimeoutAndClose(t *testing.T) { go func() { defer wg.Done() conn, err := DialConnection("tcp", address, time.Nanosecond) - Assert(t, err == nil || strings.Contains(err.Error(), "i/o timeout")) + Assert(t, err == nil || strings.Contains(err.Error(), "i/o timeout"), err) _ = conn }() } diff --git a/net_polldesc.go b/net_polldesc.go index 89becc90..72a43625 100644 --- a/net_polldesc.go +++ b/net_polldesc.go @@ -56,18 +56,18 @@ func (pd *pollDesc) WaitWrite(ctx context.Context) (err error) { // no need to detach, since poller has done it in OnHup. return Exception(ErrConnClosed, "by peer") case <-pd.writeTrigger: // triggered by poller - err = nil + return nil case <-ctx.Done(): // triggered by ctx // deregister from poller, upper caller function will close fd pd.detach() - err = mapErr(ctx.Err()) + return mapErr(ctx.Err()) } // double check close trigger select { case <-pd.closeTrigger: return Exception(ErrConnClosed, "by peer") default: - return err + return nil } }