diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-09-03 16:50:49 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-09-04 16:35:23 +0200 |
commit | db936b9b55fb825acbe7df4246097fe23d405612 (patch) | |
tree | dc9a60041b19dbb741ec281cf2e68fbe02d35735 /Transceiver52M/Transceiver.cpp | |
parent | 49ad7590728880f967dbc31876679a9dbd10d014 (diff) |
osmo-trx: Add osmo_signal to stop whole transceiver chain correctly on error
Transceiver::stop() can only be called from either CTRL iface thread or
from main thread (running osmocom loop). That's because stop attempts to
cancel and then join all the other threads, which would then lock if
attempting to stop from some of them.
As a result, the best option is to indicate to the user of the
transceiver option (osmo-trx.cpp) to stop it in a correct fashion by
destroying the object from the main thread.
Change-Id: Iac1d2dbe2328e735db2d4b933cb67b1af1babca1
Diffstat (limited to 'Transceiver52M/Transceiver.cpp')
-rw-r--r-- | Transceiver52M/Transceiver.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp index a1ebb30..cdfd79d 100644 --- a/Transceiver52M/Transceiver.cpp +++ b/Transceiver52M/Transceiver.cpp @@ -27,6 +27,10 @@ #include "Transceiver.h" #include <Logger.h> +extern "C" { +#include "osmo_signal.h" +} + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -115,7 +119,7 @@ Transceiver::Transceiver(int wBasePort, : mBasePort(wBasePort), mLocalAddr(TRXAddress), mRemoteAddr(GSMcoreAddress), mClockSocket(TRXAddress, wBasePort, GSMcoreAddress, wBasePort + 100), mTransmitLatency(wTransmitLatency), mRadioInterface(wRadioInterface), - rssiOffset(wRssiOffset), + rssiOffset(wRssiOffset), sig_cbfn(NULL), mSPSTx(tx_sps), mSPSRx(rx_sps), mChans(chans), mEdge(false), mOn(false), mForceClockInterface(false), mTxFreq(0.0), mRxFreq(0.0), mTSC(0), mMaxExpectedDelayAB(0), mMaxExpectedDelayNB(0), mWriteBurstToDiskMask(0) @@ -219,6 +223,17 @@ bool Transceiver::init(FillerType filler, size_t rtsc, unsigned rach_delay, bool return true; } +void Transceiver::setSignalHandler(osmo_signal_cbfn cbfn) +{ + if (this->sig_cbfn) + osmo_signal_unregister_handler(SS_TRANSC, this->sig_cbfn, NULL); + + if (cbfn) { + this->sig_cbfn = cbfn; + osmo_signal_register_handler(SS_TRANSC, this->sig_cbfn, NULL); + } +} + /* * Start the transceiver * @@ -885,8 +900,12 @@ bool Transceiver::driveTxPriorityQueue(size_t chan) void Transceiver::driveReceiveRadio() { - if (!mRadioInterface->driveReceiveRadio()) { + int rc = mRadioInterface->driveReceiveRadio(); + if (rc == 0) { usleep(100000); + } else if (rc < 0) { + LOG(FATAL) << "radio Interface receive failed, requesting stop."; + osmo_signal_dispatch(SS_TRANSC, S_TRANSC_STOP_REQUIRED, this); } else if (mForceClockInterface || mTransmitDeadlineClock > mLastClockUpdateTime + GSM::Time(216,0)) { mForceClockInterface = false; writeClockInterface(); |