diff --git a/srsue/src/mac/mux.cc b/srsue/src/mac/mux.cc index 361c0bea4..e59b5dc7c 100644 --- a/srsue/src/mac/mux.cc +++ b/srsue/src/mac/mux.cc @@ -307,11 +307,11 @@ bool mux::sched_sdu(lchid_t *ch, int *sdu_space, int max_sdu_sz) bool mux::allocate_sdu(uint32_t lcid, srslte::sch_pdu* pdu_msg, int max_sdu_sz) { - // Get n-th pending SDU pointer and length - int sdu_len = rlc->get_buffer_state(lcid); - - if (sdu_len > 0) { // there is pending SDU to allocate + bool sdu_added = false; + int sdu_len = rlc->get_buffer_state(lcid); + + while (sdu_len > 0) { // there is pending SDU to allocate int buffer_state = sdu_len; if (sdu_len > max_sdu_sz && max_sdu_sz >= 0) { sdu_len = max_sdu_sz; @@ -326,7 +326,8 @@ bool mux::allocate_sdu(uint32_t lcid, srslte::sch_pdu* pdu_msg, int max_sdu_sz) if (sdu_len > 0) { // new SDU could be added Debug("SDU: allocated lcid=%d, rlc_buffer=%d, allocated=%d/%d, max_sdu_sz=%d, remaining=%d\n", lcid, buffer_state, sdu_len, sdu_space, max_sdu_sz, pdu_msg->rem_size()); - return true; + sdu_len = rlc->get_buffer_state(lcid); + sdu_added = true; } else { Warning("SDU: rlc_buffer=%d, allocated=%d/%d, remaining=%d\n", buffer_state, sdu_len, sdu_space, pdu_msg->rem_size()); @@ -335,7 +336,7 @@ bool mux::allocate_sdu(uint32_t lcid, srslte::sch_pdu* pdu_msg, int max_sdu_sz) } } } - return false; + return sdu_added; } void mux::msg3_flush()