diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2023-10-18 16:19:51 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2023-10-24 12:22:53 +0900 |
commit | 25ef8d262a267d608aa3ac74481b3c3abd75ee34 (patch) | |
tree | a95012df84f7dc0263e0d07518d2b49ec6946d57 /ext/socket | |
parent | 9ce607a8d4944de3ebda23d7879bb60fa74121f0 (diff) |
Refactor GETADDRINFO_IMPL instead of GETADDRINFO_EMU
This is a preparation for introducing cancellable
getaddrinfo/getnameinfo.
Diffstat (limited to 'ext/socket')
-rw-r--r-- | ext/socket/raddrinfo.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index d267274e2d..2c2fe25fc3 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -10,6 +10,17 @@ #include "rubysocket.h" +// GETADDRINFO_IMPL == 0 : call getaddrinfo/getnameinfo directly +// GETADDRINFO_IMPL == 1 : call getaddrinfo/getnameinfo without gvl (but uncancellable) + +#ifndef GETADDRINFO_IMPL +# ifdef GETADDRINFO_EMU +# define GETADDRINFO_IMPL 0 +# else +# define GETADDRINFO_IMPL 1 +# endif +#endif + #if defined(INET6) && (defined(LOOKUP_ORDER_HACK_INET) || defined(LOOKUP_ORDER_HACK_INET6)) #define LOOKUP_ORDERS (sizeof(lookup_order_table) / sizeof(lookup_order_table[0])) static const int lookup_order_table[] = { @@ -173,7 +184,7 @@ parse_numeric_port(const char *service, int *portp) } #endif -#ifndef GETADDRINFO_EMU +#if GETADDRINFO_IMPL != 0 struct getaddrinfo_arg { const char *node; @@ -305,7 +316,7 @@ rb_freeaddrinfo(struct rb_addrinfo *ai) static int rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hints, struct addrinfo **ai) { -#ifdef GETADDRINFO_EMU +#if GETADDRINFO_IMPL == 0 return getaddrinfo(hostp, portp, hints, ai); #else struct getaddrinfo_arg arg; @@ -318,7 +329,7 @@ rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hint #endif } -#ifndef GETADDRINFO_EMU +#if GETADDRINFO_IMPL != 0 struct getnameinfo_arg { const struct sockaddr *sa; @@ -346,7 +357,7 @@ rb_getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) { -#ifdef GETADDRINFO_EMU +#if GETADDRINFO_IMPL == 0 return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags); #else struct getnameinfo_arg arg; |