Skip to content

Commit

Permalink
propagate the caller's context to the dial function (segmentio#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
Achille authored Jun 13, 2020
1 parent 2fc5681 commit b0b1cdc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ func (g *connGroup) grabConnOrConnect(ctx context.Context) (*conn, error) {
errChan := make(chan error)

go func() {
c, err := g.connect()
c, err := g.connect(ctx)
if err != nil {
select {
case errChan <- err:
Expand Down Expand Up @@ -991,10 +991,10 @@ func (g *connGroup) releaseConn(c *conn) bool {
return true
}

func (g *connGroup) connect() (*conn, error) {
func (g *connGroup) connect(ctx context.Context) (*conn, error) {
deadline := time.Now().Add(g.pool.dialTimeout)

ctx, cancel := context.WithDeadline(context.Background(), deadline)
ctx, cancel := context.WithDeadline(ctx, deadline)
defer cancel()

netConn, err := g.pool.dial(ctx, g.network, g.address)
Expand Down

0 comments on commit b0b1cdc

Please sign in to comment.