Skip to content

Commit

Permalink
shared client: Fix global timeout not being respected
Browse files Browse the repository at this point in the history
This fixes a bug where the shared client did not respect
`c.Client.Timeout`, resulting in DNS requests timing out too soon.

A per Go docs, `Client.Timeout` is supposed to also apply to the write
timeout. This is implemented in the regular client by using
`Client.getTimeoutForRequest` to determine the actual timeout. This
commit adapts the shared client code to do the same.

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
  • Loading branch information
gandro committed Apr 16, 2024
1 parent 4e6b438 commit ee3124a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion shared_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func (c *SharedClient) ExchangeSharedContext(ctx context.Context, m *Msg) (r *Ms

// This request keeps 'c.requests' open; sending a request may hang indefinitely if
// the handler happens to quit at the same time. Use ctx.Done to avoid this.
timeout := c.Client.writeTimeout()
timeout := c.getTimeoutForRequest(c.Client.writeTimeout())
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
respCh := make(chan sharedClientResponse)
Expand Down

0 comments on commit ee3124a

Please sign in to comment.