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

Execute reconnection on a goroutine #168

Merged
merged 1 commit into from
Sep 16, 2021
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
10 changes: 9 additions & 1 deletion tunnel/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,15 @@ func (t *Tunnel) Start() error {

log.Debugf("restablishing the tunnel after disconnection: %s", t)

t.connect()
// The reconnecion must happens on a goroutine to support the scenario
// where tunnel.Stop() is called while the tunnel.connect() is getting
// executed.
//
// In an event where tunnel.reconnect receives data from any point of the
// code rather than tunnel.dial(), which is evoked by tunnel.connect()
// this code needs to be updated to make sure tunnel.connect() is not
// schedule in two goroutines at the same time.
go t.connect()
}
case err := <-t.done:
if t.client != nil {
Expand Down