summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2018-08-06 20:34:24 -0400
committerMarek Olšák <[email protected]>2019-04-01 12:37:52 -0400
commitb7317b6ce0943076a786e7151c561e22412f892c (patch)
tree39d9ccf9ebaf0591a31d4287814e892640db7852 /src
parentbb111559f2929cf2692ea421ba514fcd075bfe1c (diff)
util/queue: hold a lock when reading num_threads in util_queue_finish
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/util/u_queue.c6
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]);