Skip to content

Commit

Permalink
shared client: Make responses channel buffered
Browse files Browse the repository at this point in the history
Responses channel must be buffered to remove a deadlock scenario when we
exit and the receive loop needs to send a response right after we have
completed draining.

Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
  • Loading branch information
jrajahalme committed Nov 20, 2023
1 parent 496cd01 commit b0b6f18
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion shared_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ func (c *SharedClient) ExchangeShared(m *Msg) (r *Msg, rtt time.Duration, err er
func handler(wg *sync.WaitGroup, client *Client, conn *Conn, requests chan request) {
defer wg.Done()

responses := make(chan sharedClientResponse)
// Responses channel must be buffered to remove a deadlock scenario when we exit and the
// receive loop needs to send a response right after we have completed draining.
responses := make(chan sharedClientResponse, 1)

// receiverTrigger is used to wake up the receive loop after request(s) have been sent. It
// must be buffered to be able to send a trigger while the receive loop is not yet ready to
Expand Down

0 comments on commit b0b6f18

Please sign in to comment.