p2p/discover: fix a race where table loop would self-lookup before returning from constructor

This commit is contained in:
Martin Holst Swende 2019-05-13 11:25:54 +02:00
parent abeba0a1de
commit 95263914fc
No known key found for this signature in database
GPG Key ID: 683B438C05A5DDF0
3 changed files with 2 additions and 1 deletions

View File

@ -119,7 +119,6 @@ func newTable(t transport, db *enode.DB, bootnodes []*enode.Node, log log.Logger
tab.seedRand()
tab.loadSeedNodes()
go tab.loop()
return tab, nil
}

View File

@ -42,6 +42,7 @@ func init() {
func newTestTable(t transport) (*Table, *enode.DB) {
db, _ := enode.OpenDB("")
tab, _ := newTable(t, db, nil, log.Root())
go tab.loop()
return tab, db
}

View File

@ -253,6 +253,7 @@ func ListenV4(c UDPConn, ln *enode.LocalNode, cfg Config) (*UDPv4, error) {
return nil, err
}
t.tab = tab
go tab.loop()
t.wg.Add(2)
go t.loop()