Explorar o código

Merge pull request #1457 from aboch/pnc

Lock agent access in addDriverWatches
Madhu Venugopal %!s(int64=8) %!d(string=hai) anos
pai
achega
7feaa49556
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      libnetwork/agent.go

+ 5 - 1
libnetwork/agent.go

@@ -468,8 +468,12 @@ func (n *network) addDriverWatches() {
 
 	c := n.getController()
 	for _, tableName := range n.driverTables {
-		ch, cancel := c.agent.networkDB.Watch(tableName, n.ID(), "")
 		c.Lock()
+		if c.agent == nil {
+			c.Unlock()
+			return
+		}
+		ch, cancel := c.agent.networkDB.Watch(tableName, n.ID(), "")
 		c.agent.driverCancelFuncs[n.ID()] = append(c.agent.driverCancelFuncs[n.ID()], cancel)
 		c.Unlock()