From a0e62f665f5063991b43bebda51057a2286e07ad Mon Sep 17 00:00:00 2001 From: liuxinaliang Date: Sun, 29 Dec 2019 15:32:27 +0800 Subject: [PATCH] [net][lwip] fix assert in the sys_arch_mbox_fetch function when close socket --- components/net/lwip-1.4.1/src/arch/sys_arch.c | 12 ++++-------- components/net/lwip-2.0.2/src/arch/sys_arch.c | 13 +++++-------- components/net/lwip-2.1.0/src/arch/sys_arch.c | 15 ++++++--------- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/components/net/lwip-1.4.1/src/arch/sys_arch.c b/components/net/lwip-1.4.1/src/arch/sys_arch.c index c31bd59c1d..2392dde2fa 100644 --- a/components/net/lwip-1.4.1/src/arch/sys_arch.c +++ b/components/net/lwip-1.4.1/src/arch/sys_arch.c @@ -27,7 +27,7 @@ * Change Logs: * Date Author Notes * 2012-12-8 Bernard add file header - * export bsd socket symbol for RT-Thread Application Module + * export bsd socket symbol for RT-Thread Application Module * 2017-11-15 Bernard add lock for init_done callback. */ @@ -259,7 +259,7 @@ void sys_sem_signal(sys_sem_t *sem) * * @return If the timeout argument is non-zero, it will return the number of milliseconds * spent waiting for the semaphore to be signaled; If the semaphore isn't signaled - * within the specified time, it will return SYS_ARCH_TIMEOUT; If the thread doesn't + * within the specified time, it will return SYS_ARCH_TIMEOUT; If the thread doesn't * wait for the semaphore, it will return zero */ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout) @@ -498,14 +498,10 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) } ret = rt_mb_recv(*mbox, (rt_ubase_t *)msg, t); - if(ret == -RT_ETIMEOUT) + if(ret != RT_EOK) { return SYS_ARCH_TIMEOUT; } - else - { - LWIP_ASSERT("rt_mb_recv returned with error!", ret == RT_EOK); - } /* get elapse msecond */ tick = rt_tick_get() - tick; @@ -536,7 +532,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg) } else { - if (ret == RT_EOK) + if (ret == RT_EOK) ret = 1; } diff --git a/components/net/lwip-2.0.2/src/arch/sys_arch.c b/components/net/lwip-2.0.2/src/arch/sys_arch.c index b2abaeab54..f7ed6eedec 100644 --- a/components/net/lwip-2.0.2/src/arch/sys_arch.c +++ b/components/net/lwip-2.0.2/src/arch/sys_arch.c @@ -27,7 +27,7 @@ * Change Logs: * Date Author Notes * 2012-12-8 Bernard add file header - * export bsd socket symbol for RT-Thread Application Module + * export bsd socket symbol for RT-Thread Application Module * 2017-11-15 Bernard add lock for init_done callback. */ @@ -270,7 +270,7 @@ void sys_sem_signal(sys_sem_t *sem) * * @return If the timeout argument is non-zero, it will return the number of milliseconds * spent waiting for the semaphore to be signaled; If the semaphore isn't signaled - * within the specified time, it will return SYS_ARCH_TIMEOUT; If the thread doesn't + * within the specified time, it will return SYS_ARCH_TIMEOUT; If the thread doesn't * wait for the semaphore, it will return zero */ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout) @@ -509,12 +509,9 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) } ret = rt_mb_recv(*mbox, (rt_ubase_t *)msg, t); - - if(ret == -RT_ETIMEOUT) - return SYS_ARCH_TIMEOUT; - else + if(ret != RT_EOK) { - LWIP_ASSERT("rt_mb_recv returned with error!", ret == RT_EOK); + return SYS_ARCH_TIMEOUT; } /* get elapse msecond */ @@ -545,7 +542,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg) return SYS_ARCH_TIMEOUT; else { - if (ret == RT_EOK) + if (ret == RT_EOK) ret = 1; } diff --git a/components/net/lwip-2.1.0/src/arch/sys_arch.c b/components/net/lwip-2.1.0/src/arch/sys_arch.c index dc08715ecc..0633501bb6 100755 --- a/components/net/lwip-2.1.0/src/arch/sys_arch.c +++ b/components/net/lwip-2.1.0/src/arch/sys_arch.c @@ -27,7 +27,7 @@ * Change Logs: * Date Author Notes * 2012-12-8 Bernard add file header - * export bsd socket symbol for RT-Thread Application Module + * export bsd socket symbol for RT-Thread Application Module * 2017-11-15 Bernard add lock for init_done callback. * 2018-11-02 MurphyZhao port to lwip2.1.0 */ @@ -78,7 +78,7 @@ static err_t netif_device_init(struct netif *netif) /* copy device flags to netif flags */ netif->flags = ethif->flags; netif->mtu = ETHERNET_MTU; - + /* set output */ netif->output = etharp_output; @@ -278,7 +278,7 @@ void sys_sem_signal(sys_sem_t *sem) * * @return If the timeout argument is non-zero, it will return the number of milliseconds * spent waiting for the semaphore to be signaled; If the semaphore isn't signaled - * within the specified time, it will return SYS_ARCH_TIMEOUT; If the thread doesn't + * within the specified time, it will return SYS_ARCH_TIMEOUT; If the thread doesn't * wait for the semaphore, it will return zero */ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout) @@ -523,12 +523,9 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) } ret = rt_mb_recv(*mbox, (rt_ubase_t *)msg, t); - - if(ret == -RT_ETIMEOUT) - return SYS_ARCH_TIMEOUT; - else + if(ret != RT_EOK) { - LWIP_ASSERT("rt_mb_recv returned with error!", ret == RT_EOK); + return SYS_ARCH_TIMEOUT; } /* get elapse msecond */ @@ -559,7 +556,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg) return SYS_ARCH_TIMEOUT; else { - if (ret == RT_EOK) + if (ret == RT_EOK) ret = 1; }