From 2db32cd3857cdc52ad8a7ca8fed1196747bdcc7d Mon Sep 17 00:00:00 2001 From: yugui Date: Sun, 4 Jan 2009 06:15:58 +0000 Subject: merges r21278 from trunk into ruby_1_9_1. * ext/socket/socket.c: don't apply socktype hack [ruby-core:184] for sock_s_getaddrinfo. (sock_getaddrinfo): add socktype_hack argument. (sock_addrinfo): call sock_getaddrinfo with socktype_hack. (sock_s_getaddrinfo): call sock_getaddrinfo without socktype_hack. [ruby-dev:37674] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ ext/socket/socket.c | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index fb02b58c67..c769180f23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Jan 2 23:36:10 2009 Tanaka Akira + + * ext/socket/socket.c: don't apply socktype hack [ruby-core:184] for + sock_s_getaddrinfo. + (sock_getaddrinfo): add socktype_hack argument. + (sock_addrinfo): call sock_getaddrinfo with socktype_hack. + (sock_s_getaddrinfo): call sock_getaddrinfo without socktype_hack. + [ruby-dev:37674] + Fri Jan 2 23:33:38 2009 NAKAMURA Usaku * include/ruby/missing.h, sprintf.c: get rid of a warning of VC++. diff --git a/ext/socket/socket.c b/ext/socket/socket.c index c8d55cf37a..563a72679e 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -926,7 +926,7 @@ port_str(VALUE port, char *pbuf, size_t len) #endif static struct addrinfo* -sock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints) +sock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack) { struct addrinfo* res = NULL; char *hostp, *portp; @@ -936,7 +936,7 @@ sock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints) hostp = host_str(host, hbuf, sizeof(hbuf)); portp = port_str(port, pbuf, sizeof(pbuf)); - if (hints->ai_socktype == 0 && hints->ai_flags == 0 && str_isnumber(portp)) { + if (socktype_hack && hints->ai_socktype == 0 && hints->ai_flags == 0 && str_isnumber(portp)) { hints->ai_socktype = SOCK_DGRAM; } @@ -978,7 +978,7 @@ sock_addrinfo(VALUE host, VALUE port, int socktype, int flags) hints.ai_family = AF_UNSPEC; hints.ai_socktype = socktype; hints.ai_flags = flags; - return sock_getaddrinfo(host, port, &hints); + return sock_getaddrinfo(host, port, &hints, 1); } static VALUE @@ -3315,7 +3315,7 @@ sock_s_getaddrinfo(int argc, VALUE *argv) if (!NIL_P(flags)) { hints.ai_flags = NUM2INT(flags); } - res = sock_getaddrinfo(host, port, &hints); + res = sock_getaddrinfo(host, port, &hints, 0); ret = make_addrinfo(res); freeaddrinfo(res); -- cgit v1.2.3