Fix phy memory leaks

master
Xavier Arteaga 6 years ago committed by Andre Puschmann
parent 5faa819dcd
commit 5dcf3b3563

@ -143,7 +143,7 @@ private:
const static int WORKERS_THREAD_PRIO = 2; const static int WORKERS_THREAD_PRIO = 2;
radio_interface_phy* radio = nullptr; radio_interface_phy* radio = nullptr;
std::vector<srslte::log_filter*> log_vec; std::vector<std::unique_ptr<srslte::log_filter> > log_vec;
srslte::logger* logger = nullptr; srslte::logger* logger = nullptr;
srslte::log* log_h = nullptr; srslte::log* log_h = nullptr;

@ -137,7 +137,7 @@ int phy::init(const phy_args_t& args_, srslte::logger* logger_)
mylog->init(tmp, logger, true); mylog->init(tmp, logger, true);
mylog->set_level(args.log.phy_level); mylog->set_level(args.log.phy_level);
mylog->set_hex_limit(args.log.phy_hex_limit); mylog->set_hex_limit(args.log.phy_hex_limit);
log_vec.push_back(mylog); log_vec.push_back(std::move(std::unique_ptr<srslte::log_filter>(mylog)));
} }
// Add PHY lib log // Add PHY lib log
@ -148,13 +148,13 @@ int phy::init(const phy_args_t& args_, srslte::logger* logger_)
lib_log->init(tmp, logger, true); lib_log->init(tmp, logger, true);
lib_log->set_level(args.log.phy_lib_level); lib_log->set_level(args.log.phy_lib_level);
lib_log->set_hex_limit(args.log.phy_hex_limit); lib_log->set_hex_limit(args.log.phy_hex_limit);
log_vec.push_back(lib_log); log_vec.push_back(std::move(std::unique_ptr<srslte::log_filter>(lib_log)));
} else { } else {
log_vec.push_back(nullptr); log_vec.push_back(nullptr);
} }
// set default logger // set default logger
log_h = log_vec.at(0); log_h = log_vec.at(0).get();
if (!check_args(args)) { if (!check_args(args)) {
return false; return false;
@ -162,7 +162,7 @@ int phy::init(const phy_args_t& args_, srslte::logger* logger_)
nof_workers = args.nof_phy_threads; nof_workers = args.nof_phy_threads;
if (log_vec[nof_workers]) { if (log_vec[nof_workers]) {
this->log_phy_lib_h = (srslte::log*)log_vec[0]; this->log_phy_lib_h = (srslte::log*)log_vec[0].get();
srslte_phy_log_register_handler(this, srslte_phy_handler); srslte_phy_log_register_handler(this, srslte_phy_handler);
} else { } else {
this->log_phy_lib_h = nullptr; this->log_phy_lib_h = nullptr;
@ -177,12 +177,12 @@ int phy::init(const phy_args_t& args_, srslte::logger* logger_)
void phy::run_thread() void phy::run_thread()
{ {
prach_buffer.init(SRSLTE_MAX_PRB, log_h); prach_buffer.init(SRSLTE_MAX_PRB, log_h);
common.init(&args, (srslte::log*)log_vec[0], radio, stack); common.init(&args, (srslte::log*)log_vec[0].get(), radio, stack);
// Add workers to workers pool and start threads // Add workers to workers pool and start threads
for (uint32_t i=0;i<nof_workers;i++) { for (uint32_t i=0;i<nof_workers;i++) {
auto w = std::unique_ptr<sf_worker>( auto w = std::unique_ptr<sf_worker>(new sf_worker(
new sf_worker(SRSLTE_MAX_PRB, &common, (srslte::log*)log_vec[i], (srslte::log*)log_vec[nof_workers], &sfsync)); SRSLTE_MAX_PRB, &common, (srslte::log*)log_vec[i].get(), (srslte::log*)log_vec[nof_workers].get(), &sfsync));
workers_pool.init_worker(i, w.get(), WORKERS_THREAD_PRIO, args.worker_cpu_mask); workers_pool.init_worker(i, w.get(), WORKERS_THREAD_PRIO, args.worker_cpu_mask);
workers.push_back(std::move(w)); workers.push_back(std::move(w));
} }

@ -106,17 +106,14 @@ void sync::init(radio_interface_phy* _radio,
sync::~sync() sync::~sync()
{ {
if (running) { for (uint32_t r = 0; r < SRSLTE_MAX_RADIOS; r++) {
uint32_t nof_rf_channels = worker_com->args->nof_rf_channels * worker_com->args->nof_rx_ant; for (uint32_t p = 0; p < SRSLTE_MAX_PORTS; p++) {
for (uint32_t r = 0; r < worker_com->args->nof_radios; r++) {
for (uint32_t p = 0; p < nof_rf_channels; p++) {
if (sf_buffer[r][p]) { if (sf_buffer[r][p]) {
free(sf_buffer[r][p]); free(sf_buffer[r][p]);
} }
} }
} }
srslte_ue_sync_free(&ue_sync); srslte_ue_sync_free(&ue_sync);
}
} }
void sync::stop() void sync::stop()

Loading…
Cancel
Save