diff options
author | JP Cimalando <jpcima@users.noreply.github.com> | 2018-09-17 17:09:23 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-09-18 13:51:53 +0200 |
commit | 40af4ccdb06443a9a72efa380924684ce87ec0c5 (patch) | |
tree | aee7359877b87c36f740a2b96187123dd201423f | |
parent | 2f32eb51077b707239d5e686eabe1419dca7adad (diff) | |
download | jalv-40af4ccdb06443a9a72efa380924684ce87ec0c5.tar.gz jalv-40af4ccdb06443a9a72efa380924684ce87ec0c5.tar.bz2 jalv-40af4ccdb06443a9a72efa380924684ce87ec0c5.zip |
Fix a potential crash when closed with worker
-rw-r--r-- | src/jalv.c | 3 | ||||
-rw-r--r-- | src/worker.c | 11 | ||||
-rw-r--r-- | src/worker.h | 3 |
3 files changed, 15 insertions, 2 deletions
@@ -1179,6 +1179,9 @@ main(int argc, char** argv) } jalv_backend_close(&jalv); + /* Destroy the worker */ + jalv_worker_destroy(&jalv.worker); + /* Deactivate plugin */ suil_instance_free(jalv.ui_instance); lilv_instance_deactivate(jalv.instance); diff --git a/src/worker.c b/src/worker.c index 6f94997..8354ad6 100644 --- a/src/worker.c +++ b/src/worker.c @@ -81,10 +81,17 @@ jalv_worker_init(Jalv* jalv, void jalv_worker_finish(JalvWorker* worker) { + if (worker->threaded) { + zix_sem_post(&worker->sem); + zix_thread_join(worker->thread, NULL); + } +} + +void +jalv_worker_destroy(JalvWorker* worker) +{ if (worker->requests) { if (worker->threaded) { - zix_sem_post(&worker->sem); - zix_thread_join(worker->thread, NULL); zix_ring_free(worker->requests); } zix_ring_free(worker->responses); diff --git a/src/worker.h b/src/worker.h index 93f39e0..a437fe7 100644 --- a/src/worker.h +++ b/src/worker.h @@ -27,6 +27,9 @@ jalv_worker_init(Jalv* jalv, void jalv_worker_finish(JalvWorker* worker); +void +jalv_worker_destroy(JalvWorker* worker); + LV2_Worker_Status jalv_worker_schedule(LV2_Worker_Schedule_Handle handle, uint32_t size, |