On 2022-03-15 Jia Tan wrote:
> As promised, I have attached a patch to solve the problem. Instead of
> doing as I had originally proposed, I simply added a wake up signal
> to a sleeping thread if partial updates are enabled. When the worker
> wakes up, it checks if no more input
> is available and signals to the main thread if it has output ready
> before going back
> to sleep. This prevents the deadlock on my liblzma tests and testing
> xz with/without timeout.

Thanks to both of you for debugging this. I see now that I had
completely missed this corner case. The patch looks correct except that
the mutex locking order is wrong which can cause a new deadlock. If
both thr->mutex and coder->mutex are locked at the same time,
coder->mutex must be locked first.

About memlimit updates, that may indeed need some work but I don't know
yet how much is worth the trouble. stream_decoder_mt_memconfig() has a
few FIXMEs too, maybe they don't need to be changed but it needs to be
decided.

I'm in a hurry now but I should have time for xz next week. :-)

-- 
Lasse Collin

Reply via email to