From: Jens Axboe Date: Tue, 8 Dec 2015 19:42:26 +0000 (-0700) Subject: iolog: remember to destroy cond/lock when done X-Git-Tag: fio-2.2.13~20 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=c143980a657b71eedb68ae888c4de709e4499f9e;p=fio.git iolog: remember to destroy cond/lock when done Signed-off-by: Jens Axboe --- diff --git a/iolog.c b/iolog.c index c4aa21f7..9c59acd8 100644 --- a/iolog.c +++ b/iolog.c @@ -996,6 +996,15 @@ static int finish_log(struct thread_data *td, struct io_log *log, int trylock) #ifdef CONFIG_ZLIB +static void drop_data(struct iolog_flush_data *data, int refs) +{ + if (!refs) { + free(data); + pthread_mutex_destroy(&data->lock); + pthread_cond_destroy(&data->cv); + } +} + /* * Invoked from our compress helper thread, when logging would have exceeded * the specified memory limitation. Compresses the previously stored @@ -1090,8 +1099,7 @@ done: pthread_cond_signal(&data->cv); refs = --data->refs; pthread_mutex_unlock(&data->lock); - if (!refs) - free(data); + drop_data(data, refs); } else free(data); return ret; @@ -1174,8 +1182,7 @@ int iolog_flush(struct io_log *log, int wait) pthread_cond_wait(&data->cv, &data->lock); refs = --data->refs; pthread_mutex_unlock(&data->lock); - if (!refs) - free(data); + drop_data(data, refs); } return 0;