upstream: use context to set connectToUpstream timeout
This allows the timeout to apply to the whole sequence of operations, as opposed to just Dial.
This commit is contained in:
parent
b790db1423
commit
2ba13fdefc
@ -150,7 +150,10 @@ type upstreamConn struct {
|
|||||||
func connectToUpstream(ctx context.Context, network *network) (*upstreamConn, error) {
|
func connectToUpstream(ctx context.Context, network *network) (*upstreamConn, error) {
|
||||||
logger := &prefixLogger{network.user.logger, fmt.Sprintf("upstream %q: ", network.GetName())}
|
logger := &prefixLogger{network.user.logger, fmt.Sprintf("upstream %q: ", network.GetName())}
|
||||||
|
|
||||||
dialer := net.Dialer{Timeout: connectTimeout}
|
ctx, cancel := context.WithTimeout(ctx, connectTimeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
var dialer net.Dialer
|
||||||
|
|
||||||
u, err := network.URL()
|
u, err := network.URL()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user