Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
async: ensure connection close error is set (#180)
The previous implementation had a couple of issues that could cause closeWithError() to not propagate the passed error properly. 1. c.error.Store() is only called after c.close(), which could cause the channel returned by CloseChannel() to be closed before the error is set. Callers that that block on the channel may attempt to read the error before it is set. 2. If c.close() fails, closeError is returned, but not set to c.error.Store(), causing callers to miss it. Additionally, the original error is ignored and not made available to callers at all. To fix these issues, closeWithError() is updated to set c.error before calling c.close() and all errors are returned and set to c.error by using errors.Join(). In order to support different kinds of concrete error types, the type of the error field had to be changed from atomic.Value to error. Signed-off-by: Luiz Aoqui <[email protected]>
- Loading branch information