summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2018-10-18 11:45:45 +0200
committerEven Rouault <even.rouault@spatialys.com>2018-10-18 11:45:45 +0200
commitcd900d96618ab77e79812db654731dd6b5fc7bd8 (patch)
tree03b864b145c514de953bd83d0d3bebc51aa6bd62 /src
parent0e6a5553cfef21b764d289585af2c6934a95456b (diff)
opj_thread_pool_setup(): fix infinite waiting if a thread creation failed
Diffstat (limited to 'src')
-rw-r--r--src/lib/openjp2/thread.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lib/openjp2/thread.c b/src/lib/openjp2/thread.c
index af33c2c8..f2fca2ee 100644
--- a/src/lib/openjp2/thread.c
+++ b/src/lib/openjp2/thread.c
@@ -723,6 +723,8 @@ static OPJ_BOOL opj_thread_pool_setup(opj_thread_pool_t* tp, int num_threads)
tp->worker_threads[i].thread = opj_thread_create(opj_worker_thread_function,
&(tp->worker_threads[i]));
if (tp->worker_threads[i].thread == NULL) {
+ opj_mutex_destroy(tp->worker_threads[i].mutex);
+ opj_cond_destroy(tp->worker_threads[i].cond);
tp->worker_threads_count = i;
bRet = OPJ_FALSE;
break;
@@ -732,7 +734,7 @@ static OPJ_BOOL opj_thread_pool_setup(opj_thread_pool_t* tp, int num_threads)
/* Wait all threads to be started */
/* printf("waiting for all threads to be started\n"); */
opj_mutex_lock(tp->mutex);
- while (tp->waiting_worker_thread_count < num_threads) {
+ while (tp->waiting_worker_thread_count < tp->worker_threads_count) {
opj_cond_wait(tp->cond, tp->mutex);
}
opj_mutex_unlock(tp->mutex);