mutex: clear mutex when removed
[fio.git] / mutex.c
diff --git a/mutex.c b/mutex.c
index 758092218477e0eb5dc0da8a5049aba2f6e9e908..e5b045ec91bc0348234eff8cf3f5ff265a9253cf 100644 (file)
--- a/mutex.c
+++ b/mutex.c
@@ -22,6 +22,12 @@ void __fio_mutex_remove(struct fio_mutex *mutex)
 {
        assert(mutex->magic == FIO_MUTEX_MAGIC);
        pthread_cond_destroy(&mutex->cond);
+
+       /*
+        * Ensure any subsequent attempt to grab this mutex will fail
+        * with an assert, instead of just silently hanging.
+        */
+       memset(mutex, 0, sizeof(*mutex));
 }
 
 void fio_mutex_remove(struct fio_mutex *mutex)