MCPcopy
hub / github.com/golang/net / dialContext

Function dialContext

proxy/dial.go:35–54  ·  view source on GitHub ↗

WARNING: this can leak a goroutine for as long as the underlying Dialer implementation takes to timeout A Conn returned from a successful Dial after the context has been cancelled will be immediately closed.

(ctx context.Context, d Dialer, network, address string)

Source from the content-addressed store, hash-verified

33// WARNING: this can leak a goroutine for as long as the underlying Dialer implementation takes to timeout
34// A Conn returned from a successful Dial after the context has been cancelled will be immediately closed.
35func dialContext(ctx context.Context, d Dialer, network, address string) (net.Conn, error) {
36 var (
37 conn net.Conn
38 done = make(chan struct{}, 1)
39 err error
40 )
41 go func() {
42 conn, err = d.Dial(network, address)
43 close(done)
44 if conn != nil && ctx.Err() != nil {
45 conn.Close()
46 }
47 }()
48 select {
49 case <-ctx.Done():
50 err = ctx.Err()
51 case <-done:
52 }
53 return conn, err
54}

Callers 3

DialFunction · 0.85
DialContextMethod · 0.85
SOCKS5Function · 0.85

Calls 4

DoneMethod · 0.80
DialMethod · 0.65
CloseMethod · 0.65
ErrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…