diff --git a/src/api/tcpip.c b/src/api/tcpip.c index e9d3ad77..4dfeabd3 100644 --- a/src/api/tcpip.c +++ b/src/api/tcpip.c @@ -65,6 +65,13 @@ static sys_mbox_t mbox; sys_mutex_t lock_tcpip_core; #endif /* LWIP_TCPIP_CORE_LOCKING */ +#if LWIP_TIMERS +/* wait for a message, timeouts are processed while waiting */ +#define TCPIP_MBOX_FETCH(mbox, msg) sys_timeouts_mbox_fetch(mbox, msg) +#else /* LWIP_TIMERS */ +/* wait for a message with timers disabled (e.g. pass a timer-check trigger into tcpip_thread) */ +#define TCPIP_MBOX_FETCH(mbox, msg) sys_mbox_fetch(mbox, msg) +#endif /* LWIP_TIMERS */ /** * The main lwIP thread. This thread has exclusive access to lwIP core functions @@ -91,7 +98,7 @@ tcpip_thread(void *arg) UNLOCK_TCPIP_CORE(); LWIP_TCPIP_THREAD_ALIVE(); /* wait for a message, timeouts are processed while waiting */ - sys_timeouts_mbox_fetch(&mbox, (void **)&msg); + TCPIP_MBOX_FETCH(&mbox, (void **)&msg); LOCK_TCPIP_CORE(); if (msg == NULL) { LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: invalid message: NULL\n")); @@ -119,7 +126,7 @@ tcpip_thread(void *arg) break; #endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */ -#if LWIP_TCPIP_TIMEOUT +#if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS case TCPIP_MSG_TIMEOUT: LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: TIMEOUT %p\n", (void *)msg)); sys_timeout(msg->msg.tmo.msecs, msg->msg.tmo.h, msg->msg.tmo.arg); @@ -130,7 +137,7 @@ tcpip_thread(void *arg) sys_untimeout(msg->msg.tmo.h, msg->msg.tmo.arg); memp_free(MEMP_TCPIP_MSG_API, msg); break; -#endif /* LWIP_TCPIP_TIMEOUT */ +#endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */ case TCPIP_MSG_CALLBACK: LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK %p\n", (void *)msg)); @@ -249,7 +256,7 @@ tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block) return ERR_OK; } -#if LWIP_TCPIP_TIMEOUT +#if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS /** * call sys_timeout in tcpip_thread * @@ -304,7 +311,7 @@ tcpip_untimeout(sys_timeout_handler h, void *arg) sys_mbox_post(&mbox, msg); return ERR_OK; } -#endif /* LWIP_TCPIP_TIMEOUT */ +#endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */ /** diff --git a/src/include/lwip/priv/tcpip_priv.h b/src/include/lwip/priv/tcpip_priv.h index b6e42935..5fc80f3f 100644 --- a/src/include/lwip/priv/tcpip_priv.h +++ b/src/include/lwip/priv/tcpip_priv.h @@ -112,10 +112,10 @@ enum tcpip_msg_type { TCPIP_MSG_API, TCPIP_MSG_API_CALL, TCPIP_MSG_INPKT, -#if LWIP_TCPIP_TIMEOUT +#if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS TCPIP_MSG_TIMEOUT, TCPIP_MSG_UNTIMEOUT, -#endif /* LWIP_TCPIP_TIMEOUT */ +#endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */ TCPIP_MSG_CALLBACK, TCPIP_MSG_CALLBACK_STATIC }; @@ -141,13 +141,13 @@ struct tcpip_msg { tcpip_callback_fn function; void *ctx; } cb; -#if LWIP_TCPIP_TIMEOUT +#if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS struct { u32_t msecs; sys_timeout_handler h; void *arg; } tmo; -#endif /* LWIP_TCPIP_TIMEOUT */ +#endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */ } msg; }; diff --git a/src/include/lwip/tcpip.h b/src/include/lwip/tcpip.h index dc060b20..404a4a2c 100644 --- a/src/include/lwip/tcpip.h +++ b/src/include/lwip/tcpip.h @@ -90,10 +90,10 @@ err_t tcpip_trycallback(struct tcpip_callback_msg* msg); err_t pbuf_free_callback(struct pbuf *p); err_t mem_free_callback(void *m); -#if LWIP_TCPIP_TIMEOUT +#if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg); err_t tcpip_untimeout(sys_timeout_handler h, void *arg); -#endif /* LWIP_TCPIP_TIMEOUT */ +#endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */ #ifdef __cplusplus }