mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/socket.c (rb_getaddrinfo): use getaddrinfo with GVL if
getaddrinfo.c/getnameinfo.c is used. They are not thread safe because gethostbyname/gethostbyaddr is used. (rb_getnameinfo): ditto. * extconf.rb: define GETADDRINFO_EMU if getaddrinfo.c/getnameinfo.c is used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e1809a0ced
commit
84775721bc
3 changed files with 23 additions and 0 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
Tue Jan 13 21:38:07 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/socket/socket.c (rb_getaddrinfo): use getaddrinfo with GVL if
|
||||||
|
getaddrinfo.c/getnameinfo.c is used. They are not thread safe
|
||||||
|
because gethostbyname/gethostbyaddr is used.
|
||||||
|
(rb_getnameinfo): ditto.
|
||||||
|
|
||||||
|
* extconf.rb: define GETADDRINFO_EMU if getaddrinfo.c/getnameinfo.c is
|
||||||
|
used.
|
||||||
|
|
||||||
Tue Jan 13 21:28:14 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
Tue Jan 13 21:28:14 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||||
|
|
||||||
* object.c (rb_obj_not_match): rdoc.
|
* object.c (rb_obj_not_match): rdoc.
|
||||||
|
|
|
@ -251,6 +251,7 @@ unless getaddr_info_ok and have_func("getnameinfo", headers) and have_func("geta
|
||||||
$CPPFLAGS="-I. "+$CPPFLAGS
|
$CPPFLAGS="-I. "+$CPPFLAGS
|
||||||
$objs += ["getaddrinfo.#{$OBJEXT}"]
|
$objs += ["getaddrinfo.#{$OBJEXT}"]
|
||||||
$objs += ["getnameinfo.#{$OBJEXT}"]
|
$objs += ["getnameinfo.#{$OBJEXT}"]
|
||||||
|
$defs << "-DGETADDRINFO_EMU"
|
||||||
have_func("inet_ntop") or have_func("inet_ntoa")
|
have_func("inet_ntop") or have_func("inet_ntoa")
|
||||||
have_func("inet_pton") or have_func("inet_aton")
|
have_func("inet_pton") or have_func("inet_aton")
|
||||||
have_func("getservbyport")
|
have_func("getservbyport")
|
||||||
|
|
|
@ -238,6 +238,7 @@ ruby_getnameinfo__aix(const struct sockaddr *sa, size_t salen,
|
||||||
#define close closesocket
|
#define close closesocket
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef GETADDRINFO_EMU
|
||||||
struct getaddrinfo_arg
|
struct getaddrinfo_arg
|
||||||
{
|
{
|
||||||
const char *node;
|
const char *node;
|
||||||
|
@ -253,12 +254,16 @@ nogvl_getaddrinfo(void *arg)
|
||||||
return getaddrinfo(ptr->node, ptr->service,
|
return getaddrinfo(ptr->node, ptr->service,
|
||||||
ptr->hints, ptr->res);
|
ptr->hints, ptr->res);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rb_getaddrinfo(const char *node, const char *service,
|
rb_getaddrinfo(const char *node, const char *service,
|
||||||
const struct addrinfo *hints,
|
const struct addrinfo *hints,
|
||||||
struct addrinfo **res)
|
struct addrinfo **res)
|
||||||
{
|
{
|
||||||
|
#ifdef GETADDRINFO_EMU
|
||||||
|
return getaddrinfo(node, service, hints, res);
|
||||||
|
#else
|
||||||
struct getaddrinfo_arg arg;
|
struct getaddrinfo_arg arg;
|
||||||
int ret;
|
int ret;
|
||||||
arg.node = node;
|
arg.node = node;
|
||||||
|
@ -267,8 +272,10 @@ rb_getaddrinfo(const char *node, const char *service,
|
||||||
arg.res = res;
|
arg.res = res;
|
||||||
ret = BLOCKING_REGION(nogvl_getaddrinfo, &arg);
|
ret = BLOCKING_REGION(nogvl_getaddrinfo, &arg);
|
||||||
return ret;
|
return ret;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef GETADDRINFO_EMU
|
||||||
struct getnameinfo_arg
|
struct getnameinfo_arg
|
||||||
{
|
{
|
||||||
const struct sockaddr *sa;
|
const struct sockaddr *sa;
|
||||||
|
@ -289,12 +296,16 @@ nogvl_getnameinfo(void *arg)
|
||||||
ptr->serv, ptr->servlen,
|
ptr->serv, ptr->servlen,
|
||||||
ptr->flags);
|
ptr->flags);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int
|
static 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)
|
||||||
{
|
{
|
||||||
|
#ifdef GETADDRINFO_EMU
|
||||||
|
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;
|
||||||
|
@ -306,6 +317,7 @@ rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
|
||||||
arg.flags = flags;
|
arg.flags = flags;
|
||||||
ret = BLOCKING_REGION(nogvl_getnameinfo, &arg);
|
ret = BLOCKING_REGION(nogvl_getnameinfo, &arg);
|
||||||
return ret;
|
return ret;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in a new issue