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 authored and chengshiwen committed Aug 23, 2024
1 parent 71cb30c commit 157ca5e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions services/hh/node_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,17 @@ 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 157ca5e

Please sign in to comment.