File: 0020-Only-call-pthread_join-if-thread-is-active.patch

package info (click to toggle)
airspyone-host 1.0.10-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,200 kB
  • sloc: ansic: 6,550; sh: 31; xml: 20; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 1,091 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From d5cd86729c4e0003f8e4f23d1bb3d660d37f3fa9 Mon Sep 17 00:00:00 2001
From: Johan Hedin <johan.o.hedin@gmail.com>
Date: Wed, 10 Jan 2024 22:13:20 +0100
Subject: [PATCH 20/29] Only call pthread_join if thread is 'active'

---
 libairspy/src/airspy.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libairspy/src/airspy.c b/libairspy/src/airspy.c
index 397d117..7766a18 100644
--- a/libairspy/src/airspy.c
+++ b/libairspy/src/airspy.c
@@ -529,8 +529,14 @@ static int kill_io_threads(airspy_device_t* device)
 		pthread_cond_signal(&device->consumer_cv);
 		pthread_mutex_unlock(&device->consumer_mp);
 
-		pthread_join(device->transfer_thread, NULL);
-		pthread_join(device->consumer_thread, NULL);
+		if (device->transfer_thread != 0) {
+		    pthread_join(device->transfer_thread, NULL);
+		    device->transfer_thread = 0;
+		}
+		if (device->consumer_thread != 0) {
+		    pthread_join(device->consumer_thread, NULL);
+		    device->consumer_thread = 0;
+		}
 
 		libusb_handle_events_timeout_completed(device->usb_context, &timeout, NULL);
 	}
-- 
2.47.3