From: Jens Axboe Date: Mon, 24 Oct 2016 16:49:48 +0000 (-0600) Subject: mutex: clear mutex when removed X-Git-Tag: fio-2.15~4 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=4e1cc8e6ddf90e4e2fa5eab27cca4110e4dce1bb 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 --- 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)