diff --git a/lib/include/srsran/upper/rlc_am_lte.h b/lib/include/srsran/upper/rlc_am_lte.h index a23a91c2f..c20cd6724 100644 --- a/lib/include/srsran/upper/rlc_am_lte.h +++ b/lib/include/srsran/upper/rlc_am_lte.h @@ -116,13 +116,20 @@ public: void add_pdcp_sdu(uint32_t sn) { - assert(not has_pdcp_sn(sn)); + srsran_assert(not has_pdcp_sn(sn), "Cannot re-add same PDCP SN twice"); + uint32_t sn_idx = get_idx(sn); + if (buffered_pdus[sn_idx].sn != invalid_sn) { + clear_pdcp_sdu(buffered_pdus[sn_idx].sn); + } buffered_pdus[get_idx(sn)].sn = sn; count++; } void clear_pdcp_sdu(uint32_t sn) { - uint32_t sn_idx = get_idx(sn); + uint32_t sn_idx = get_idx(sn); + if (buffered_pdus[sn_idx].sn == invalid_sn) { + return; + } buffered_pdus[sn_idx].sn = invalid_sn; buffered_pdus[sn_idx].fully_acked = false; buffered_pdus[sn_idx].fully_txed = false; diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index 2fc44b46d..6d783eef2 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -2128,6 +2128,7 @@ buffered_pdcp_pdu_list::buffered_pdcp_pdu_list() : buffered_pdus(max_buffer_idx void buffered_pdcp_pdu_list::clear() { + count = 0; for (auto& b : buffered_pdus) { b.sn = invalid_sn; b.fully_acked = false;