diff --git a/lib/include/srslte/common/pdu.h b/lib/include/srslte/common/pdu.h index f14415058..8907e345d 100644 --- a/lib/include/srslte/common/pdu.h +++ b/lib/include/srslte/common/pdu.h @@ -101,7 +101,7 @@ public: if (nof_subheaders > 0) { nof_subheaders--; } - if (cur_idx > 0) { + if (cur_idx >= 0) { cur_idx--; } } diff --git a/lib/src/common/pdu.cc b/lib/src/common/pdu.cc index efcfb9a5e..c7ccda989 100644 --- a/lib/src/common/pdu.cc +++ b/lib/src/common/pdu.cc @@ -126,7 +126,7 @@ uint8_t* sch_pdu::write_packet(srslte::log* log_h) for (uint32_t i = 0; i < onetwo_padding; i++) { sch_subh padding; padding.set_padding(); - padding.write_subheader(&ptr, false); + padding.write_subheader(&ptr, pdu_len > onetwo_padding ? false : true); } // Then write subheaders for MAC CE diff --git a/srsue/src/stack/mac/mux.cc b/srsue/src/stack/mac/mux.cc index df6a5d4d1..231e14aec 100644 --- a/srsue/src/stack/mac/mux.cc +++ b/srsue/src/stack/mac/mux.cc @@ -326,13 +326,15 @@ bool mux::allocate_sdu(uint32_t lcid, srslte::sch_pdu* pdu_msg, int max_sdu_sz) buffer_state = rlc->get_buffer_state(lcid); } else { - Warning("SDU: rlc_buffer=%d, requested_sdu_len=%d, allocated=%d/%d, remaining=%d\n", + Warning("Couldn't allocate new SDU (rlc_buffer=%d, requested_sdu_len=%d, allocated=%d/%d, remaining=%d)\n", buffer_state, requested_sdu_len, sdu_len, sdu_space, pdu_msg->rem_size()); pdu_msg->del_subh(); + // prevent endless loop + break; } } else { Debug("Couldn't add new MAC subheader (rlc_buffer=%d, requested_sdu_len=%d, sdu_space=%d, remaining=%d)\n",