aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/osmo-trx.cpp
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-09-03 16:50:49 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2018-09-04 16:35:23 +0200
commitdb936b9b55fb825acbe7df4246097fe23d405612 (patch)
treedc9a60041b19dbb741ec281cf2e68fbe02d35735 /Transceiver52M/osmo-trx.cpp
parent49ad7590728880f967dbc31876679a9dbd10d014 (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/osmo-trx.cpp')
-rw-r--r--Transceiver52M/osmo-trx.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp
index 1c40fcf..d01a4cf 100644
--- a/Transceiver52M/osmo-trx.cpp
+++ b/Transceiver52M/osmo-trx.cpp
@@ -55,6 +55,7 @@ extern "C" {
#include "convert.h"
#include "trx_vty.h"
#include "debug.h"
+#include "osmo_signal.h"
}
#define DEFAULT_CONFIG_FILE "osmo-trx.cfg"
@@ -112,6 +113,20 @@ RadioInterface *makeRadioInterface(struct trx_ctx *trx,
return radio;
}
+/* Callback function to be called every time we receive a signal from TRANSC */
+static int transc_sig_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ switch (signal) {
+ case S_TRANSC_STOP_REQUIRED:
+ gshutdown = true;
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+
/* Create transceiver core
* The multi-threaded modem core operates at multiples of the GSM rate of
* 270.8333 ksps and consists of GSM specific modulation, demodulation,
@@ -132,6 +147,8 @@ int makeTransceiver(struct trx_ctx *trx, RadioInterface *radio)
return -1;
}
+ transceiver->setSignalHandler(transc_sig_cb);
+
for (size_t i = 0; i < trx->cfg.num_chans; i++) {
fifo = radio->receiveFIFO(i);
if (fifo && transceiver->receiveFIFO(fifo, i))