Browse Source

Merge pull request #1254 from mrjana/networkdb

Make sure to notify watchers on node going away
Alessandro Boch 9 years ago
parent
commit
174e19f64f
1 changed files with 9 additions and 2 deletions
  1. 9 2
      libnetwork/networkdb/cluster.go

+ 9 - 2
libnetwork/networkdb/cluster.go

@@ -193,7 +193,10 @@ func (nDB *NetworkDB) reapNetworks() {
 }
 }
 
 
 func (nDB *NetworkDB) reapTableEntries() {
 func (nDB *NetworkDB) reapTableEntries() {
-	var paths []string
+	var (
+		paths   []string
+		entries []*entry
+	)
 
 
 	now := time.Now()
 	now := time.Now()
 
 
@@ -209,12 +212,14 @@ func (nDB *NetworkDB) reapTableEntries() {
 		}
 		}
 
 
 		paths = append(paths, path)
 		paths = append(paths, path)
+		entries = append(entries, entry)
 		return false
 		return false
 	})
 	})
 	nDB.RUnlock()
 	nDB.RUnlock()
 
 
 	nDB.Lock()
 	nDB.Lock()
-	for _, path := range paths {
+	for i, path := range paths {
+		entry := entries[i]
 		params := strings.Split(path[1:], "/")
 		params := strings.Split(path[1:], "/")
 		tname := params[0]
 		tname := params[0]
 		nid := params[1]
 		nid := params[1]
@@ -227,6 +232,8 @@ func (nDB *NetworkDB) reapTableEntries() {
 		if _, ok := nDB.indexes[byNetwork].Delete(fmt.Sprintf("/%s/%s/%s", nid, tname, key)); !ok {
 		if _, ok := nDB.indexes[byNetwork].Delete(fmt.Sprintf("/%s/%s/%s", nid, tname, key)); !ok {
 			logrus.Errorf("Could not delete entry in network %s with table name %s and key %s as it does not exist", nid, tname, key)
 			logrus.Errorf("Could not delete entry in network %s with table name %s and key %s as it does not exist", nid, tname, key)
 		}
 		}
+
+		nDB.broadcaster.Write(makeEvent(opDelete, tname, nid, key, entry.value))
 	}
 	}
 	nDB.Unlock()
 	nDB.Unlock()
 }
 }