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

client/comms: expire requests on connection shutdown #1915

Merged
merged 1 commit into from Oct 27, 2022

Conversation

chappjc
Copy link
Member

@chappjc chappjc commented Oct 20, 2022

This avoids hangs on shutdown with comms requests that would be waiting to timeout.

Since the connection dropping does not abort requests (and should not since there is a reconnect loop), we must call the expire func when the wsConn is explicitly shutdown, otherwise users of Request and RequestWithTimeout may hang until the request timeout is reached, depending on the use pattern.

For example, with this pattern used throughout the client, it would hang at <-errChan until timeout even if the conn were explicitly shutdown after sending the request:

errChan := make(chan error, 1)
err = conn.RequestWithTimeout(reqMsg, func(msg *msgjson.Message) {
	errChan <- msg.UnmarshalResult(response)
}, timeout, func() {
	errChan <- fmt.Errorf("timed out waiting for %q response", route)
})
// Check the request error.
if err != nil {
	return err
}
// Check the response error.
return <-errChan

@chappjc chappjc merged commit e4bdbf0 into decred:master Oct 27, 2022
@chappjc chappjc deleted the client-comms-expire-req-on-shutdown branch October 27, 2022 12:55
@chappjc chappjc added this to the 0.6 milestone Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants