[libvirt PATCH 7/7] virMutex*: Fail loudly

Tim Wiederhake twiederh at redhat.com
Thu Aug 5 13:08:51 UTC 2021


Make failure to lock, unlock or destroy mutexes visible in the CI.

As "abort()" is quite a harsh treatment and pthread generally speaking
"does the right thing" regardless, limit this to analysis builds in
the CI as to not bother users but still make developers aware of issues.

Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 src/util/virthread.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/util/virthread.c b/src/util/virthread.c
index f64dbee9e9..95213bd511 100644
--- a/src/util/virthread.c
+++ b/src/util/virthread.c
@@ -88,6 +88,9 @@ void virMutexDestroy(virMutex *m)
 {
     if (pthread_mutex_destroy(&m->lock)) {
         VIR_WARN("Failed to destroy mutex=%p", m);
+#if DYNAMIC_ANALYSIS
+        abort();
+#endif
     }
 }
 
@@ -95,6 +98,9 @@ void virMutexLock(virMutex *m)
 {
     if (pthread_mutex_lock(&m->lock)) {
         VIR_WARN("Failed to lock mutex=%p", m);
+#if DYNAMIC_ANALYSIS
+        abort();
+#endif
     }
 }
 
@@ -102,6 +108,9 @@ void virMutexUnlock(virMutex *m)
 {
     if (pthread_mutex_unlock(&m->lock)) {
         VIR_WARN("Failed to unlock mutex=%p", m);
+#if DYNAMIC_ANALYSIS
+        abort();
+#endif
     }
 }
 
-- 
2.31.1




More information about the libvir-list mailing list