net: disable IRQ when data is being enqueued

- This prevents broken json to be sent out due to IRQ
This commit is contained in:
linuswck 2024-09-04 12:17:55 +08:00
parent 838592c812
commit b763350a8b

View File

@ -246,14 +246,16 @@ impl ServerHandle {
pub fn send(&mut self, buffer: &mut [u8], num_bytes: usize, socket_handles: SocketHandle) {
let socket = self.socket_set.get_mut::<Socket>(socket_handles);
if num_bytes > 0 {
match socket.send_slice(&buffer[..num_bytes]) {
Ok(_) => {
info!("Enqueued {} bytes.", num_bytes);
}
Err(err) => {
info!("Bytes cannot be sent. Error: {:?}", err)
}
};
cortex_m::interrupt::free(|_| {
match socket.send_slice(&buffer[..num_bytes]) {
Ok(_) => {
info!("Enqueued {} bytes.", num_bytes);
}
Err(err) => {
info!("Bytes cannot be sent. Error: {:?}", err)
}
};
});
}
}