]> Git Repo - qemu.git/commitdiff
replay/replay-internal.c: track holding of replay_lock
authorAlex Bennée <[email protected]>
Tue, 27 Feb 2018 09:52:37 +0000 (12:52 +0300)
committerPaolo Bonzini <[email protected]>
Mon, 12 Mar 2018 15:12:50 +0000 (16:12 +0100)
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 <[email protected]>
Tested-by: Pavel Dovgalyuk <[email protected]>
Message-Id: <20180227095237.1060.44661.stgit@pasha-VirtualBox>
Signed-off-by: Paolo Bonzini <[email protected]>
replay/replay-internal.c

index fca851401292714f0cf7ae066e5729e495767ef5..0d7e1d6bc433b9ebc5093d1d070222ba56bda6dd 100644 (file)
@@ -169,6 +169,8 @@ void replay_finish_event(void)
     replay_fetch_data_kind();
 }
 
+static __thread bool replay_locked;
+
 void replay_mutex_init(void)
 {
     qemu_mutex_init(&lock);
@@ -179,13 +181,22 @@ void replay_mutex_destroy(void)
     qemu_mutex_destroy(&lock);
 }
 
+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);
 }
 
This page took 0.026806 seconds and 4 git commands to generate.