Is getaddrinfo() in the SDK thread safe?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is getaddrinfo() in the SDK thread safe?

Jump to solution
1,095 Views
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 Kudos
Reply
1 Solution
1,070 Views
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.

 

View solution in original post

0 Kudos
Reply
1 Reply
1,071 Views
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 Kudos
Reply