mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
liblzma: Fix another deadlock in the threaded encoder.
This race condition could cause a deadlock if lzma_end() was called before finishing the encoding. This can happen with xz with debugging enabled (non-debugging version doesn't call lzma_end() before exiting).
This commit is contained in:
parent
b465da5988
commit
e572e123b5
1 changed files with 6 additions and 3 deletions
|
@ -341,12 +341,15 @@ worker_start(void *thr_ptr)
|
||||||
if (state == THR_EXIT)
|
if (state == THR_EXIT)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Mark the thread as idle. Signal is needed for the case
|
// Mark the thread as idle unless the main thread has
|
||||||
|
// told us to exit. Signal is needed for the case
|
||||||
// where the main thread is waiting for the threads to stop.
|
// where the main thread is waiting for the threads to stop.
|
||||||
mythread_sync(thr->mutex) {
|
mythread_sync(thr->mutex) {
|
||||||
|
if (thr->state != THR_EXIT) {
|
||||||
thr->state = THR_IDLE;
|
thr->state = THR_IDLE;
|
||||||
pthread_cond_signal(&thr->cond);
|
pthread_cond_signal(&thr->cond);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mythread_sync(thr->coder->mutex) {
|
mythread_sync(thr->coder->mutex) {
|
||||||
// Mark the output buffer as finished if
|
// Mark the output buffer as finished if
|
||||||
|
|
Loading…
Reference in a new issue