Skip to content

Commit

Permalink
Fix couple of panics in networkdb
Browse files Browse the repository at this point in the history
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
  • Loading branch information
mrjana committed Jun 3, 2016
1 parent 531ba0f commit 0cfd412
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 12 additions & 2 deletions networkdb/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ func (nDB *NetworkDB) reapTableEntries() {
func (nDB *NetworkDB) gossip() {
networkNodes := make(map[string][]string)
nDB.RLock()
for nid := range nDB.networks[nDB.config.NodeName] {
thisNodeNetworks := nDB.networks[nDB.config.NodeName]
for nid := range thisNodeNetworks {
networkNodes[nid] = nDB.networkNodes[nid]

}
Expand All @@ -195,8 +196,17 @@ func (nDB *NetworkDB) gossip() {
bytesAvail := udpSendBuf - compoundHeaderOverhead

nDB.RLock()
broadcastQ := nDB.networks[nDB.config.NodeName][nid].tableBroadcasts
network, ok := thisNodeNetworks[nid]
nDB.RUnlock()
if !ok || network == nil {
// It is normal for the network to be removed
// between the time we collect the network
// attachments of this node and processing
// them here.
continue
}

broadcastQ := network.tableBroadcasts

if broadcastQ == nil {
logrus.Errorf("Invalid broadcastQ encountered while gossiping for network %s", nid)
Expand Down
5 changes: 5 additions & 0 deletions networkdb/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ func (nDB *NetworkDB) handleTableMessage(buf []byte) {
}

broadcastQ := n.tableBroadcasts

if broadcastQ == nil {
return
}

broadcastQ.QueueBroadcast(&tableEventMessage{
msg: buf,
id: tEvent.NetworkID,
Expand Down

0 comments on commit 0cfd412

Please sign in to comment.