From 7d08079131f01b9e0cddc81c0e42e18ec8fa63f8 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 17 Jun 2016 10:57:09 +0200 Subject: fix segfault on SIGINT before UHD init completes --- src/OutputUHD.cpp | 3 +-- src/OutputUHD.h | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp index 87ea9c3..c7e9fac 100644 --- a/src/OutputUHD.cpp +++ b/src/OutputUHD.cpp @@ -122,8 +122,8 @@ OutputUHD::OutputUHD( // the buffers at object initialisation. first_run(true), gps_fix_verified(false), + worker(&uwd), myDelayBuf(0) - { myConf.muting = true; // is remote-controllable, and reset by the GPS fix check myConf.staticDelayUs = 0; // is remote-controllable @@ -269,7 +269,6 @@ OutputUHD::OutputUHD( OutputUHD::~OutputUHD() { MDEBUG("OutputUHD::~OutputUHD() @ %p\n", this); - worker.stop(); } diff --git a/src/OutputUHD.h b/src/OutputUHD.h index 6de945e..a74f627 100644 --- a/src/OutputUHD.h +++ b/src/OutputUHD.h @@ -126,9 +126,11 @@ struct UHDWorkerData { class UHDWorker { public: - void start(struct UHDWorkerData *uhdworkerdata) { + UHDWorker(struct UHDWorkerData *uhdworkerdata) { uwd = uhdworkerdata; + } + void start(struct UHDWorkerData *uhdworkerdata) { uwd->running = true; uhd_thread = boost::thread(&UHDWorker::process_errhandler, this); } @@ -141,6 +143,13 @@ class UHDWorker { uhd_thread.join(); } + ~UHDWorker() { + stop(); + } + + UHDWorker(const UHDWorker& other) = delete; + UHDWorker& operator=(const UHDWorker& other) = delete; + private: // Asynchronous message statistics int num_underflows; @@ -234,17 +243,17 @@ class OutputUHD: public ModOutput, public RemoteControllable { protected: - OutputUHD(const OutputUHD& other); - OutputUHD& operator=(const OutputUHD& other); + OutputUHD(const OutputUHD& other) = delete; + OutputUHD& operator=(const OutputUHD& other) = delete; EtiReader *myEtiReader; OutputUHDConfig& myConf; uhd::usrp::multi_usrp::sptr myUsrp; std::shared_ptr mySyncBarrier; - UHDWorker worker; bool first_run; bool gps_fix_verified; struct UHDWorkerData uwd; + UHDWorker worker; private: // Resize the internal delay buffer according to the dabMode and -- cgit v1.2.3