Is getaddrinfo() in the SDK thread safe?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Is getaddrinfo() in the SDK thread safe?

跳至解决方案
1,096 次查看
atm2024
Contributor III

Hi everyone,

I'm trying to build an application that uses FreeRTOS and the lwip stack.
I'm using the MIMXRT1064-EVK with version 2.14.0 of the SDK.

Using getaddrinfo() in two tasks at the same time does not work correctly.
If I run freeaddrinfo() after getaddrinfo() in the first task, it works fine in the second task.

Is this behavior as specified?

If I want to use getaddrinfo() at the same time, is there no choice but to use a semaphore or mutex to guard it until freeaddrinfo()?

Thanks in advance.

0 项奖励
回复
1 解答
1,071 次查看
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @atm2024,

This behavior is expected. This is the description that accompanies the function on the netdb.c file:

EdwinHz_0-1709327670570.png

You can use the function in both tasks as long as you call the freeaddrinfo() function for each of the getaddrinfo() before trying to do another getaddrinfo() on the second task.

BR,
Edwin.

 

在原帖中查看解决方案

0 项奖励
回复
1 回复
1,072 次查看
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @atm2024,

This behavior is expected. This is the description that accompanies the function on the netdb.c file:

EdwinHz_0-1709327670570.png

You can use the function in both tasks as long as you call the freeaddrinfo() function for each of the getaddrinfo() before trying to do another getaddrinfo() on the second task.

BR,
Edwin.

 

0 项奖励
回复