From 4e1cc8e6ddf90e4e2fa5eab27cca4110e4dce1bb Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 24 Oct 2016 10:49:48 -0600 Subject: [PATCH] mutex: clear mutex when removed This ensures that any attempt to grab it after it has been removed will trigger an assert, instead of just silently hanging. Signed-off-by: Jens Axboe --- mutex.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mutex.c b/mutex.c index 75809221..e5b045ec 100644 --- 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) -- 2.25.1