File: 0002-Process-pending-libusb-events-before-shutdown-78.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 (42 lines) | stat: -rw-r--r-- 1,272 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
34
35
36
37
38
39
40
41
42
From f652e230f31ab88ca35b2f0af8c4b44c81106489 Mon Sep 17 00:00:00 2001
From: Johan Hedin <johan.o.hedin@gmail.com>
Date: Sat, 22 May 2021 17:38:09 +0200
Subject: [PATCH 02/29] Process pending libusb events before shutdown (#78)

* Process pending libusb events before shutdown

After libusb_cancel_transfer, pending events need to be handled to
avoid memory leaks.

* Do not use deprecated function

Use libusb_handle_events_timeout_completed instead of deprecated libusb_handle_events_timeout.
---
 libairspy/src/airspy.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libairspy/src/airspy.c b/libairspy/src/airspy.c
index afd096c..1f2178b 100644
--- a/libairspy/src/airspy.c
+++ b/libairspy/src/airspy.c
@@ -515,6 +515,8 @@ static void* transfer_threadproc(void* arg)
 
 static int kill_io_threads(airspy_device_t* device)
 {
+	struct timeval timeout = { 0, 0 };
+
 	if (device->streaming)
 	{
 		device->stop_requested = true;
@@ -527,6 +529,8 @@ static int kill_io_threads(airspy_device_t* device)
 		pthread_join(device->transfer_thread, NULL);
 		pthread_join(device->consumer_thread, NULL);
 
+		libusb_handle_events_timeout_completed(device->usb_context, &timeout, NULL);
+
 		device->stop_requested = false;
 		device->streaming = false;
 	}
-- 
2.47.3