From 46c5df1c239187db35965037c59fba1582750422 Mon Sep 17 00:00:00 2001 From: Arceliar Date: Tue, 13 Aug 2019 18:49:49 -0500 Subject: [PATCH] when we abandon a link because we already have a connection to that peer, only wait for the connection to close if it's an *outgoing* link, otherwise incomming connection attempts can cause us to leak links --- src/yggdrasil/link.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/yggdrasil/link.go b/src/yggdrasil/link.go index de90fd9..eca96eb 100644 --- a/src/yggdrasil/link.go +++ b/src/yggdrasil/link.go @@ -179,7 +179,10 @@ func (intf *linkInterface) handler() error { // That lets them do things like close connections on its own, avoid printing a connection message in the first place, etc. intf.link.core.log.Debugln("DEBUG: found existing interface for", intf.name) intf.msgIO.close() - <-oldIntf.closed + if !intf.incoming { + // Block outgoing connection attempts until the existing connection closes + <-oldIntf.closed + } return nil } else { intf.closed = make(chan struct{})