mirror of
https://github.com/RangeNetworks/openbts.git
synced 2025-11-05 06:13:15 +00:00
Transceiver52M: Deallocate high level resources on shutdown
This primarily addresses the error case at initialization. In the event that the transceiver fails to start, we should be able cleanly shutdown and release while providing a useful reason for exiting. After the radio is started and threads launched, there are no thread state variables or shutdown messaging between threads, and the transceiver cannot be consistently shutdown. This issue remains to be solved. Signed-off-by: Thomas Tsou <tom@tsou.cc> git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@6752 19bc5d8c-e614-43d4-8b26-e1612bc8e597
This commit is contained in:
@@ -75,8 +75,6 @@ RadioInterfaceResamp::~RadioInterfaceResamp()
|
|||||||
|
|
||||||
void RadioInterfaceResamp::close()
|
void RadioInterfaceResamp::close()
|
||||||
{
|
{
|
||||||
RadioInterface::close();
|
|
||||||
|
|
||||||
delete innerSendBuffer;
|
delete innerSendBuffer;
|
||||||
delete outerSendBuffer;
|
delete outerSendBuffer;
|
||||||
delete innerRecvBuffer;
|
delete innerRecvBuffer;
|
||||||
@@ -89,9 +87,13 @@ void RadioInterfaceResamp::close()
|
|||||||
outerSendBuffer = NULL;
|
outerSendBuffer = NULL;
|
||||||
innerRecvBuffer = NULL;
|
innerRecvBuffer = NULL;
|
||||||
outerRecvBuffer = NULL;
|
outerRecvBuffer = NULL;
|
||||||
|
sendBuffer = NULL;
|
||||||
|
recvBuffer = NULL;
|
||||||
|
|
||||||
upsampler = NULL;
|
upsampler = NULL;
|
||||||
dnsampler = NULL;
|
dnsampler = NULL;
|
||||||
|
|
||||||
|
RadioInterface::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize I/O specific objects */
|
/* Initialize I/O specific objects */
|
||||||
|
|||||||
@@ -47,8 +47,6 @@
|
|||||||
*/
|
*/
|
||||||
#define SPS 4
|
#define SPS 4
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
ConfigurationKeyMap getConfigurationKeys();
|
ConfigurationKeyMap getConfigurationKeys();
|
||||||
ConfigurationTable gConfig(CONFIGDB, 0, getConfigurationKeys());
|
ConfigurationTable gConfig(CONFIGDB, 0, getConfigurationKeys());
|
||||||
|
|
||||||
@@ -56,7 +54,7 @@ volatile bool gbShutdown = false;
|
|||||||
|
|
||||||
static void ctrlCHandler(int signo)
|
static void ctrlCHandler(int signo)
|
||||||
{
|
{
|
||||||
cout << "Received shutdown signal" << endl;;
|
std::cout << "Received shutdown signal" << std::endl;
|
||||||
gbShutdown = true;
|
gbShutdown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,28 +109,25 @@ int testConfig(const char *filename)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int trxPort;
|
int trxPort, fail = 0;
|
||||||
std::string deviceArgs, logLevel, trxAddr;
|
std::string deviceArgs, logLevel, trxAddr;
|
||||||
|
RadioDevice *usrp = NULL;
|
||||||
|
RadioInterface *radio = NULL;
|
||||||
|
Transceiver *trx = NULL;
|
||||||
|
|
||||||
if (argc == 3)
|
if (argc == 3)
|
||||||
{
|
|
||||||
deviceArgs = std::string(argv[2]);
|
deviceArgs = std::string(argv[2]);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
deviceArgs = "";
|
deviceArgs = "";
|
||||||
|
|
||||||
|
if (signal(SIGINT, ctrlCHandler) == SIG_ERR) {
|
||||||
|
std::cerr << "Couldn't install signal handler for SIGINT" << std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( signal( SIGINT, ctrlCHandler ) == SIG_ERR )
|
if (signal(SIGTERM, ctrlCHandler) == SIG_ERR) {
|
||||||
{
|
std::cerr << "Couldn't install signal handler for SIGTERM" << std::endl;
|
||||||
cerr << "Couldn't install signal handler for SIGINT" << endl;
|
return EXIT_FAILURE;
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( signal( SIGTERM, ctrlCHandler ) == SIG_ERR )
|
|
||||||
{
|
|
||||||
cerr << "Couldn't install signal handler for SIGTERM" << endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure logger.
|
// Configure logger.
|
||||||
@@ -148,14 +143,13 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
srandom(time(NULL));
|
srandom(time(NULL));
|
||||||
|
|
||||||
RadioDevice *usrp = RadioDevice::make(SPS);
|
usrp = RadioDevice::make(SPS);
|
||||||
int radioType = usrp->open(deviceArgs);
|
int radioType = usrp->open(deviceArgs);
|
||||||
if (radioType < 0) {
|
if (radioType < 0) {
|
||||||
LOG(ALERT) << "Transceiver exiting..." << std::endl;
|
LOG(ALERT) << "Transceiver exiting..." << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioInterface* radio;
|
|
||||||
switch (radioType) {
|
switch (radioType) {
|
||||||
case RadioDevice::NORMAL:
|
case RadioDevice::NORMAL:
|
||||||
radio = new RadioInterface(usrp, 3, SPS, false);
|
radio = new RadioInterface(usrp, 3, SPS, false);
|
||||||
@@ -166,27 +160,38 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG(ALERT) << "Unsupported configuration";
|
LOG(ALERT) << "Unsupported configuration";
|
||||||
return EXIT_FAILURE;
|
fail = 1;
|
||||||
|
goto shutdown;
|
||||||
}
|
}
|
||||||
if (!radio->init(radioType)) {
|
if (!radio->init(radioType)) {
|
||||||
LOG(ALERT) << "Failed to initialize radio interface";
|
LOG(ALERT) << "Failed to initialize radio interface";
|
||||||
|
fail = 1;
|
||||||
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transceiver *trx = new Transceiver(trxPort, trxAddr.c_str(),
|
trx = new Transceiver(trxPort, trxAddr.c_str(), SPS, GSM::Time(3,0), radio);
|
||||||
SPS, GSM::Time(3,0), radio);
|
|
||||||
if (!trx->init()) {
|
if (!trx->init()) {
|
||||||
LOG(ALERT) << "Failed to initialize transceiver";
|
LOG(ALERT) << "Failed to initialize transceiver";
|
||||||
|
fail = 1;
|
||||||
|
goto shutdown;
|
||||||
}
|
}
|
||||||
trx->receiveFIFO(radio->receiveFIFO());
|
trx->receiveFIFO(radio->receiveFIFO());
|
||||||
trx->start();
|
trx->start();
|
||||||
|
|
||||||
while (!gbShutdown) {
|
while (!gbShutdown)
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
|
||||||
|
|
||||||
cout << "Shutting down transceiver..." << endl;
|
shutdown:
|
||||||
|
std::cout << "Shutting down transceiver..." << std::endl;
|
||||||
|
|
||||||
delete trx;
|
delete trx;
|
||||||
|
delete radio;
|
||||||
|
delete usrp;
|
||||||
|
|
||||||
|
if (fail)
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationKeyMap getConfigurationKeys()
|
ConfigurationKeyMap getConfigurationKeys()
|
||||||
|
|||||||
Reference in New Issue
Block a user