Skip to content

Commit

Permalink
don't depend on goroutine to avoid deadlock.
Browse files Browse the repository at this point in the history
Code calls a function that has a lock that is held around that call. It
didn't deadlock as the function call was calling it as a goroutine, so
it would kick it off and then unlock which would let the goroutine then
get the lock. Found this when I temporarily removed to goroutine to
force sequential exectution for debugging. Didn't like this so I cleaned
things up such that the code doesn't rely on the goroutine to avoid the
deadlock.
  • Loading branch information
eikenb committed May 12, 2022
1 parent cf4687c commit 56039d2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion coordinate.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ func (a *Agent) updateCoords(nodeCh nodeChannel) {
a.inflightLock.Lock()
if _, ok := a.inflightPings[node.Node]; ok {
a.logger.Warn("Error pinging node, last request still outstanding", "node", node.Node, "nodeId", node.ID)
a.inflightLock.Unlock()
} else {
a.inflightPings[node.Node] = struct{}{}
a.inflightLock.Unlock()
go a.runNodePing(node)
}
a.inflightLock.Unlock()
}
}

Expand Down

0 comments on commit 56039d2

Please sign in to comment.