瀏覽代碼

Merge pull request #42545 from steffengy/master

libnetwork: processEndpointDelete: Fix deadlock between getSvcRecords and processEndpointDelete
Brian Goff 4 年之前
父節點
當前提交
3ad9549e70
共有 1 個文件被更改,包括 7 次插入4 次删除
  1. 7 4
      libnetwork/store.go

+ 7 - 4
libnetwork/store.go

@@ -402,11 +402,14 @@ func (c *controller) processEndpointDelete(nmap map[string]*netWatch, ep *endpoi
 		return
 		return
 	}
 	}
 
 
+	networkID := n.ID()
+	endpointID := ep.ID()
+
 	c.Lock()
 	c.Lock()
-	nw, ok := nmap[n.ID()]
+	nw, ok := nmap[networkID]
 
 
 	if ok {
 	if ok {
-		delete(nw.localEps, ep.ID())
+		delete(nw.localEps, endpointID)
 		c.Unlock()
 		c.Unlock()
 
 
 		// Update the svc db about local endpoint leave right away
 		// Update the svc db about local endpoint leave right away
@@ -420,9 +423,9 @@ func (c *controller) processEndpointDelete(nmap map[string]*netWatch, ep *endpoi
 
 
 			// This is the last container going away for the network. Destroy
 			// This is the last container going away for the network. Destroy
 			// this network's svc db entry
 			// this network's svc db entry
-			delete(c.svcRecords, n.ID())
+			delete(c.svcRecords, networkID)
 
 
-			delete(nmap, n.ID())
+			delete(nmap, networkID)
 		}
 		}
 	}
 	}
 	c.Unlock()
 	c.Unlock()