rlc_am: hold lock while handling new PDUs

This lock was removed in 1cbf7eac because it was considered unneeded.
However, as can be seen in issue #1503, we need to protect the access
to rx_window, for example.

Issue #1503 shows a stack trace where a PHY worker generates a status PDU.
While holding the mutex to access rx_window, the stack thread on the
other hand, happily accesses the rx_window member without acquiring
the lock. This commit protects all handle_*() functions in write_pdu().

This reverts commit 1cbf7eac04.
master
Andre Puschmann 4 years ago
parent e550bf726d
commit 95f5093432

@ -1590,10 +1590,10 @@ void rlc_am_lte::rlc_am_lte_rx::write_pdu(uint8_t* payload, const uint32_t nof_b
pthread_mutex_lock(&mutex);
num_rx_bytes += nof_bytes;
pthread_mutex_unlock(&mutex);
if (rlc_am_is_control_pdu(payload)) {
// unlock mutex and pass to Tx subclass
pthread_mutex_unlock(&mutex);
parent->tx.handle_control_pdu(payload, nof_bytes);
} else {
rlc_amd_pdu_header_t header = {};
@ -1601,6 +1601,7 @@ void rlc_am_lte::rlc_am_lte_rx::write_pdu(uint8_t* payload, const uint32_t nof_b
rlc_am_read_data_pdu_header(&payload, &payload_len, &header);
if (payload_len > nof_bytes) {
log->info("Dropping corrupted PDU (%d B). Remaining length after header %d B.\n", nof_bytes, payload_len);
pthread_mutex_unlock(&mutex);
return;
}
if (header.rf) {
@ -1608,6 +1609,7 @@ void rlc_am_lte::rlc_am_lte_rx::write_pdu(uint8_t* payload, const uint32_t nof_b
} else {
handle_data_pdu(payload, payload_len, header);
}
pthread_mutex_unlock(&mutex);
}
}

Loading…
Cancel
Save