From bf35e27ea76ea50515e3f345a9ac05ec558ffabf Mon Sep 17 00:00:00 2001 From: ucwong Date: Thu, 2 Apr 2020 00:00:33 +0800 Subject: [PATCH] p2p/server: add UDP port mapping goroutine to wait group (#20846) --- p2p/server.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/p2p/server.go b/p2p/server.go index c87b7758d..1fe5f3978 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -562,7 +562,11 @@ func (srv *Server) setupDiscovery() error { srv.log.Debug("UDP listener up", "addr", realaddr) if srv.NAT != nil { if !realaddr.IP.IsLoopback() { - go nat.Map(srv.NAT, srv.quit, "udp", realaddr.Port, realaddr.Port, "ethereum discovery") + srv.loopWG.Add(1) + go func() { + nat.Map(srv.NAT, srv.quit, "udp", realaddr.Port, realaddr.Port, "ethereum discovery") + srv.loopWG.Done() + }() } } srv.localnode.SetFallbackUDP(realaddr.Port)