فهرست منبع

Merge pull request #3298 from xiangxistu/master

[net][lwip] fix assert in the sys_arch_mbox_fetch function when close socket
Bernard Xiong 5 سال پیش
والد
کامیت
848c3ff02b

+ 4 - 8
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;
     }
 

+ 5 - 8
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;
     }
 

+ 6 - 9
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;
     }
 

+ 6 - 1
components/net/lwip-2.1.0/src/netif/ethernetif.c

@@ -487,8 +487,13 @@ static err_t eth_netif_device_init(struct netif *netif)
 rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flags)
 {
     struct netif* netif;
-
+#if LWIP_NETIF_HOSTNAME
+#define LWIP_HOSTNAME_LEN 16
+    char *hostname = RT_NULL;
+    netif = (struct netif*) rt_malloc (sizeof(struct netif) + LWIP_HOSTNAME_LEN);
+#else
     netif = (struct netif*) rt_malloc (sizeof(struct netif));
+#endif
     if (netif == RT_NULL)
     {
         rt_kprintf("malloc netif failed\n");