From 424eae0095675b2fdb7489c676f5b7648ae63de9 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 16 Dec 2024 14:50:15 +0100 Subject: [PATCH] pkg/lwip: fix adaption to API change of netdev_new_api Since https://github.com/RIOT-OS/RIOT/pull/21012 a netdev in the new API can return > 0 directly in netdev_driver_t::send() to indicate the driver is naturally synchronous and has already completed the transmission. The adaption of lwIP to that API change contained a bug: It handled the case after the thread is already blocked waiting for the signal that is never going to arrive. This is now fixed. --- pkg/lwip/contrib/netdev/lwip_netdev.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/lwip/contrib/netdev/lwip_netdev.c b/pkg/lwip/contrib/netdev/lwip_netdev.c index 592e6e59b8e7..0970b35b5792 100644 --- a/pkg/lwip/contrib/netdev/lwip_netdev.c +++ b/pkg/lwip/contrib/netdev/lwip_netdev.c @@ -298,14 +298,16 @@ static err_t _common_link_output(struct netif *netif, netdev_t *netdev, iolist_t return ERR_IF; } - /* block until TX completion is signaled from IRQ */ - thread_flags_wait_any(THREAD_FLAG_LWIP_TX_DONE); + /* `res > 0` means transmission already completed according to API contract. + * ==> only waiting when res == 0 */ + if (res == 0) { + /* block until TX completion is signaled from IRQ */ + thread_flags_wait_any(THREAD_FLAG_LWIP_TX_DONE); - irq_state = irq_disable(); - compat_netif->thread_doing_tx = NULL; - irq_restore(irq_state); + irq_state = irq_disable(); + compat_netif->thread_doing_tx = NULL; + irq_restore(irq_state); - if (res == 0) { /* async send */ while (-EAGAIN == (res = netdev->driver->confirm_send(netdev, NULL))) { /* this should not happen, as the driver really only should emit the