Merge pull request #3603 from embassy-rs/nrf91-free-bufs
Free tx buffer on ipc send failure
This commit is contained in:
commit
af02310edc
@ -507,6 +507,7 @@ impl StateInner {
|
|||||||
if data.is_empty() {
|
if data.is_empty() {
|
||||||
msg.data = ptr::null_mut();
|
msg.data = ptr::null_mut();
|
||||||
msg.data_len = 0;
|
msg.data_len = 0;
|
||||||
|
self.send_message_raw(msg)
|
||||||
} else {
|
} else {
|
||||||
assert!(data.len() <= TX_BUF_SIZE);
|
assert!(data.len() <= TX_BUF_SIZE);
|
||||||
let buf_idx = self.find_free_tx_buf().ok_or(NoFreeBufs)?;
|
let buf_idx = self.find_free_tx_buf().ok_or(NoFreeBufs)?;
|
||||||
@ -517,10 +518,15 @@ impl StateInner {
|
|||||||
self.tx_buf_used[buf_idx] = true;
|
self.tx_buf_used[buf_idx] = true;
|
||||||
|
|
||||||
fence(Ordering::SeqCst); // synchronize copy_nonoverlapping (non-volatile) with volatile writes below.
|
fence(Ordering::SeqCst); // synchronize copy_nonoverlapping (non-volatile) with volatile writes below.
|
||||||
|
if let Err(e) = self.send_message_raw(msg) {
|
||||||
|
msg.data = ptr::null_mut();
|
||||||
|
msg.data_len = 0;
|
||||||
|
self.tx_buf_used[buf_idx] = false;
|
||||||
|
Err(e)
|
||||||
|
} else {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO free data buf if send_message_raw fails.
|
|
||||||
self.send_message_raw(msg)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_message_raw(&mut self, msg: &Message) -> Result<(), NoFreeBufs> {
|
fn send_message_raw(&mut self, msg: &Message) -> Result<(), NoFreeBufs> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user