Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: Increase client timeout #8

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ func (c *ClientRaw) Close() error {
if c == nil {
return nil
}
defer close(c.Messages)

c.sendMu.Lock()
defer c.sendMu.Unlock()
Expand All @@ -241,6 +240,8 @@ func (c *ClientRaw) Close() error {

err := c.conn.Close()

close(c.Messages)

return err
}

Expand Down Expand Up @@ -316,16 +317,17 @@ func (c *ClientRaw) input() {
break
}

c.mu.Lock()
id := message.Header.ID
if id == 0 {
// A message with ID 0 is a standalone message (e.g. log message)
// and not part of the request-response flow.
c.Messages <- message
c.mu.Unlock()
continue
}

// Attach it to the correct pending call.
c.mu.Lock()
call, found := c.pending[id]
if !found {
panic(fmt.Sprintf("call with ID %d not found", id))
Expand All @@ -337,12 +339,13 @@ func (c *ClientRaw) input() {
}

delete(c.pending, id)
c.mu.Unlock()
if call == nil {
err = fmt.Errorf("call with ID %d not found", id)
c.mu.Unlock()
break
}
call.Messages <- message
c.mu.Unlock()
call.done()
}

Expand Down
Loading