Skip to content

Commit

Permalink
tcpip: fix that TCPIP_CORE_LOCK is not released for LWIP_TIMERS==0
Browse files Browse the repository at this point in the history
See bug #65328

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
  • Loading branch information
goldsimon committed Feb 19, 2024
1 parent e799c26 commit d0efd9e
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/api/tcpip.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,20 @@ sys_mutex_t lock_tcpip_core;
static void tcpip_thread_handle_msg(struct tcpip_msg *msg);

#if !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)

/** Wait for a message with timers disabled (e.g. pass a timer-check trigger into tcpip_thread) */
static void
tcpip_mbox_fetch(sys_mbox_t* mbox, void** msg)
{
LWIP_ASSERT_CORE_LOCKED();

UNLOCK_TCPIP_CORE();
sys_mbox_fetch(mbox, msg);
LOCK_TCPIP_CORE();
}

#else /* !LWIP_TIMERS */
/* wait for a message, timeouts are processed while waiting */
#define TCPIP_MBOX_FETCH(mbox, msg) tcpip_timeouts_mbox_fetch(mbox, msg)

/**
* Wait (forever) for a message to arrive in an mbox.
* While waiting, timeouts are processed.
Expand All @@ -81,7 +90,7 @@ static void tcpip_thread_handle_msg(struct tcpip_msg *msg);
* @param msg the place to store the message
*/
static void
tcpip_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg)
tcpip_mbox_fetch(sys_mbox_t *mbox, void **msg)
{
u32_t sleeptime, res;

Expand Down Expand Up @@ -139,7 +148,7 @@ tcpip_thread(void *arg)
while (1) { /* MAIN Loop */
LWIP_TCPIP_THREAD_ALIVE();
/* wait for a message, timeouts are processed while waiting */
TCPIP_MBOX_FETCH(&tcpip_mbox, (void **)&msg);
tcpip_mbox_fetch(&tcpip_mbox, (void **)&msg);
if (msg == NULL) {
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: invalid message: NULL\n"));
LWIP_ASSERT("tcpip_thread: invalid message", 0);
Expand Down

0 comments on commit d0efd9e

Please sign in to comment.