diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-06-17 10:57:09 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-06-17 10:57:09 +0200 |
commit | 7d08079131f01b9e0cddc81c0e42e18ec8fa63f8 (patch) | |
tree | a9362c6ae0cb6cc5bd00cb0cecbaf9b0e722524f | |
parent | 45c2d54e57bd26ef91d1dd1f011a17f20623443a (diff) | |
download | dabmod-7d08079131f01b9e0cddc81c0e42e18ec8fa63f8.tar.gz dabmod-7d08079131f01b9e0cddc81c0e42e18ec8fa63f8.tar.bz2 dabmod-7d08079131f01b9e0cddc81c0e42e18ec8fa63f8.zip |
fix segfault on SIGINT before UHD init completes
-rw-r--r-- | src/OutputUHD.cpp | 3 | ||||
-rw-r--r-- | src/OutputUHD.h | 17 |
2 files changed, 14 insertions, 6 deletions
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<boost::barrier> 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 |