iolog: fix 'cur_log' leaks
[fio.git] / iolog.c
diff --git a/iolog.c b/iolog.c
index e2f9776e3b5c2306e9001d3755666df5cb77c697..ff521df4719818e2ecf368ef021e1763be5a1f3b 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -576,7 +576,6 @@ void setup_log(struct io_log **log, struct log_params *p,
               const char *filename)
 {
        struct io_log *l;
-       pthread_mutexattr_t mattr;
 
        l = scalloc(1, sizeof(*l));
        INIT_FLIST_HEAD(&l->io_logs);
@@ -605,11 +604,7 @@ void setup_log(struct io_log **log, struct log_params *p,
        if (l->log_gz && !p->td)
                l->log_gz = 0;
        else if (l->log_gz || l->log_gz_store) {
-               pthread_mutexattr_init(&mattr);
-#ifdef FIO_HAVE_PSHARED_MUTEX
-               pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED);
-#endif
-               pthread_mutex_init(&l->chunk_lock, &mattr);
+               mutex_init_pshared(&l->chunk_lock);
                p->td->flags |= TD_F_COMPRESS_LOG;
        }
 
@@ -650,6 +645,7 @@ void free_log(struct io_log *log)
                cur_log = flist_first_entry(&log->io_logs, struct io_logs, list);
                flist_del_init(&cur_log->list);
                free(cur_log->log);
+               sfree(cur_log);
        }
 
        if (log->pending) {
@@ -993,6 +989,7 @@ void flush_log(struct io_log *log, int do_append)
                cur_log = flist_first_entry(&log->io_logs, struct io_logs, list);
                flist_del_init(&cur_log->list);
                flush_samples(f, cur_log->log, cur_log->nr_samples * log_entry_sz(log));
+               sfree(cur_log);
        }
 
        fclose(f);
@@ -1231,9 +1228,7 @@ static int iolog_flush(struct io_log *log)
                data->samples = cur_log->log;
                data->nr_samples = cur_log->nr_samples;
 
-               cur_log->nr_samples = 0;
-               cur_log->max_samples = 0;
-               cur_log->log = NULL;
+               sfree(cur_log);
 
                gz_work(data);
        }