Просмотр исходного кода

Merge pull request #1713 from aboch/nse

On clusterLeave, notify only if there are peers
Santhosh Manohar 8 лет назад
Родитель
Сommit
1693144ae2
1 измененных файлов с 9 добавлено и 0 удалено
  1. 9 0
      libnetwork/networkdb/broadcast.go

+ 9 - 0
libnetwork/networkdb/broadcast.go

@@ -86,6 +86,15 @@ func (nDB *NetworkDB) sendNodeEvent(event NodeEvent_Type) error {
 		notify: notifyCh,
 	})
 
+	nDB.RLock()
+	noPeers := len(nDB.nodes) <= 1
+	nDB.RUnlock()
+
+	// Message enqueued, do not wait for a send if no peer is present
+	if noPeers {
+		return nil
+	}
+
 	// Wait for the broadcast
 	select {
 	case <-notifyCh: