Skip to content

Commit a0e62f6

Browse files
author
liuxinaliang
committed
[net][lwip] fix assert in the sys_arch_mbox_fetch function when close socket
1 parent c232235 commit a0e62f6

File tree

3 files changed

+15
-25
lines changed

3 files changed

+15
-25
lines changed

components/net/lwip-1.4.1/src/arch/sys_arch.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* Change Logs:
2828
* Date Author Notes
2929
* 2012-12-8 Bernard add file header
30-
* export bsd socket symbol for RT-Thread Application Module
30+
* export bsd socket symbol for RT-Thread Application Module
3131
* 2017-11-15 Bernard add lock for init_done callback.
3232
*/
3333

@@ -259,7 +259,7 @@ void sys_sem_signal(sys_sem_t *sem)
259259
*
260260
* @return If the timeout argument is non-zero, it will return the number of milliseconds
261261
* spent waiting for the semaphore to be signaled; If the semaphore isn't signaled
262-
* within the specified time, it will return SYS_ARCH_TIMEOUT; If the thread doesn't
262+
* within the specified time, it will return SYS_ARCH_TIMEOUT; If the thread doesn't
263263
* wait for the semaphore, it will return zero
264264
*/
265265
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)
498498
}
499499

500500
ret = rt_mb_recv(*mbox, (rt_ubase_t *)msg, t);
501-
if(ret == -RT_ETIMEOUT)
501+
if(ret != RT_EOK)
502502
{
503503
return SYS_ARCH_TIMEOUT;
504504
}
505-
else
506-
{
507-
LWIP_ASSERT("rt_mb_recv returned with error!", ret == RT_EOK);
508-
}
509505

510506
/* get elapse msecond */
511507
tick = rt_tick_get() - tick;
@@ -536,7 +532,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
536532
}
537533
else
538534
{
539-
if (ret == RT_EOK)
535+
if (ret == RT_EOK)
540536
ret = 1;
541537
}
542538

components/net/lwip-2.0.2/src/arch/sys_arch.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* Change Logs:
2828
* Date Author Notes
2929
* 2012-12-8 Bernard add file header
30-
* export bsd socket symbol for RT-Thread Application Module
30+
* export bsd socket symbol for RT-Thread Application Module
3131
* 2017-11-15 Bernard add lock for init_done callback.
3232
*/
3333

@@ -270,7 +270,7 @@ void sys_sem_signal(sys_sem_t *sem)
270270
*
271271
* @return If the timeout argument is non-zero, it will return the number of milliseconds
272272
* spent waiting for the semaphore to be signaled; If the semaphore isn't signaled
273-
* within the specified time, it will return SYS_ARCH_TIMEOUT; If the thread doesn't
273+
* within the specified time, it will return SYS_ARCH_TIMEOUT; If the thread doesn't
274274
* wait for the semaphore, it will return zero
275275
*/
276276
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)
509509
}
510510

511511
ret = rt_mb_recv(*mbox, (rt_ubase_t *)msg, t);
512-
513-
if(ret == -RT_ETIMEOUT)
514-
return SYS_ARCH_TIMEOUT;
515-
else
512+
if(ret != RT_EOK)
516513
{
517-
LWIP_ASSERT("rt_mb_recv returned with error!", ret == RT_EOK);
514+
return SYS_ARCH_TIMEOUT;
518515
}
519516

520517
/* get elapse msecond */
@@ -545,7 +542,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
545542
return SYS_ARCH_TIMEOUT;
546543
else
547544
{
548-
if (ret == RT_EOK)
545+
if (ret == RT_EOK)
549546
ret = 1;
550547
}
551548

components/net/lwip-2.1.0/src/arch/sys_arch.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* Change Logs:
2828
* Date Author Notes
2929
* 2012-12-8 Bernard add file header
30-
* export bsd socket symbol for RT-Thread Application Module
30+
* export bsd socket symbol for RT-Thread Application Module
3131
* 2017-11-15 Bernard add lock for init_done callback.
3232
* 2018-11-02 MurphyZhao port to lwip2.1.0
3333
*/
@@ -78,7 +78,7 @@ static err_t netif_device_init(struct netif *netif)
7878
/* copy device flags to netif flags */
7979
netif->flags = ethif->flags;
8080
netif->mtu = ETHERNET_MTU;
81-
81+
8282
/* set output */
8383
netif->output = etharp_output;
8484

@@ -278,7 +278,7 @@ void sys_sem_signal(sys_sem_t *sem)
278278
*
279279
* @return If the timeout argument is non-zero, it will return the number of milliseconds
280280
* spent waiting for the semaphore to be signaled; If the semaphore isn't signaled
281-
* within the specified time, it will return SYS_ARCH_TIMEOUT; If the thread doesn't
281+
* within the specified time, it will return SYS_ARCH_TIMEOUT; If the thread doesn't
282282
* wait for the semaphore, it will return zero
283283
*/
284284
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)
523523
}
524524

525525
ret = rt_mb_recv(*mbox, (rt_ubase_t *)msg, t);
526-
527-
if(ret == -RT_ETIMEOUT)
528-
return SYS_ARCH_TIMEOUT;
529-
else
526+
if(ret != RT_EOK)
530527
{
531-
LWIP_ASSERT("rt_mb_recv returned with error!", ret == RT_EOK);
528+
return SYS_ARCH_TIMEOUT;
532529
}
533530

534531
/* get elapse msecond */
@@ -559,7 +556,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
559556
return SYS_ARCH_TIMEOUT;
560557
else
561558
{
562-
if (ret == RT_EOK)
559+
if (ret == RT_EOK)
563560
ret = 1;
564561
}
565562

0 commit comments

Comments
 (0)