core/bloombits: fix a deadlock when a matcher session hits an error

This commit is contained in:
Toshihito Kikuchi 2023-09-23 17:45:34 -07:00 committed by tokikuch
parent 82ec555d70
commit 1ec46ae349
No known key found for this signature in database
GPG key ID: 5FC95A8910795927

View file

@ -630,13 +630,16 @@ func (s *MatcherSession) Multiplex(batch int, wait time.Duration, mux chan chan
request <- &Retrieval{Bit: bit, Sections: sections, Context: s.ctx}
result := <-request
// Deliver a result before s.Close() to avoid a deadlock
s.deliverSections(result.Bit, result.Sections, result.Bitsets)
if result.Error != nil {
s.errLock.Lock()
s.err = result.Error
s.errLock.Unlock()
s.Close()
}
s.deliverSections(result.Bit, result.Sections, result.Bitsets)
}
}
}