iolog: remember to destroy cond/lock when done
[fio.git] / iolog.c
diff --git a/iolog.c b/iolog.c
index c4aa21f79e0e840a940c58766e152de8bb6e5fca..9c59acd8653b491a08c6a8aa4ab12584599e9910 100644 (file)
--- 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;