p2p/discover | sync close tab when udp server is stopped

This commit is contained in:
ucwong 2020-04-01 08:21:25 +00:00
parent f0be151349
commit bc0be4d6a7

View file

@ -280,7 +280,11 @@ func ListenV4(c UDPConn, ln *enode.LocalNode, cfg Config) (*UDPv4, error) {
return nil, err
}
t.tab = tab
go tab.loop()
t.wg.Add(1)
go func() {
defer t.wg.Done()
tab.loop()
}()
t.wg.Add(2)
go t.loop()
@ -298,8 +302,8 @@ func (t *UDPv4) Close() {
t.closeOnce.Do(func() {
t.cancelCloseCtx()
t.conn.Close()
t.wg.Wait()
t.tab.close()
t.wg.Wait()
})
}