diff options
author | Marek Olšák <marek.olsak@amd.com> | 2018-08-06 20:34:24 -0400 |
---|---|---|
committer | Marek Olšák <marek.olsak@amd.com> | 2019-04-01 12:37:52 -0400 |
commit | b7317b6ce0943076a786e7151c561e22412f892c (patch) | |
tree | 39d9ccf9ebaf0591a31d4287814e892640db7852 /src/util/u_queue.c | |
parent | bb111559f2929cf2692ea421ba514fcd075bfe1c (diff) | |
download | mesa-b7317b6ce0943076a786e7151c561e22412f892c.tar.gz mesa-b7317b6ce0943076a786e7151c561e22412f892c.tar.bz2 mesa-b7317b6ce0943076a786e7151c561e22412f892c.zip |
util/queue: hold a lock when reading num_threads in util_queue_finish
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/util/u_queue.c')
-rw-r--r-- | src/util/u_queue.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/util/u_queue.c b/src/util/u_queue.c index cfd2a08e3c8..5e0c1095569 100644 --- a/src/util/u_queue.c +++ b/src/util/u_queue.c @@ -592,15 +592,15 @@ void util_queue_finish(struct util_queue *queue) { util_barrier barrier; - struct util_queue_fence *fences = malloc(queue->num_threads * sizeof(*fences)); - - util_barrier_init(&barrier, queue->num_threads); + struct util_queue_fence *fences; /* If 2 threads were adding jobs for 2 different barries at the same time, * a deadlock would happen, because 1 barrier requires that all threads * wait for it exclusively. */ mtx_lock(&queue->finish_lock); + fences = malloc(queue->num_threads * sizeof(*fences)); + util_barrier_init(&barrier, queue->num_threads); for (unsigned i = 0; i < queue->num_threads; ++i) { util_queue_fence_init(&fences[i]); |