File tree Expand file tree Collapse file tree 1 file changed +2
-3
lines changed
Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change @@ -401,7 +401,8 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
401401 // Another goroutine is initializing - WAIT for it to complete
402402 // Use a context with timeout = min(remaining command timeout, DialTimeout)
403403 // This prevents waiting too long while respecting the caller's deadline
404- waitCtx := ctx
404+ var waitCtx context.Context
405+ var cancel context.CancelFunc
405406 dialTimeout := c .opt .DialTimeout
406407
407408 if cmdDeadline , hasCmdDeadline := ctx .Deadline (); hasCmdDeadline {
@@ -413,13 +414,11 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
413414 waitCtx = ctx
414415 } else {
415416 // DialTimeout is shorter, cap the wait at DialTimeout
416- var cancel context.CancelFunc
417417 waitCtx , cancel = context .WithTimeout (ctx , dialTimeout )
418418 defer cancel ()
419419 }
420420 } else {
421421 // No command deadline, use DialTimeout to prevent waiting indefinitely
422- var cancel context.CancelFunc
423422 waitCtx , cancel = context .WithTimeout (ctx , dialTimeout )
424423 defer cancel ()
425424 }
You can’t perform that action at this time.
0 commit comments