Skip to content

zsock_getaddrinfo() is not reentrant #8183

@andrewboie

Description

@andrewboie

This function uses globals for the returned address information (ai_arr) as well as a global for the state of the getaddrinfo function (ai_state). This presents some problems:

  1. Multiple threads calling zsock_getaddrinfo() concurrently could lead to data corruption, either in ai_state or ai_arr or both. ai_state could be moved onto zsock_getaddrinfo's stack instead of being a global, but ai_arr is more complicated.
  2. The returned "res" pointer is supposed to be allocated. Right now, we cannot expose zsock_getaddrinfo() to user mode as user mode would not have access to ai_arr. What we need is something like malloc()/free() in minimal libc, possibly backed with the sys_mem_pool implementation.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions