Shanks0224 commented on code in PR #22182:
URL: https://github.com/apache/nuttx/pull/22182#discussion_r4676157624
##########
include/netdb.h:
##########
@@ -298,6 +333,47 @@ int getaddrinfo(FAR const char *nodename,
FAR const char *servname,
FAR const struct addrinfo *hints,
FAR struct addrinfo **res);
+
+/* Asynchronous getaddrinfo — getaddrinfo_a() and helpers.
+ *
+ * Two modes of operation:
+ *
+ * 1. Synchronous (GAI_WAIT)
+ * getaddrinfo_a(GAI_WAIT, list, n, NULL) resolves every entry in
+ * list[] in the caller's thread and returns 0. Each gaicb.ar_return
+ * holds the per-request result (0 or an EAI_* error). No worker
+ * thread is created; gai_suspend / gai_cancel are not needed.
+ *
+ * 2. Asynchronous (GAI_NOWAIT)
+ * getaddrinfo_a(GAI_NOWAIT, list, n, sevp) spawns a background
+ * worker thread and returns immediately. The optional sigevent
+ * *sevp fires when the entire batch finishes.
+ *
+ * Poll or wait for individual results with:
+ * gai_error(req) — returns EAI_INPROGRESS while pending,
+ * or the final EAI_* / 0 result.
+ * gai_suspend() — blocks until at least one request completes.
+ * gai_cancel(req) — attempts to cancel (cancels the whole batch).
+ *
+ * IMPORTANT: The gaicb lifetime is owned by the caller. Before
+ * freeing or reusing a gaicb, the caller MUST confirm the request
+ * has finished by calling gai_error() and observing a return value
+ * other than EAI_INPROGRESS. Only then is it safe to free the
+ * gaicb, because the worker thread no longer references it.
+ * Freeing a gaicb while gai_error() still returns EAI_INPROGRESS
+ * is undefined behavior — the worker thread may still be writing
+ * to it.
+ */
+
+#ifndef CONFIG_DISABLE_PTHREAD
Review Comment:
Done: NETDB_GETADDRINFO_A is the single condition for netdb.h, Make.defs,
CMakeLists.txt and libc.csv, and the four functions are in libc.csv (#22242).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]