Skip to content

Commit

Permalink
Fix a dead-lock problem in NodeProcessor::Close(). Closes #42
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeng committed Aug 21, 2024
1 parent 71cb30c commit 60be0a7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions services/hh/node_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,18 @@ func (n *NodeProcessor) Open() error {
// When closed it will not accept hinted-handoff data.
func (n *NodeProcessor) Close() error {
n.mu.Lock()
defer n.mu.Unlock()

if n.done == nil {
// Already closed.
n.mu.Unlock()
return nil
}

close(n.done)
n.wg.Wait()
n.done = nil
n.mu.Unlock()

n.wg.Wait()

return n.queue.Close()
}
Expand Down

0 comments on commit 60be0a7

Please sign in to comment.