瀏覽代碼

Merge pull request #19562 from holiman/fix_tabcrash

p2p/discover: fix nil-dereference due to race
Péter Szilágyi 6 年之前
父節點
當前提交
a0b81097ad
共有 3 個文件被更改,包括 2 次插入1 次删除
  1. 0 1
      p2p/discover/table.go
  2. 1 0
      p2p/discover/table_util_test.go
  3. 1 0
      p2p/discover/v4_udp.go

+ 0 - 1
p2p/discover/table.go

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

+ 1 - 0
p2p/discover/table_util_test.go

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

+ 1 - 0
p2p/discover/v4_udp.go

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