Fix a nasty data race in the ue_bearer_manager class. The underlying std::map member was being accessed concurrently potentially corrupting memory.

master
faluco 3 years ago committed by faluco
parent c2b705c5ce
commit d2f09a8d3c

@ -104,11 +104,23 @@ public:
/// All registered bearer are removed (e.g. after connection release) /// All registered bearer are removed (e.g. after connection release)
void reset(); void reset();
bool has_active_radio_bearer(uint32_t eps_bearer_id) { return impl.has_active_radio_bearer(eps_bearer_id); } bool has_active_radio_bearer(uint32_t eps_bearer_id)
{
radio_bearer_t get_radio_bearer(uint32_t eps_bearer_id) { return impl.get_radio_bearer(eps_bearer_id); } srsran::rwlock_read_guard rw_lock(rwlock);
return impl.has_active_radio_bearer(eps_bearer_id);
radio_bearer_t get_lcid_bearer(uint32_t lcid) { return impl.get_lcid_bearer(lcid); } }
radio_bearer_t get_radio_bearer(uint32_t eps_bearer_id)
{
srsran::rwlock_read_guard rw_lock(rwlock);
return impl.get_radio_bearer(eps_bearer_id);
}
radio_bearer_t get_lcid_bearer(uint32_t lcid)
{
srsran::rwlock_read_guard rw_lock(rwlock);
return impl.get_lcid_bearer(lcid);
}
private: private:
pthread_rwlock_t rwlock = {}; /// RW lock to protect access from RRC/GW threads pthread_rwlock_t rwlock = {}; /// RW lock to protect access from RRC/GW threads

@ -102,6 +102,7 @@ void ue_bearer_manager::remove_eps_bearer(uint8_t eps_bearer_id)
void ue_bearer_manager::reset() void ue_bearer_manager::reset()
{ {
srsran::rwlock_write_guard rw_lock(rwlock);
impl.reset(); impl.reset();
logger.info("Bearers: Reset EPS bearer manager"); logger.info("Bearers: Reset EPS bearer manager");
} }

Loading…
Cancel
Save