From a091b1806207d06e02a469487a4a9e3961c0e12b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 22 Nov 2020 14:08:48 +0100 Subject: [PATCH] Fix occasional segfault when exiting with enter+q if Acquisition_XX.blocking=false --- docs/changelog.md | 2 ++ .../acquisition/gnuradio_blocks/CMakeLists.txt | 1 - .../acquisition/gnuradio_blocks/pcps_acquisition.cc | 13 +++---------- .../acquisition/gnuradio_blocks/pcps_acquisition.h | 2 -- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index d0e123d5e..e0070644f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -67,6 +67,8 @@ SPDX-FileCopyrightText: 2011-2020 Carles Fernandez-Prades d_threshold) @@ -872,7 +869,6 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count) send_negative_acquisition(); } } - d_worker_active = false; if ((d_num_noncoherent_integrations_counter == d_acq_parameters.max_dwells) or (d_positive_acq == 1)) { @@ -884,6 +880,8 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count) d_num_noncoherent_integrations_counter = 0U; d_positive_acq = 0; } + + d_worker_active = false; } @@ -930,11 +928,7 @@ int pcps_acquisition::general_work(int noutput_items __attribute__((unused)), * 6. Declare positive or negative acquisition using a message port */ gr::thread::scoped_lock lk(d_setlock); - if (!d_active and d_worker_active and !d_acq_parameters.blocking) - { - pthread_cancel(d_id_worker); - return 0; - } + if (!d_active or d_worker_active) { if (!d_acq_parameters.blocking_on_standby) @@ -1022,7 +1016,6 @@ int pcps_acquisition::general_work(int noutput_items __attribute__((unused)), else { d_worker = std::thread([&] { pcps_acquisition::acquisition_core(d_sample_counter); }); - d_id_worker = d_worker.native_handle(); d_worker.detach(); d_worker_active = true; } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h index bcdcf5332..c161cb063 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h @@ -59,7 +59,6 @@ #include #include #include -#include #include #include #include @@ -261,7 +260,6 @@ private: std::string d_dump_filename; std::thread d_worker; - pthread_t d_id_worker; int64_t d_dump_number; uint64_t d_sample_counter;