diff mbox series

[RFC,v1,4/9] replay/replay-internal.c: track holding of replay_lock

Message ID 20170505103822.20641-5-alex.bennee@linaro.org
State New
Headers show
Series BQL and Replay Lock changes | expand

Commit Message

Alex Bennée May 5, 2017, 10:38 a.m. UTC
This is modelled after the iothread mutex lock. We keep a TLS flag to
indicate when that thread has acquired the lock and assert we don't
double-lock or release when we shouldn't have.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

---
 replay/replay-internal.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

-- 
2.11.0
diff mbox series

Patch

diff --git a/replay/replay-internal.c b/replay/replay-internal.c
index fca8514012..157c863e25 100644
--- a/replay/replay-internal.c
+++ b/replay/replay-internal.c
@@ -179,13 +179,24 @@  void replay_mutex_destroy(void)
     qemu_mutex_destroy(&lock);
 }
 
+static __thread bool replay_locked;
+
+static bool replay_mutex_locked(void)
+{
+    return replay_locked;
+}
+
 void replay_mutex_lock(void)
 {
+    g_assert(!replay_mutex_locked());
     qemu_mutex_lock(&lock);
+    replay_locked = true;
 }
 
 void replay_mutex_unlock(void)
 {
+    g_assert(replay_mutex_locked());
+    replay_locked = false;
     qemu_mutex_unlock(&lock);
 }