From 2336eb2530e1f6df6817f309e0ea2a4102056967 Mon Sep 17 00:00:00 2001 From: GrĂ©goire DuchĂȘne Date: Sun, 27 Nov 2022 16:18:08 +0000 Subject: Revert "Close pipe if PipeListener.DialContext errors out" This reverts commit 2bfa4630c7223ee11ec29b91107333758e7f2a8e. It basically is not necessary to close the underlying channel. --- net.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'net.go') diff --git a/net.go b/net.go index aa1ccc3..040fe66 100644 --- a/net.go +++ b/net.go @@ -63,19 +63,16 @@ func (p *PipeListener) Dial(_, _ string) (net.Conn, error) { return p.DialContext(context.Background(), "", "") } -func (p *PipeListener) DialContext(ctx context.Context, _, _ string) (_ net.Conn, err error) { +func (p *PipeListener) DialContext(ctx context.Context, _, _ string) (net.Conn, error) { s, c := net.Pipe() select { case p.conns <- s: return c, nil case <-p.done: - err = syscall.ECONNREFUSED + return nil, syscall.ECONNREFUSED case <-ctx.Done(): - err = ctx.Err() + return nil, ctx.Err() } - s.Close() - c.Close() - return } func (p *PipeListener) DialContextGRPC(ctx context.Context, _ string) (net.Conn, error) { -- cgit v1.2.3-70-g09d2