mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/raddrinfo.c (make_inspectname): add a res argument to
suppress numeric inspectname. (init_addrinfo_getaddrinfo): call make_inspectname here. (addrinfo_firstonly_new): follow make_inspectname change. (addrinfo_list_new): ditto. (addrinfo_initialize): follow init_addrinfo_getaddrinfo change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
32bbcc6d52
commit
9cd0874fc2
2 changed files with 34 additions and 5 deletions
|
@ -1,3 +1,12 @@
|
|||
Sat Jan 17 15:01:22 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/raddrinfo.c (make_inspectname): add a res argument to
|
||||
suppress numeric inspectname.
|
||||
(init_addrinfo_getaddrinfo): call make_inspectname here.
|
||||
(addrinfo_firstonly_new): follow make_inspectname change.
|
||||
(addrinfo_list_new): ditto.
|
||||
(addrinfo_initialize): follow init_addrinfo_getaddrinfo change.
|
||||
|
||||
Sat Jan 17 14:52:27 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/mkconstants.rb: don't cause an error for duplicate names.
|
||||
|
|
|
@ -590,13 +590,16 @@ call_getaddrinfo(VALUE node, VALUE service,
|
|||
return res;
|
||||
}
|
||||
|
||||
static VALUE make_inspectname(VALUE node, VALUE service, struct addrinfo *res);
|
||||
|
||||
static void
|
||||
init_addrinfo_getaddrinfo(rb_addrinfo_t *rai, VALUE node, VALUE service,
|
||||
VALUE family, VALUE socktype, VALUE protocol, VALUE flags,
|
||||
VALUE inspectname)
|
||||
VALUE inspectnode, VALUE inspectservice)
|
||||
{
|
||||
struct addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 1);
|
||||
VALUE canonname;
|
||||
VALUE inspectname = rb_str_equal(node, inspectnode) ? Qnil : make_inspectname(inspectnode, inspectservice, res);
|
||||
|
||||
canonname = Qnil;
|
||||
if (res->ai_canonname) {
|
||||
|
@ -612,9 +615,26 @@ init_addrinfo_getaddrinfo(rb_addrinfo_t *rai, VALUE node, VALUE service,
|
|||
}
|
||||
|
||||
static VALUE
|
||||
make_inspectname(VALUE node, VALUE service)
|
||||
make_inspectname(VALUE node, VALUE service, struct addrinfo *res)
|
||||
{
|
||||
VALUE inspectname = Qnil;
|
||||
|
||||
if (res) {
|
||||
char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
|
||||
int ret;
|
||||
ret = rb_getnameinfo(res->ai_addr, res->ai_addrlen, hbuf,
|
||||
sizeof(hbuf), pbuf, sizeof(pbuf),
|
||||
NI_NUMERICHOST|NI_NUMERICSERV);
|
||||
if (ret == 0) {
|
||||
if (TYPE(node) == T_STRING && strcmp(hbuf, RSTRING_PTR(node)) == 0)
|
||||
node = Qnil;
|
||||
if (TYPE(service) == T_STRING && strcmp(pbuf, RSTRING_PTR(service)) == 0)
|
||||
service = Qnil;
|
||||
else if (TYPE(service) == T_FIXNUM && atoi(pbuf) == FIX2INT(service))
|
||||
service = Qnil;
|
||||
}
|
||||
}
|
||||
|
||||
if (TYPE(node) == T_STRING) {
|
||||
inspectname = rb_str_dup(node);
|
||||
}
|
||||
|
@ -648,7 +668,7 @@ addrinfo_firstonly_new(VALUE node, VALUE service, VALUE family, VALUE socktype,
|
|||
|
||||
struct addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 0);
|
||||
|
||||
inspectname = make_inspectname(node, service);
|
||||
inspectname = make_inspectname(node, service, res);
|
||||
|
||||
canonname = Qnil;
|
||||
if (res->ai_canonname) {
|
||||
|
@ -673,7 +693,7 @@ addrinfo_list_new(VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE
|
|||
|
||||
struct addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 0);
|
||||
|
||||
inspectname = make_inspectname(node, service);
|
||||
inspectname = make_inspectname(node, service, res);
|
||||
|
||||
ret = rb_ary_new();
|
||||
for (r = res; r; r = r->ai_next) {
|
||||
|
@ -814,7 +834,7 @@ addrinfo_initialize(int argc, VALUE *argv, VALUE self)
|
|||
init_addrinfo_getaddrinfo(rai, numericnode, service,
|
||||
INT2NUM(i_pfamily ? i_pfamily : af), INT2NUM(i_socktype), INT2NUM(i_protocol),
|
||||
INT2NUM(flags),
|
||||
rb_str_equal(numericnode, nodename) ? Qnil : make_inspectname(nodename, service));
|
||||
nodename, service);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue