diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2022-06-02 14:10:44 +0100 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2022-06-02 14:10:44 +0100 |
| commit | c949ffafd1cbe823f66654af6f04026edb44bf86 (patch) | |
| tree | d2698a0bd3cd89416c26cb025f8fdefd14730073 /pipeln.go | |
| parent | fb8af574c03fd5099dac49cdf6dec8b83df36c48 (diff) | |
Have DialContext return upon context cancellationv1.0.1
Diffstat (limited to 'pipeln.go')
| -rw-r--r-- | pipeln.go | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -47,6 +47,11 @@ func (ln *PipeListenerDialer) Close() error { // See net.Dialer.Dial for more details. func (ln *PipeListenerDialer) Dial(_, addr string) (net.Conn, error) { + return ln.DialContext(context.Background(), "", addr) +} + +// DialContext is a dummy wrapper around Dial. +func (ln *PipeListenerDialer) DialContext(ctx context.Context, _, addr string) (net.Conn, error) { if addr != ln.addr { return nil, unix.EINVAL } @@ -56,19 +61,16 @@ func (ln *PipeListenerDialer) Dial(_, addr string) (net.Conn, error) { return c, nil case <-ln.done: return nil, unix.ECONNREFUSED + case <-ctx.Done(): + return nil, ctx.Err() } } -// DialContext is a dummy wrapper around Dial. -func (ln *PipeListenerDialer) DialContext(_ context.Context, network, addr string) (net.Conn, error) { - return ln.Dial(network, addr) -} - // DialContextAddr is a dummy wrapper around Dial. // // This function can be passed to grpc.WithContextDialer. -func (ln *PipeListenerDialer) DialContextAddr(_ context.Context, addr string) (net.Conn, error) { - return ln.Dial("", addr) +func (ln *PipeListenerDialer) DialContextAddr(ctx context.Context, addr string) (net.Conn, error) { + return ln.DialContext(ctx, "", addr) } // New returns a PipeListenerDialer that will only accept connections |
