#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
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;
static struct workqueue_ops log_compress_wq_ops = {
.fn = gz_work,
+ .nice = 1,
};
int iolog_compress_init(struct thread_data *td)
data->nr_samples = log->nr_samples;
log->nr_samples = 0;
- if (wait) {
+ data->wait = wait;
+ if (data->wait) {
pthread_mutex_init(&data->lock, NULL);
pthread_cond_init(&data->cv, NULL);
data->done = 0;
- data->wait = 1;
data->refs = 2;
- } else
- data->wait = 0;
+ }
workqueue_enqueue(&log->td->log_compress_wq, &data->work);
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;