Skip to content

Commit

Permalink
Merge pull request #2679 from corhere/backport-20.10/fix-processendpo…
Browse files Browse the repository at this point in the history
…intdelete-deadlock

Fix deadlock between getSvcRecords and processEndpointDelete
  • Loading branch information
cpuguy83 committed Oct 20, 2023
2 parents 67e0588 + 9a98d9c commit 3797618
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,14 @@ func (c *controller) processEndpointDelete(nmap map[string]*netWatch, ep *endpoi
return
}

networkID := n.ID()
endpointID := ep.ID()

c.Lock()
nw, ok := nmap[n.ID()]
nw, ok := nmap[networkID]

if ok {
delete(nw.localEps, ep.ID())
delete(nw.localEps, endpointID)
c.Unlock()

// Update the svc db about local endpoint leave right away
Expand All @@ -420,9 +423,9 @@ func (c *controller) processEndpointDelete(nmap map[string]*netWatch, ep *endpoi

// This is the last container going away for the network. Destroy
// this network's svc db entry
delete(c.svcRecords, n.ID())
delete(c.svcRecords, networkID)

delete(nmap, n.ID())
delete(nmap, networkID)
}
}
c.Unlock()
Expand Down

0 comments on commit 3797618

Please sign in to comment.