1
0
Fork 0

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
1 changed files with 10 additions and 8 deletions

View File

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