Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: docs for Dial and DialContext should indicate concurrency properties #25019

Closed
jsha opened this issue Apr 23, 2018 · 2 comments
Closed
Labels
Documentation FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@jsha
Copy link

jsha commented Apr 23, 2018

In Go 1.10.1, a user of the net/http package can specify a custom RoundTripper. That RoundTripper can define a custom Dial and/or DialContext. When running Client.Do, the Dial or DialContext function is run on a separate goroutine. If the function has side effects (for instance, recording its results in a shared slice), this can cause race conditions. For a real-world example, see letsencrypt/boulder#3109.

I think the documentation should be updated to mention that Dial and DialContext may be run concurrently with the function calling Client.Do. Here's the current documenation:

https://godoc.org/net/http#Transport

// DialContext specifies the dial function for creating unencrypted TCP connections.
// If DialContext is nil (and the deprecated Dial below is also nil),
// then the transport dials using package net.
DialContext func(ctx context.Context, network, addr string) (net.Conn, error)

// Dial specifies the dial function for creating unencrypted TCP connections.
//
// Deprecated: Use DialContext instead, which allows the transport
// to cancel dials as soon as they are no longer needed.
// If both are set, DialContext takes priority.
Dial func(network, addr string) (net.Conn, error)

Thanks!

@ianlancetaylor
Copy link
Contributor

CC @bradfitz @tombergan

@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone Apr 23, 2018
@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 23, 2018
@gopherbot
Copy link

Change https://golang.org/cl/116375 mentions this issue: net/http: document Transport.Dial concurrency

@bradfitz bradfitz self-assigned this Jun 5, 2018
@golang golang locked and limited conversation to collaborators Jun 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants