mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-25 18:14:53 +00:00
timers: rework the core locking around timers (bug #52719)
Want the core lock held while working on the timer data structures.
This commit is contained in:
parent
04b983b4f3
commit
53499f5e9f
@ -99,11 +99,9 @@ tcpip_thread(void *arg)
|
|||||||
|
|
||||||
LOCK_TCPIP_CORE();
|
LOCK_TCPIP_CORE();
|
||||||
while (1) { /* MAIN Loop */
|
while (1) { /* MAIN Loop */
|
||||||
UNLOCK_TCPIP_CORE();
|
|
||||||
LWIP_TCPIP_THREAD_ALIVE();
|
LWIP_TCPIP_THREAD_ALIVE();
|
||||||
/* wait for a message, timeouts are processed while waiting */
|
/* wait for a message, timeouts are processed while waiting */
|
||||||
TCPIP_MBOX_FETCH(&mbox, (void **)&msg);
|
TCPIP_MBOX_FETCH(&mbox, (void **)&msg);
|
||||||
LOCK_TCPIP_CORE();
|
|
||||||
if (msg == NULL) {
|
if (msg == NULL) {
|
||||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: invalid message: NULL\n"));
|
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: invalid message: NULL\n"));
|
||||||
LWIP_ASSERT("tcpip_thread: invalid message", 0);
|
LWIP_ASSERT("tcpip_thread: invalid message", 0);
|
||||||
|
@ -350,15 +350,7 @@ sys_check_timeouts(void)
|
|||||||
#endif /* LWIP_DEBUG_TIMERNAMES */
|
#endif /* LWIP_DEBUG_TIMERNAMES */
|
||||||
memp_free(MEMP_SYS_TIMEOUT, tmptimeout);
|
memp_free(MEMP_SYS_TIMEOUT, tmptimeout);
|
||||||
if (handler != NULL) {
|
if (handler != NULL) {
|
||||||
#if !NO_SYS
|
|
||||||
/* For LWIP_TCPIP_CORE_LOCKING, lock the core before calling the
|
|
||||||
timeout handler function. */
|
|
||||||
LOCK_TCPIP_CORE();
|
|
||||||
#endif /* !NO_SYS */
|
|
||||||
handler(arg);
|
handler(arg);
|
||||||
#if !NO_SYS
|
|
||||||
UNLOCK_TCPIP_CORE();
|
|
||||||
#endif /* !NO_SYS */
|
|
||||||
}
|
}
|
||||||
LWIP_TCPIP_THREAD_ALIVE();
|
LWIP_TCPIP_THREAD_ALIVE();
|
||||||
}
|
}
|
||||||
@ -416,16 +408,29 @@ sys_timeouts_sleeptime(void)
|
|||||||
void
|
void
|
||||||
sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg)
|
sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg)
|
||||||
{
|
{
|
||||||
u32_t sleeptime;
|
u32_t sleeptime, res;
|
||||||
|
|
||||||
again:
|
again:
|
||||||
|
LWIP_ASSERT_CORE_LOCKED();
|
||||||
|
|
||||||
if (!next_timeout) {
|
if (!next_timeout) {
|
||||||
|
UNLOCK_TCPIP_CORE();
|
||||||
sys_arch_mbox_fetch(mbox, msg, 0);
|
sys_arch_mbox_fetch(mbox, msg, 0);
|
||||||
|
LOCK_TCPIP_CORE();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sleeptime = sys_timeouts_sleeptime();
|
sleeptime = sys_timeouts_sleeptime();
|
||||||
if (sleeptime == 0 || sys_arch_mbox_fetch(mbox, msg, sleeptime) == SYS_ARCH_TIMEOUT) {
|
if (sleeptime == 0) {
|
||||||
|
sys_check_timeouts();
|
||||||
|
/* We try again to fetch a message from the mbox. */
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
|
|
||||||
|
UNLOCK_TCPIP_CORE();
|
||||||
|
res = sys_arch_mbox_fetch(mbox, msg, sleeptime);
|
||||||
|
LOCK_TCPIP_CORE();
|
||||||
|
if (res == SYS_ARCH_TIMEOUT) {
|
||||||
/* If a SYS_ARCH_TIMEOUT value is returned, a timeout occurred
|
/* If a SYS_ARCH_TIMEOUT value is returned, a timeout occurred
|
||||||
before a message could be fetched. */
|
before a message could be fetched. */
|
||||||
sys_check_timeouts();
|
sys_check_timeouts();
|
||||||
|
Loading…
Reference in New Issue
Block a user