Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commit 955eb8a ("channelz: cleanup channel registration if Dial fails (grpc#2733)") moved a defer block earlier in DialContext() to ensure that cc.Close() was always called. This defer block also checks whether the ctx.Done() is true, and if so ensures the context error is returned. If the dial options include a timeout, the original context gets replaced with a new context that has the timeout, and this gets a catchall `defer cancel()` to go with it. However, this cancel() now gets called before the cleanup defer block, so when the latter runs the context is always already cancelled. Fix by splitting the larger defer block into two parts: - The part that does cc.Close() stays near the beginning of the method. - The part that checks ctx.Done() returns to below the `defer cancel()` call, and so gets invoked before it.
- Loading branch information