-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix stuck call to Dial when calling Stop on the initiator
This commit fixes an issue when calling Start() and then Stop() on the initiator while the connection is likely to fail and timeout. Calling initiator.Stop() will block since Dial will attempt to connect until it times out and returns on the 'waitForReconnectInterval' call. We mitigate this problem by using a proxy.ContextDialer and allowing to pass a context with cancellation method to the dialer.DialContext method on 'handleConnection'. We need to start a routine listening for the stopChan in order to call cancel() explicitly and thus exit the DialContext method. Note: there are scenarios where cancel() will be called twice, this choice was made in order to avoid a larger refactor of the reconnect logic, but since the call to cancel() is idempotent, this doesn't lead to any adverse effect. fixes #653 Signed-off-by: Alexandre Beslic <ab21c8b9f7@abronan.com>
- Loading branch information
Showing
2 changed files
with
39 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters