X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=mutex.c;h=5e5a0648161de8767bbee98e42ac71d1bef94062;hp=758092218477e0eb5dc0da8a5049aba2f6e9e908;hb=8f7630813305a4f4f04a5f9ba20b2a7d486c0cfb;hpb=34febb23fa9c7b9b0d54c324effff1a808a8fe6e diff --git a/mutex.c b/mutex.c index 75809221..5e5a0648 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) @@ -156,7 +162,7 @@ int fio_mutex_down_timeout(struct fio_mutex *mutex, unsigned int msecs) t.tv_nsec = tv_s.tv_usec * 1000; t.tv_sec += msecs / 1000; - t.tv_nsec += ((msecs * 1000000) % 1000000000); + t.tv_nsec += ((msecs * 1000000ULL) % 1000000000); if (t.tv_nsec >= 1000000000) { t.tv_nsec -= 1000000000; t.tv_sec++;