Skip to content

Commit d8f2d02

Browse files
committed
【修复】部分设备网卡设置 down/up 时导致 check_link 线程重复创建问题
Signed-off-by: chenyong <[email protected]>
1 parent ce5bfc9 commit d8f2d02

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

class/ec20/at_device_ec20.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,14 @@ static int ec20_netdev_check_link_status(struct netdev *netdev)
436436
#define EC20_LINK_THREAD_PRIORITY (RT_THREAD_PRIORITY_MAX - 2)
437437

438438
rt_thread_t tid;
439+
char tname[RT_NAME_MAX] = {0};
439440

440441
RT_ASSERT(netdev);
441442

443+
rt_snprintf(tname, RT_NAME_MAX, "%s", netdev->name);
444+
442445
/* create ec20 link status polling thread */
443-
tid = rt_thread_create("ec20_link", ec20_check_link_status_entry, (void *)netdev,
446+
tid = rt_thread_create(tname, ec20_check_link_status_entry, (void *)netdev,
444447
EC20_LINK_THREAD_STACK_SIZE, EC20_LINK_THREAD_PRIORITY, EC20_LINK_THREAD_TICK);
445448
if (tid != RT_NULL)
446449
{
@@ -886,7 +889,11 @@ static void ec20_init_thread_entry(void *parameter)
886889
{
887890
/* set network interface device status and address information */
888891
ec20_netdev_set_info(device->netdev);
889-
ec20_netdev_check_link_status(device->netdev);
892+
/* check and create link staus sync thread */
893+
if (rt_thread_find(device->netdev->name) == RT_NULL)
894+
{
895+
ec20_netdev_check_link_status(device->netdev);
896+
}
890897

891898
LOG_I("%s device network initialize success.", device->name);
892899
}

class/m26/at_device_m26.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ static int m26_netdev_check_link_status(struct netdev *netdev)
294294

295295
RT_ASSERT(netdev);
296296

297-
rt_snprintf(tname, RT_NAME_MAX, "%s_link", netdev->name);
297+
rt_snprintf(tname, RT_NAME_MAX, "%s", netdev->name);
298298

299299
tid = rt_thread_create(tname, check_link_status_entry, (void *)netdev,
300300
M26_LINK_THREAD_STACK_SIZE, M26_LINK_THREAD_PRIORITY, M26_LINK_THREAD_TICK);
@@ -707,7 +707,11 @@ static void m26_init_thread_entry(void *parameter)
707707
if (result == RT_EOK)
708708
{
709709
m26_netdev_set_info(device->netdev);
710-
m26_netdev_check_link_status(device->netdev);
710+
/* check and create link staus sync thread */
711+
if (rt_thread_find(device->netdev->name) == RT_NULL)
712+
{
713+
m26_netdev_check_link_status(device->netdev);
714+
}
711715

712716
LOG_I("%s device network initialize success.", device->name);
713717
}

class/sim76xx/at_device_sim76xx.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static int sim76xx_netdev_check_link_status(struct netdev *netdev)
277277

278278
RT_ASSERT(netdev);
279279

280-
rt_snprintf(tname, RT_NAME_MAX, "%s_link", netdev->name);
280+
rt_snprintf(tname, RT_NAME_MAX, "%s", netdev->name);
281281

282282
tid = rt_thread_create(tname, check_link_status_entry, (void *)netdev,
283283
SIM76XX_LINK_THREAD_STACK_SIZE, SIM76XX_LINK_THREAD_PRIORITY, SIM76XX_LINK_THREAD_TICK);
@@ -704,7 +704,11 @@ static void sim76xx_init_thread_entry(void *parameter)
704704
{
705705
/* set network interface device status and address information */
706706
sim76xx_netdev_set_info(device->netdev);
707-
sim76xx_netdev_check_link_status(device->netdev);
707+
/* check and create link staus sync thread */
708+
if (rt_thread_find(device->netdev->name) == RT_NULL)
709+
{
710+
sim76xx_netdev_check_link_status(device->netdev);
711+
}
708712

709713
LOG_I("%s device network initialize success!", device->name);
710714
}

class/sim800c/at_device_sim800c.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static int sim800c_netdev_check_link_status(struct netdev *netdev)
298298

299299
RT_ASSERT(netdev);
300300

301-
rt_snprintf(tname, RT_NAME_MAX, "%s_link", netdev->name);
301+
rt_snprintf(tname, RT_NAME_MAX, "%s", netdev->name);
302302

303303
tid = rt_thread_create(tname, check_link_status_entry, (void *) netdev,
304304
SIM800C_LINK_THREAD_STACK_SIZE, SIM800C_LINK_THREAD_PRIORITY, SIM800C_LINK_THREAD_TICK);
@@ -796,7 +796,11 @@ static void sim800c_init_thread_entry(void *parameter)
796796
{
797797
/* set network interface device status and address information */
798798
sim800c_netdev_set_info(device->netdev);
799-
sim800c_netdev_check_link_status(device->netdev);
799+
/* check and create link staus sync thread */
800+
if (rt_thread_find(device->netdev->name) == RT_NULL)
801+
{
802+
sim800c_netdev_check_link_status(device->netdev);
803+
}
800804

801805
LOG_I("%s device network initialize success!", device->name);
802806

0 commit comments

Comments
 (0)