5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-22 14:10:28 +00:00

remove link.go block on oldIntf if we already have a connection to the same node, this spams connections, so it's not a good long-term fix if that's where the goroutine leak is

This commit is contained in:
Arceliar 2020-12-13 16:16:14 -06:00
parent df1239b054
commit 1daf3e7bd7

View File

@ -252,16 +252,12 @@ func (intf *link) handler() error {
intf.info.box = meta.box intf.info.box = meta.box
intf.info.sig = meta.sig intf.info.sig = meta.sig
intf.links.mutex.Lock() intf.links.mutex.Lock()
if oldIntf, isIn := intf.links.links[intf.info]; isIn { if _, isIn := intf.links.links[intf.info]; isIn {
intf.links.mutex.Unlock() intf.links.mutex.Unlock()
// FIXME we should really return an error and let the caller block instead // FIXME we should really return an error and let the caller block instead
// That lets them do things like close connections on its own, avoid printing a connection message in the first place, etc. // That lets them do things like close connections on its own, avoid printing a connection message in the first place, etc.
intf.links.core.log.Debugln("DEBUG: found existing interface for", intf.name) intf.links.core.log.Debugln("DEBUG: found existing interface for", intf.name)
intf.msgIO.close() intf.msgIO.close()
if !intf.incoming {
// Block outgoing connection attempts until the existing connection closes
<-oldIntf.closed
}
return nil return nil
} else { } else {
intf.closed = make(chan struct{}) intf.closed = make(chan struct{})