lwip: check minimum timeout value on sys_timeouts_mbox_fetch
This patch prevents this busyloop to add a check-routine for timeout value
- sem_tickwait's granularity is a MSEC_PER_TICK,
and if timeout value is smaller than MSEC_PER_TICK,
this causes busy loop on sys_arch_sem_wait
#include <net/lwip/pbuf.h>
#include <net/lwip/netif/etharp.h>
+#include <tinyara/clock.h>
+
#if LWIP_DEBUG_TIMERNAMES
#define HANDLER(x) x, #x
#else /* LWIP_DEBUG_TIMERNAMES */
@@ -421,6 +423,12 @@ again:
}
sleeptime = sys_timeouts_sleeptime();
+
+ if (sleeptime > 0 && sleeptime <= MSEC_PER_TICK) {
+ sleeptime = MSEC_PER_TICK;
+ }
+
+
if (sleeptime == 0 || sys_arch_mbox_fetch(mbox, msg, sleeptime) == SYS_ARCH_TIMEOUT) {
/* If a SYS_ARCH_TIMEOUT value is returned, a timeout occurred
before a message could be fetched. */
