pdu_queue must be non-blocking in order to avoid the ue or enb to block in the event of a memory leak and the buffer pool running out of buffers. In that case, the null return shall be handled properly and error logged. This commit restores commit c4c44c33f4.

This commit is contained in:
Ismael Gomez 2021-01-15 10:59:39 +01:00
parent 5391001c46
commit 0780f3caea
2 changed files with 15 additions and 9 deletions

View File

@ -27,19 +27,21 @@ uint8_t* pdu_queue::request(uint32_t len)
ERROR("Error request buffer of invalid size %d. Max bytes %d\n", len, MAX_PDU_LEN);
return NULL;
}
pdu_t* pdu = pool.allocate("pdu_queue::request", true);
if (!pdu) {
// This function must be non-blocking. In case we run out of buffers, it shall handle the error properly
pdu_t* pdu = pool.allocate("pdu_queue::request", false);
if (pdu) {
if ((void*)pdu->ptr != (void*)pdu) {
ERROR("Fatal error in memory alignment in struct pdu_queue::pdu_t\n");
exit(-1);
}
return pdu->ptr;
} else {
if (log_h) {
log_h->error("Not enough buffers for MAC PDU\n");
}
ERROR("Not enough buffers for MAC PDU\n");
return nullptr;
}
if ((void*)pdu->ptr != (void*)pdu) {
ERROR("Fatal error in memory alignment in struct pdu_queue::pdu_t\n");
exit(-1);
}
return pdu->ptr;
}
void pdu_queue::deallocate(const uint8_t* pdu)

View File

@ -907,7 +907,11 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list)
srslte_softbuffer_rx_reset_tbs(phy_ul_sched_res->pusch[n].softbuffer_rx, sched_result.pusch[i].tbs * 8);
}
phy_ul_sched_res->pusch[n].data = ue_db[rnti]->request_buffer(sched_result.pusch[i].tbs);
phy_ul_sched_res->nof_grants++;
if (phy_ul_sched_res->pusch[n].data) {
phy_ul_sched_res->nof_grants++;
} else {
Error("Grant for rnti=0x%x could not be allocated due to lack of buffers\n", rnti);
}
n++;
} else {
Warning("Invalid UL scheduling result. User 0x%x does not exist\n", rnti);