Fix crash in mac_nr when accesing the ue_db and not checking if the rnti is valid, while there fix a potential data race.

Fix data race inside sched_nr when modifying per ue metrics.
master
faluco 3 years ago committed by Andre Puschmann
parent a4932564d7
commit b8171e493e

@ -77,6 +77,7 @@ public:
// metrics // metrics
mac_ue_metrics_t metrics = {}; mac_ue_metrics_t metrics = {};
std::mutex metrics_mutex;
private: private:
bwp_ue_cfg bwp_cfg; bwp_ue_cfg bwp_cfg;

@ -389,9 +389,12 @@ bool mac_nr::handle_uci_data(const uint16_t rnti, const srsran_uci_cfg_nr_t& cfg
} }
// Process CQI // Process CQI
if (value.valid) { {
srsran::rwlock_read_guard rw_lock(rwmutex);
if (ue_db.contains(rnti) && value.valid) {
ue_db[rnti]->metrics_dl_cqi(cfg_, value.csi->wideband_cri_ri_pmi_cqi.cqi); ue_db[rnti]->metrics_dl_cqi(cfg_, value.csi->wideband_cri_ri_pmi_cqi.cqi);
} }
}
return true; return true;
} }

@ -172,6 +172,7 @@ void sched_nr::dl_ack_info(uint16_t rnti, uint32_t cc, uint32_t pid, uint32_t tb
sched_workers->enqueue_cc_feedback(rnti, cc, [this, pid, tb_idx, ack](ue_carrier& ue_cc) { sched_workers->enqueue_cc_feedback(rnti, cc, [this, pid, tb_idx, ack](ue_carrier& ue_cc) {
int tbs = ue_cc.harq_ent.dl_ack_info(pid, tb_idx, ack); int tbs = ue_cc.harq_ent.dl_ack_info(pid, tb_idx, ack);
if (tbs >= 0) { if (tbs >= 0) {
std::lock_guard<std::mutex> lock(ue_cc.metrics_mutex);
if (ack) { if (ack) {
ue_cc.metrics.tx_brate += tbs; ue_cc.metrics.tx_brate += tbs;
} else { } else {

@ -375,6 +375,7 @@ void sched_worker_manager::get_metrics_nolocking(mac_metrics_t& metrics)
for (mac_ue_metrics_t& ue_metric : metrics.ues) { for (mac_ue_metrics_t& ue_metric : metrics.ues) {
if (ue_db.contains(ue_metric.rnti) and ue_db[ue_metric.rnti]->carriers[0] != nullptr) { if (ue_db.contains(ue_metric.rnti) and ue_db[ue_metric.rnti]->carriers[0] != nullptr) {
auto& ue_cc = *ue_db[ue_metric.rnti]->carriers[0]; auto& ue_cc = *ue_db[ue_metric.rnti]->carriers[0];
std::lock_guard<std::mutex> lock(ue_cc.metrics_mutex);
ue_metric.tx_brate = ue_cc.metrics.tx_brate; ue_metric.tx_brate = ue_cc.metrics.tx_brate;
ue_metric.tx_errors = ue_cc.metrics.tx_errors; ue_metric.tx_errors = ue_cc.metrics.tx_errors;
ue_metric.tx_pkts = ue_cc.metrics.tx_pkts; ue_metric.tx_pkts = ue_cc.metrics.tx_pkts;

Loading…
Cancel
Save