From 157ca5e01d4b1542778aca47ce27c5c98b10cb0f Mon Sep 17 00:00:00 2001 From: lifeng Date: Wed, 21 Aug 2024 22:09:27 +0800 Subject: [PATCH] Fix a dead-lock problem in NodeProcessor::Close(). Closes #42 --- services/hh/node_processor.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/hh/node_processor.go b/services/hh/node_processor.go index 10d3a70..7290929 100644 --- a/services/hh/node_processor.go +++ b/services/hh/node_processor.go @@ -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() }