summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkrasjet <nil@krj.st>2020-10-14 17:40:56 +0000
committerFilipe Coelho <falktx@falktx.com>2021-04-14 16:12:11 +0100
commit62b07487dc76b5d94d118e7926d216a2cbb8bb5d (patch)
treea7b654470273f2b50242133dc9988754ec86780b
parent1dea3e2c010f5ff9cb023e1fcedabd49d19499e3 (diff)
downloadjack2-62b07487dc76b5d94d118e7926d216a2cbb8bb5d.tar.gz
fix a deadlock issue in midi_dump
The main loop might be blocked by `data_ready` when JACK server dies while the program is running. To reproduce the problem: 1. Start JACK server 2. Run `jack_midi_dump` 3. Stop JACK server 4. Press Ctrl-C in `jack_midi_dump` to send SIGINT. 5. Observe that the program doesn't stop and stuck in the main loop. This patch forces the `data_ready` to be signaled in the signal handler to prevent indefinite waiting.
-rw-r--r--tools/midi_dump.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/midi_dump.c b/tools/midi_dump.c
index 7a7ec2b3..ef9148b3 100644
--- a/tools/midi_dump.c
+++ b/tools/midi_dump.c
@@ -112,6 +112,11 @@ process (jack_nframes_t frames, void* arg)
static void wearedone(int sig) {
fprintf(stderr, "Shutting down\n");
keeprunning = 0;
+ /* main loop might be blocked by data_ready when jack server dies. */
+ if (pthread_mutex_trylock (&msg_thread_lock) == 0) {
+ pthread_cond_signal (&data_ready);
+ pthread_mutex_unlock (&msg_thread_lock);
+ }
}
static void usage (int status) {