From 3768ee9e0eb51649b75cdf283cceedeb62d574fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Caruso?= <niccolo.caruso@skywarder.eu> Date: Tue, 14 Jan 2025 12:32:04 +0100 Subject: [PATCH] [WIZ5500, FIX] Enforcing exit from recv when timeout expires There were missing checks with the timeout to exit from the recv function --- src/shared/drivers/WIZ5500/WIZ5500.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/shared/drivers/WIZ5500/WIZ5500.cpp b/src/shared/drivers/WIZ5500/WIZ5500.cpp index 4f0159743..bf272bb5f 100644 --- a/src/shared/drivers/WIZ5500/WIZ5500.cpp +++ b/src/shared/drivers/WIZ5500/WIZ5500.cpp @@ -25,6 +25,7 @@ #include <drivers/interrupt/external_interrupts.h> #include <interfaces/endianness.h> #include <kernel/scheduler/scheduler.h> +#include <utils/Debug.h> #include <utils/KernelTime.h> #include "WIZ5500Defs.h" @@ -464,6 +465,8 @@ int Wiz5500::waitForSocketIrq(miosix::Lock<miosix::FastMutex>& l, int sock_n, while (wait_infos[i].irq == 0 && result == TimedWaitResult::NoTimeout && interrupt_service_thread != this_thread) { + if (Kernel::getOldTick() > start + timeout) + break; if (timeout != -1) { result = Kernel::Thread::IRQenableIrqAndTimedWaitMs( @@ -484,6 +487,9 @@ int Wiz5500::waitForSocketIrq(miosix::Lock<miosix::FastMutex>& l, int sock_n, while (interrupt_service_thread == this_thread) { + if (Kernel::getOldTick() > start + timeout) + break; + // Run a single step of the ISR if (timeout == -1) result = runInterruptServiceRoutine(l, -1); -- GitLab