ref: 8e5c00fee92731a98998f935bb504d35bb4310c6
parent: e293c3963ffe94490143353ab480f8477d0d52ef
author: Ronald S. Bultje <rsbultje@gmail.com>
date: Sat Oct 6 11:15:03 EDT 2018
Ensure all tile workers are parked before finishing frame Otherwise a pathological condition can start the next frame while some related variables are still being read. Fixes #43.
--- a/src/decode.c
+++ b/src/decode.c
@@ -2589,10 +2589,7 @@
// signal available tasks to worker threads
int num_tasks;
- const uint64_t all_mask = ~0ULL >> (64 - f->n_tc);
pthread_mutex_lock(&f->tile_thread.lock);
- while (f->tile_thread.available != all_mask)
- pthread_cond_wait(&f->tile_thread.icond, &f->tile_thread.lock);
assert(!f->tile_thread.tasks_left);
if (f->frame_thread.pass == 1 || f->n_tc >= f->frame_hdr.tiling.cols) {
// we can (or in fact, if >, we need to) do full tile decoding.
@@ -2635,6 +2632,12 @@
progress_plane_type);
}
}
+
+ const uint64_t all_mask = ~0ULL >> (64 - f->n_tc);
+ pthread_mutex_lock(&f->tile_thread.lock);
+ while (f->tile_thread.available != all_mask)
+ pthread_cond_wait(&f->tile_thread.icond, &f->tile_thread.lock);
+ pthread_mutex_unlock(&f->tile_thread.lock);
}
if (f->frame_thread.pass <= 1 && f->frame_hdr.refresh_context) {