From feadec63846d569829a4302486025b2915228712 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 27 Oct 2016 12:49:07 +0200 Subject: qemu-thread: introduce QemuRecMutex GRecMutex is new in glib 2.32, so we cannot use it. Introduce a recursive mutex in qemu-thread instead, which will be used instead of RFifoLock. Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Paolo Bonzini Message-Id: <1477565348-5458-20-git-send-email-pbonzini@redhat.com> Signed-off-by: Fam Zheng --- util/qemu-thread-posix.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'util/qemu-thread-posix.c') diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index ce51b37c1d..d20cddec0c 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -80,6 +80,20 @@ void qemu_mutex_unlock(QemuMutex *mutex) error_exit(err, __func__); } +void qemu_rec_mutex_init(QemuRecMutex *mutex) +{ + int err; + pthread_mutexattr_t attr; + + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + err = pthread_mutex_init(&mutex->lock, &attr); + pthread_mutexattr_destroy(&attr); + if (err) { + error_exit(err, __func__); + } +} + void qemu_cond_init(QemuCond *cond) { int err; -- cgit 1.4.1