aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bush <mike.bush@allenvanguard.com>2018-07-24 09:02:13 -0400
committerGarrett D'Amore <garrett@damore.org>2018-07-24 07:55:04 -0700
commit9b9526e4a643d36d9c66f2254f00df7298e5562f (patch)
tree670c64ee70451bbc22ea6e3f8bdcf49dc38d8815
parent0a746ae40b4a06e278f9f11db9e00d09ed4df868 (diff)
downloadnng-9b9526e4a643d36d9c66f2254f00df7298e5562f.tar.gz
nng-9b9526e4a643d36d9c66f2254f00df7298e5562f.tar.bz2
nng-9b9526e4a643d36d9c66f2254f00df7298e5562f.zip
Modified code to explicitly set hints.ai_socktype passed to getaddrinfo(). On QNX, specifying a numeric servname while leaving ai_socktype unspecified would result in EAI_SERVICE.
-rw-r--r--src/platform/posix/posix_resolv_gai.c21
-rw-r--r--src/platform/windows/win_resolv.c21
2 files changed, 24 insertions, 18 deletions
diff --git a/src/platform/posix/posix_resolv_gai.c b/src/platform/posix/posix_resolv_gai.c
index f78d0b6b..aea823a0 100644
--- a/src/platform/posix/posix_resolv_gai.c
+++ b/src/platform/posix/posix_resolv_gai.c
@@ -50,6 +50,7 @@ struct resolv_item {
int passive;
const char * name;
int proto;
+ int socktype;
uint16_t port;
nni_aio * aio;
nng_sockaddr sa;
@@ -138,6 +139,7 @@ resolv_task(resolv_item *item)
}
hints.ai_protocol = item->proto;
hints.ai_family = item->family;
+ hints.ai_socktype = item->socktype;
// We can pass any non-zero service number, but we have to pass
// *something*, in case we are using a NULL hostname.
@@ -191,7 +193,7 @@ done:
static void
resolv_ip(const char *host, const char *serv, int passive, int family,
- int proto, nni_aio *aio)
+ int proto, int socktype, nni_aio *aio)
{
resolv_item *item;
sa_family_t fam;
@@ -249,12 +251,13 @@ resolv_ip(const char *host, const char *serv, int passive, int family,
// NB: host and serv must remain valid until this is completed.
memset(&item->sa, 0, sizeof(item->sa));
- item->name = host;
- item->proto = proto;
- item->aio = aio;
- item->family = fam;
- item->passive = passive;
- item->port = htons((uint16_t) port);
+ item->name = host;
+ item->proto = proto;
+ item->aio = aio;
+ item->family = fam;
+ item->passive = passive;
+ item->socktype = socktype;
+ item->port = htons((uint16_t) port);
nni_mtx_lock(&resolv_mtx);
if (resolv_fini) {
@@ -277,14 +280,14 @@ void
nni_tcp_resolv(
const char *host, const char *serv, int family, int passive, nni_aio *aio)
{
- resolv_ip(host, serv, passive, family, IPPROTO_TCP, aio);
+ resolv_ip(host, serv, passive, family, IPPROTO_TCP, SOCK_STREAM, aio);
}
void
nni_udp_resolv(
const char *host, const char *serv, int family, int passive, nni_aio *aio)
{
- resolv_ip(host, serv, passive, family, IPPROTO_UDP, aio);
+ resolv_ip(host, serv, passive, family, IPPROTO_UDP, SOCK_DGRAM, aio);
}
void
diff --git a/src/platform/windows/win_resolv.c b/src/platform/windows/win_resolv.c
index 916f54b1..cc876d04 100644
--- a/src/platform/windows/win_resolv.c
+++ b/src/platform/windows/win_resolv.c
@@ -38,6 +38,7 @@ struct resolv_item {
int passive;
const char * name;
int proto;
+ int socktype;
uint16_t port;
nni_aio * aio;
nng_sockaddr sa;
@@ -115,6 +116,7 @@ resolv_task(resolv_item *item)
}
hints.ai_protocol = item->proto;
hints.ai_family = item->family;
+ hints.ai_socktype = item->socktype;
if ((rv = getaddrinfo(item->name, "80", &hints, &results)) != 0) {
rv = resolv_errno(rv);
@@ -165,7 +167,7 @@ done:
static void
resolv_ip(const char *host, const char *serv, int passive, int family,
- int proto, nni_aio *aio)
+ int proto, int socktype, nni_aio *aio)
{
resolv_item *item;
int fam;
@@ -222,12 +224,13 @@ resolv_ip(const char *host, const char *serv, int passive, int family,
return;
}
memset(&item->sa, 0, sizeof(item->sa));
- item->passive = passive;
- item->name = host;
- item->proto = proto;
- item->aio = aio;
- item->family = fam;
- item->port = htons((uint16_t) port);
+ item->passive = passive;
+ item->name = host;
+ item->proto = proto;
+ item->aio = aio;
+ item->family = fam;
+ item->socktype = socktype;
+ item->port = htons((uint16_t) port);
nni_mtx_lock(&resolv_mtx);
if (resolv_fini) {
@@ -250,14 +253,14 @@ void
nni_tcp_resolv(
const char *host, const char *serv, int family, int passive, nni_aio *aio)
{
- resolv_ip(host, serv, passive, family, IPPROTO_TCP, aio);
+ resolv_ip(host, serv, passive, family, IPPROTO_TCP, SOCK_STREAM, aio);
}
void
nni_udp_resolv(
const char *host, const char *serv, int family, int passive, nni_aio *aio)
{
- resolv_ip(host, serv, passive, family, IPPROTO_UDP, aio);
+ resolv_ip(host, serv, passive, family, IPPROTO_UDP, SOCK_DGRAM, aio);
}
void