liblzma: Fix a deadlock in the threaded encoder.
authorLasse Collin <lasse.collin@tukaani.org>
Sun, 23 Oct 2011 14:05:55 +0000 (17:05 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Sun, 23 Oct 2011 14:05:55 +0000 (17:05 +0300)
It was triggered when reinitializing the encoder,
e.g. when encoding two files.

src/liblzma/common/stream_encoder_mt.c

index 323f04a..a4b2800 100644 (file)
@@ -295,8 +295,10 @@ worker_start(void *thr_ptr)
                        while (true) {
                                // The thread is already idle so if we are
                                // requested to stop, just set the state.
-                               if (thr->state == THR_STOP)
+                               if (thr->state == THR_STOP) {
                                        thr->state = THR_IDLE;
+                                       pthread_cond_signal(&thr->cond);
+                               }
 
                                state = thr->state;
                                if (state != THR_IDLE)