diff mbox series

[PULL,24/42] job: Fix missing locking due to mismerge

Message ID 20180925151541.18932-25-mreitz@redhat.com
State New
Headers show
Series [PULL,01/42] block/commit: add block job creation flags | expand

Commit Message

Max Reitz Sept. 25, 2018, 3:15 p.m. UTC
From: Kevin Wolf <kwolf@redhat.com>

job_completed() had a problem with double locking that was recently
fixed independently by two different commits:

"job: Fix nested aio_poll() hanging in job_txn_apply"
"jobs: add exit shim"

One fix removed the first aio_context_acquire(), the other fix removed
the other one. Now we have a bug again and the code is run without any
locking.

Add it back in one of the places.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
---
 job.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/job.c b/job.c
index 3dd31a5f8e..d17b1c82da 100644
--- a/job.c
+++ b/job.c
@@ -847,7 +847,11 @@  static void job_completed(Job *job)
 static void job_exit(void *opaque)
 {
     Job *job = (Job *)opaque;
+    AioContext *ctx = job->aio_context;
+
+    aio_context_acquire(ctx);
     job_completed(job);
+    aio_context_release(ctx);
 }
 
 /**