From 52ed93408b9331905978ccb98c6b280c5eba1e64 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Tue, 21 Feb 2017 23:18:25 +0100 Subject: [PATCH] prevent double close in tcp hub --- transport/internet/tcp_hub.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/transport/internet/tcp_hub.go b/transport/internet/tcp_hub.go index 775b494a..786e8bd2 100644 --- a/transport/internet/tcp_hub.go +++ b/transport/internet/tcp_hub.go @@ -63,11 +63,16 @@ func ListenTCP(address v2net.Address, port v2net.Port, callback ConnectionHandle } func (v *TCPHub) Close() { + defer func() { + recover() + }() + select { case <-v.closed: return default: v.listener.Close() + close(v.closed) } }