From 426d1570259dedec8d527b8c832b24b4829d4765 Mon Sep 17 00:00:00 2001 From: Arceliar Date: Fri, 8 Mar 2019 18:51:07 -0600 Subject: [PATCH] make sure we don't replace an existing listener --- src/yggdrasil/tcp.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/yggdrasil/tcp.go b/src/yggdrasil/tcp.go index 2a177c03..43ea4431 100644 --- a/src/yggdrasil/tcp.go +++ b/src/yggdrasil/tcp.go @@ -155,8 +155,14 @@ func (t *tcp) listener(l *tcpListener, listenaddr string) { } // Track the listener so that we can find it again in future t.mutex.Lock() - t.listeners[listenaddr] = l - t.mutex.Unlock() + if _, isIn := t.listeners[listenaddr]; isIn { + t.mutex.Unlock() + l.listener.Close() + return + } else { + t.listeners[listenaddr] = l + t.mutex.Unlock() + } // And here we go! accepted := make(chan bool) defer func() {