浏览代码

Merge pull request #1688 from aboch/ptst

Fix panic in networkdb test code
Madhu Venugopal 8 年之前
父节点
当前提交
6ebaee9e62
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      libnetwork/networkdb/networkdb_test.go

+ 6 - 1
libnetwork/networkdb/networkdb_test.go

@@ -55,7 +55,9 @@ func closeNetworkDBInstances(dbs []*NetworkDB) {
 
 func (db *NetworkDB) verifyNodeExistence(t *testing.T, node string, present bool) {
 	for i := 0; i < 80; i++ {
+		db.RLock()
 		_, ok := db.nodes[node]
+		db.RUnlock()
 		if present && ok {
 			return
 		}
@@ -72,7 +74,10 @@ func (db *NetworkDB) verifyNodeExistence(t *testing.T, node string, present bool
 
 func (db *NetworkDB) verifyNetworkExistence(t *testing.T, node string, id string, present bool) {
 	for i := 0; i < 80; i++ {
-		if nn, nnok := db.networks[node]; nnok {
+		db.RLock()
+		nn, nnok := db.networks[node]
+		db.RUnlock()
+		if nnok {
 			n, ok := nn[id]
 			if present && ok {
 				return