p2p/server: add UDP port mapping goroutine to wait group (#20846)

This commit is contained in:
ucwong 2020-04-02 00:00:33 +08:00 committed by GitHub
parent 1e2e1b41f8
commit bf35e27ea7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)