Expand macro branches to make them plain
This commit is contained in:
parent
25ef8d262a
commit
efd58f19ea
@ -184,32 +184,6 @@ parse_numeric_port(const char *service, int *portp)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GETADDRINFO_IMPL != 0
|
|
||||||
struct getaddrinfo_arg
|
|
||||||
{
|
|
||||||
const char *node;
|
|
||||||
const char *service;
|
|
||||||
const struct addrinfo *hints;
|
|
||||||
struct addrinfo **res;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void *
|
|
||||||
nogvl_getaddrinfo(void *arg)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
struct getaddrinfo_arg *ptr = arg;
|
|
||||||
ret = getaddrinfo(ptr->node, ptr->service, ptr->hints, ptr->res);
|
|
||||||
#ifdef __linux__
|
|
||||||
/* On Linux (mainly Ubuntu 13.04) /etc/nsswitch.conf has mdns4 and
|
|
||||||
* it cause getaddrinfo to return EAI_SYSTEM/ENOENT. [ruby-list:49420]
|
|
||||||
*/
|
|
||||||
if (ret == EAI_SYSTEM && errno == ENOENT)
|
|
||||||
ret = EAI_NONAME;
|
|
||||||
#endif
|
|
||||||
return (void *)(VALUE)ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
numeric_getaddrinfo(const char *node, const char *service,
|
numeric_getaddrinfo(const char *node, const char *service,
|
||||||
const struct addrinfo *hints,
|
const struct addrinfo *hints,
|
||||||
@ -313,12 +287,43 @@ rb_freeaddrinfo(struct rb_addrinfo *ai)
|
|||||||
xfree(ai);
|
xfree(ai);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GETADDRINFO_IMPL == 0
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hints, struct addrinfo **ai)
|
rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hints, struct addrinfo **ai)
|
||||||
{
|
{
|
||||||
#if GETADDRINFO_IMPL == 0
|
|
||||||
return getaddrinfo(hostp, portp, hints, ai);
|
return getaddrinfo(hostp, portp, hints, ai);
|
||||||
#else
|
}
|
||||||
|
|
||||||
|
#elif GETADDRINFO_IMPL == 1
|
||||||
|
|
||||||
|
struct getaddrinfo_arg
|
||||||
|
{
|
||||||
|
const char *node;
|
||||||
|
const char *service;
|
||||||
|
const struct addrinfo *hints;
|
||||||
|
struct addrinfo **res;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void *
|
||||||
|
nogvl_getaddrinfo(void *arg)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
struct getaddrinfo_arg *ptr = arg;
|
||||||
|
ret = getaddrinfo(ptr->node, ptr->service, ptr->hints, ptr->res);
|
||||||
|
#ifdef __linux__
|
||||||
|
/* On Linux (mainly Ubuntu 13.04) /etc/nsswitch.conf has mdns4 and
|
||||||
|
* it cause getaddrinfo to return EAI_SYSTEM/ENOENT. [ruby-list:49420]
|
||||||
|
*/
|
||||||
|
if (ret == EAI_SYSTEM && errno == ENOENT)
|
||||||
|
ret = EAI_NONAME;
|
||||||
|
#endif
|
||||||
|
return (void *)(VALUE)ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hints, struct addrinfo **ai)
|
||||||
|
{
|
||||||
struct getaddrinfo_arg arg;
|
struct getaddrinfo_arg arg;
|
||||||
MEMZERO(&arg, struct getaddrinfo_arg, 1);
|
MEMZERO(&arg, struct getaddrinfo_arg, 1);
|
||||||
arg.node = hostp;
|
arg.node = hostp;
|
||||||
@ -326,10 +331,22 @@ rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hint
|
|||||||
arg.hints = hints;
|
arg.hints = hints;
|
||||||
arg.res = ai;
|
arg.res = ai;
|
||||||
return (int)(VALUE)rb_thread_call_without_gvl(nogvl_getaddrinfo, &arg, RUBY_UBF_IO, 0);
|
return (int)(VALUE)rb_thread_call_without_gvl(nogvl_getaddrinfo, &arg, RUBY_UBF_IO, 0);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GETADDRINFO_IMPL != 0
|
#endif
|
||||||
|
|
||||||
|
#if GETADDRINFO_IMPL == 0
|
||||||
|
|
||||||
|
int
|
||||||
|
rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
|
||||||
|
char *host, size_t hostlen,
|
||||||
|
char *serv, size_t servlen, int flags)
|
||||||
|
{
|
||||||
|
return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif GETADDRINFO_IMPL == 1
|
||||||
|
|
||||||
struct getnameinfo_arg
|
struct getnameinfo_arg
|
||||||
{
|
{
|
||||||
const struct sockaddr *sa;
|
const struct sockaddr *sa;
|
||||||
@ -350,16 +367,11 @@ nogvl_getnameinfo(void *arg)
|
|||||||
ptr->serv, (socklen_t)ptr->servlen,
|
ptr->serv, (socklen_t)ptr->servlen,
|
||||||
ptr->flags);
|
ptr->flags);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
int
|
||||||
rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
|
rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
|
||||||
char *host, size_t hostlen,
|
char *host, size_t hostlen,
|
||||||
char *serv, size_t servlen, int flags)
|
char *serv, size_t servlen, int flags)
|
||||||
{
|
{
|
||||||
#if GETADDRINFO_IMPL == 0
|
|
||||||
return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
|
|
||||||
#else
|
|
||||||
struct getnameinfo_arg arg;
|
struct getnameinfo_arg arg;
|
||||||
int ret;
|
int ret;
|
||||||
arg.sa = sa;
|
arg.sa = sa;
|
||||||
@ -371,9 +383,10 @@ rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
|
|||||||
arg.flags = flags;
|
arg.flags = flags;
|
||||||
ret = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getnameinfo, &arg, RUBY_UBF_IO, 0);
|
ret = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getnameinfo, &arg, RUBY_UBF_IO, 0);
|
||||||
return ret;
|
return ret;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
make_ipaddr0(struct sockaddr *addr, socklen_t addrlen, char *buf, size_t buflen)
|
make_ipaddr0(struct sockaddr *addr, socklen_t addrlen, char *buf, size_t buflen)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user