enb,mac: fix concurrent access to cell structs

this patch moves the rwlock that protects the UE database outside
to also protect the cell struct.

It also adds a missing write guard when setting the cell
master
Andre Puschmann 3 years ago
parent ff72c78745
commit 4b069d9b86

@ -228,6 +228,7 @@ int mac::ue_set_crnti(uint16_t temp_crnti, uint16_t crnti, const sched_interface
int mac::cell_cfg(const std::vector<sched_interface::cell_cfg_t>& cell_cfg_) int mac::cell_cfg(const std::vector<sched_interface::cell_cfg_t>& cell_cfg_)
{ {
srsran::rwlock_write_guard lock(rwlock);
cell_config = cell_cfg_; cell_config = cell_cfg_;
return scheduler.cell_cfg(cell_config); return scheduler.cell_cfg(cell_config);
} }
@ -576,6 +577,8 @@ int mac::get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res_list)
add_padding(); add_padding();
} }
srsran::rwlock_read_guard lock(rwlock);
for (uint32_t enb_cc_idx = 0; enb_cc_idx < cell_config.size(); enb_cc_idx++) { for (uint32_t enb_cc_idx = 0; enb_cc_idx < cell_config.size(); enb_cc_idx++) {
// Run scheduler with current info // Run scheduler with current info
sched_interface::dl_sched_res_t sched_result = {}; sched_interface::dl_sched_res_t sched_result = {};
@ -587,9 +590,6 @@ int mac::get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res_list)
int n = 0; int n = 0;
dl_sched_t* dl_sched_res = &dl_sched_res_list[enb_cc_idx]; dl_sched_t* dl_sched_res = &dl_sched_res_list[enb_cc_idx];
{
srsran::rwlock_read_guard lock(rwlock);
// Copy data grants // Copy data grants
for (uint32_t i = 0; i < sched_result.data.size(); i++) { for (uint32_t i = 0; i < sched_result.data.size(); i++) {
uint32_t tb_count = 0; uint32_t tb_count = 0;
@ -648,9 +648,6 @@ int mac::get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res_list)
} }
} }
// No more uses of shared ue_db beyond here
}
// Copy RAR grants // Copy RAR grants
for (uint32_t i = 0; i < sched_result.rar.size(); i++) { for (uint32_t i = 0; i < sched_result.rar.size(); i++) {
// Copy dci info // Copy dci info
@ -728,12 +725,9 @@ int mac::get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res_list)
} }
// Count number of TTIs for all active users // Count number of TTIs for all active users
{
srsran::rwlock_read_guard lock(rwlock);
for (auto& u : ue_db) { for (auto& u : ue_db) {
u.second->metrics_cnt(); u.second->metrics_cnt();
} }
}
return SRSRAN_SUCCESS; return SRSRAN_SUCCESS;
} }

Loading…
Cancel
Save