Skip to content

esp32/modsocket: Fix getaddrinfo hints to set AI_CANONNAME. #16210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ports/esp32/modsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ static int mdns_getaddrinfo(const char *host_str, const char *port_str,
#endif // MICROPY_HW_ENABLE_MDNS_QUERIES

static void _getaddrinfo_inner(const mp_obj_t host, const mp_obj_t portx,
const struct addrinfo *hints, struct addrinfo **res) {
struct addrinfo *hints, struct addrinfo **res) {
int retval = 0;

*res = NULL;
Expand All @@ -235,6 +235,9 @@ static void _getaddrinfo_inner(const mp_obj_t host, const mp_obj_t portx,

MP_THREAD_GIL_EXIT();

// The ai_canonname field is used below, so set the hint.
hints->ai_flags |= AI_CANONNAME;

#if MICROPY_HW_ENABLE_MDNS_QUERIES
retval = mdns_getaddrinfo(host_str, port_str, hints, res);
#endif
Expand Down Expand Up @@ -264,7 +267,8 @@ static void _getaddrinfo_inner(const mp_obj_t host, const mp_obj_t portx,
static void _socket_getaddrinfo(const mp_obj_t addrtuple, struct addrinfo **resp) {
mp_obj_t *elem;
mp_obj_get_array_fixed_n(addrtuple, 2, &elem);
_getaddrinfo_inner(elem[0], elem[1], NULL, resp);
struct addrinfo hints = { 0 };
_getaddrinfo_inner(elem[0], elem[1], &hints, resp);
}

static mp_obj_t socket_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
Expand Down
Loading