diff options
-rw-r--r-- | include/qemu/coroutine.h | 1 | ||||
-rw-r--r-- | util/qemu-coroutine-lock.c | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h index ac8d4c9cc8..29a20782f0 100644 --- a/include/qemu/coroutine.h +++ b/include/qemu/coroutine.h @@ -143,6 +143,7 @@ bool qemu_co_queue_empty(CoQueue *queue); */ typedef struct CoMutex { bool locked; + Coroutine *holder; CoQueue queue; } CoMutex; diff --git a/util/qemu-coroutine-lock.c b/util/qemu-coroutine-lock.c index 22aa9abb30..f30ee8184d 100644 --- a/util/qemu-coroutine-lock.c +++ b/util/qemu-coroutine-lock.c @@ -129,6 +129,7 @@ void coroutine_fn qemu_co_mutex_lock(CoMutex *mutex) } mutex->locked = true; + mutex->holder = self; trace_qemu_co_mutex_lock_return(mutex, self); } @@ -140,9 +141,11 @@ void coroutine_fn qemu_co_mutex_unlock(CoMutex *mutex) trace_qemu_co_mutex_unlock_entry(mutex, self); assert(mutex->locked == true); + assert(mutex->holder == self); assert(qemu_in_coroutine()); mutex->locked = false; + mutex->holder = NULL; qemu_co_queue_next(&mutex->queue); trace_qemu_co_mutex_unlock_return(mutex, self); |