Skip to content

Commit 2133b16

Browse files
committed
On send node envents, notify only if there are peers
- Otherwise operation will unnecessarely block for five seconds. - This is particularly noticeable on graceful shutdown of daemon in one node cluster. Signed-off-by: Alessandro Boch <aboch@docker.com>
1 parent f6ce0ce commit 2133b16

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

networkdb/broadcast.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ func (nDB *NetworkDB) sendNodeEvent(event NodeEvent_Type) error {
8686
notify: notifyCh,
8787
})
8888

89+
nDB.RLock()
90+
noPeers := len(nDB.nodes) <= 1
91+
nDB.RUnlock()
92+
93+
// Message enqueued, do not wait for a send if no peer is present
94+
if noPeers {
95+
return nil
96+
}
97+
8998
// Wait for the broadcast
9099
select {
91100
case <-notifyCh:

0 commit comments

Comments
 (0)