Skip to content

Commit

Permalink
shared client: add fail-safe mechanism for stuck requests.
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Zieba <marcel.zieba@isovalent.com>
  • Loading branch information
marseel authored and aanm committed Apr 11, 2024
1 parent 564189d commit 4e6b438
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions shared_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,13 @@ func (c *SharedClient) ExchangeSharedContext(ctx context.Context, m *Msg) (r *Ms
}

// Since c.requests is unbuffered, the handler is guaranteed to eventually close 'respCh'
resp := <-respCh
return resp.msg, resp.rtt, resp.err
select {
case resp := <-respCh:
return resp.msg, resp.rtt, resp.err
// This is just fail-safe mechanism in case there is another similar issue
case <-time.After(time.Minute):
return nil, 0, fmt.Errorf("timeout waiting for response")
}
}

// close closes and waits for the close to finish.
Expand Down

0 comments on commit 4e6b438

Please sign in to comment.