net: fix incorrect poll_iface() calls

- poll_iface might be called by interrupt while poll_iface was being called in main loop
- Disable interrupt when poll_iface is being processed
- Only use IfacePollTimer to poll_iface
This commit is contained in:
linuswck 2024-08-27 18:43:20 +08:00
parent c86d67b15c
commit 51913f2e2f
1 changed files with 7 additions and 8 deletions

View File

@ -220,7 +220,9 @@ impl ServerHandle {
}
pub fn poll_iface(&mut self) {
cortex_m::interrupt::free(|_| {
self.iface.poll(now_fn(), &mut &mut self.dma, &mut self.socket_set);
});
}
pub fn poll_at_iface(&mut self) -> Option<Instant> {
@ -246,8 +248,7 @@ impl ServerHandle {
if num_bytes > 0 {
match socket.send_slice(&buffer[..num_bytes]) {
Ok(_) => {
self.poll_iface();
info!("Sent {} bytes.", num_bytes);
info!("Enqueued {} bytes.", num_bytes);
}
Err(err) => {
info!("Bytes cannot be sent. Error: {:?}", err)
@ -515,11 +516,9 @@ pub fn for_each<F: FnMut(SocketHandle, usize)>(mut callback: F) {
#[interrupt]
fn ETH() {
let interrupt_reason = stm32_eth::eth_interrupt_handler();
cortex_m::interrupt::free(|_| {
if interrupt_reason.rx {
eth_poll_iface();
}
});
debug!("Ethernet Interrupt{:?}", interrupt_reason);
}