From 85eee61358fd44f6e89f7ad7ade4ea4534b911f5 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Fri, 2 Jan 2015 22:34:35 +0000 Subject: [PATCH] Oops, one unsaved file. --- dump1090.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dump1090.c b/dump1090.c index d2da11d..dfbc7af 100644 --- a/dump1090.c +++ b/dump1090.c @@ -331,8 +331,9 @@ void readDataFromFile(void) { while(toread) { nread = read(Modes.fd, p, toread); if (nread <= 0) { + // Done. Modes.exit = 1; // Signal the other threads to exit. - break; + goto OUT; } p += nread; toread -= nread; @@ -355,6 +356,9 @@ void readDataFromFile(void) { // Signal to the other thread that new data is ready pthread_cond_signal(&Modes.data_cond); } + + OUT: + pthread_mutex_unlock(&Modes.data_mutex); } // //========================================================================= @@ -388,7 +392,7 @@ void *readerThreadEntryPoint(void *arg) { // Wake the main thread (if it's still waiting) pthread_mutex_lock(&Modes.data_mutex); - Modes.exit = 1; + Modes.exit = 1; // just in case pthread_cond_signal(&Modes.data_cond); pthread_mutex_unlock(&Modes.data_mutex);