Skip to content

Commit

Permalink
NameResolutionPal.Unix: fixed loss of address family information in a…
Browse files Browse the repository at this point in the history
…sync lookup (#47171)

* Removed dead code from SystemNative_GetHostEntryForNameAsync

* Fixed loss of address-family
  • Loading branch information
gfoidl authored Jan 22, 2021
1 parent d0b10ed commit 2f25931
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions src/libraries/Native/Unix/System.Native/pal_networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,12 +601,6 @@ int32_t SystemNative_GetHostEntryForNameAsync(const uint8_t* address, int32_t ad
return GetAddrInfoErrorFlags_EAI_BADARG;
}

sa_family_t platformFamily;
if (!TryConvertAddressFamilyPalToPlatform(addressFamily, &platformFamily))
{
return GetAddrInfoErrorFlags_EAI_FAMILY;
}

struct GetAddrInfoAsyncState* state = malloc(sizeof(*state) + addrlen + 1);

if (state == NULL)
Expand All @@ -622,24 +616,22 @@ int32_t SystemNative_GetHostEntryForNameAsync(const uint8_t* address, int32_t ad

memcpy(state->address, address, addrlen + 1);

*state = (struct GetAddrInfoAsyncState) {
.gai_request = {
.ar_name = state->address,
.ar_service = NULL,
.ar_request = &state->hint,
.ar_result = NULL
},
.gai_requests = &state->gai_request,
.sigevent = {
.sigev_notify = SIGEV_THREAD,
.sigev_value = {
.sival_ptr = state
},
.sigev_notify_function = GetHostEntryForNameAsyncComplete
state->gai_request = (struct gaicb) {
.ar_name = state->address,
.ar_service = NULL,
.ar_request = &state->hint,
.ar_result = NULL
};
state->gai_requests = &state->gai_request;
state->sigevent = (struct sigevent) {
.sigev_notify = SIGEV_THREAD,
.sigev_value = {
.sival_ptr = state
},
.entry = entry,
.callback = callback
.sigev_notify_function = GetHostEntryForNameAsyncComplete
};
state->entry = entry;
state->callback = callback;

atomic_thread_fence(memory_order_release);

Expand Down

0 comments on commit 2f25931

Please sign in to comment.