enb,mac: protect concurrent access to ue_db from different threads

race condition between PHY worker(s) and Stack thread when
accessing ue_db member. RWlock needs to be hold.

partly fixes #2932
master
Andre Puschmann 4 years ago
parent 3df72cb6ab
commit 80a89ec4bf

@ -126,6 +126,7 @@ void mac::reset()
void mac::start_pcap(srsran::mac_pcap* pcap_)
{
srsran::rwlock_read_guard lock(rwlock);
pcap = pcap_;
// Set pcap in all UEs for UL messages
for (auto& u : ue_db) {
@ -135,6 +136,7 @@ void mac::start_pcap(srsran::mac_pcap* pcap_)
void mac::start_pcap_net(srsran::mac_pcap_net* pcap_net_)
{
srsran::rwlock_read_guard lock(rwlock);
pcap_net = pcap_net_;
// Set pcap in all UEs for UL messages
for (auto& u : ue_db) {
@ -292,6 +294,7 @@ void mac::toggle_padding()
void mac::add_padding()
{
srsran::rwlock_read_guard lock(rwlock);
for (auto it = ue_db.begin(); it != ue_db.end(); ++it) {
uint16_t cur_rnti = it->first;
auto ue = it;
@ -817,6 +820,7 @@ void mac::build_mch_sched(uint32_t tbs)
int mac::get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_list_t& dl_sched_res_list)
{
srsran::rwlock_read_guard lock(rwlock);
dl_sched_t* dl_sched_res = &dl_sched_res_list[0];
logger.set_context(tti);
srsran_ra_tb_t mcs = {};
@ -930,6 +934,8 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list)
logger.set_context(TTI_SUB(tti_tx_ul, FDD_HARQ_DELAY_UL_MS + FDD_HARQ_DELAY_DL_MS));
srsran::rwlock_read_guard lock(rwlock);
// Execute UE FSMs (e.g. TA)
for (auto& ue : ue_db) {
ue.second->tic();
@ -945,9 +951,6 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list)
return SRSRAN_ERROR;
}
{
srsran::rwlock_read_guard lock(rwlock);
// Copy DCI grants
phy_ul_sched_res->nof_grants = 0;
int n = 0;
@ -990,9 +993,6 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list)
}
}
// No more uses of ue_db beyond here
}
// Copy PHICH actions
for (uint32_t i = 0; i < sched_result.phich.size(); i++) {
phy_ul_sched_res->phich[i].ack = sched_result.phich[i].phich == sched_interface::ul_sched_phich_t::ACK;
@ -1023,6 +1023,7 @@ void mac::write_mcch(const srsran::sib2_mbms_t* sib2_,
const uint8_t* mcch_payload,
const uint8_t mcch_payload_length)
{
srsran::rwlock_write_guard lock(rwlock);
mcch = *mcch_;
mch.num_mtch_sched = this->mcch.pmch_info_list[0].nof_mbms_session_info;
for (uint32_t i = 0; i < mch.num_mtch_sched; ++i) {
@ -1038,6 +1039,7 @@ void mac::write_mcch(const srsran::sib2_mbms_t* sib2_,
rrc_h->add_user(SRSRAN_MRNTI, {});
}
// Internal helper function, caller must hold UE DB rwlock
bool mac::check_ue_exists(uint16_t rnti)
{
if (not ue_db.contains(rnti)) {

Loading…
Cancel
Save