From b7fd00c8fa50f592e958540b0604114a6471275f Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 1 Jul 2013 11:05:47 +0000 Subject: * ext/socket/ipsocket.c (init_inetsock_internal): Use an address family for local address wihch is different to the remote address if no other choice. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/socket/ipsocket.c | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 21938a0183..9cc3045b39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jul 1 20:03:39 2013 Tanaka Akira + + * ext/socket/ipsocket.c (init_inetsock_internal): Use an address + family for local address wihch is different to the remote + address if no other choice. + Mon Jul 1 15:05:00 2013 Nobuyoshi Nakada * lib/csv.rb (CSV#<<): use StringIO#set_encoding instead of creating diff --git a/ext/socket/ipsocket.c b/ext/socket/ipsocket.c index 01290cbb8f..a146797dda 100644 --- a/ext/socket/ipsocket.c +++ b/ext/socket/ipsocket.c @@ -68,8 +68,13 @@ init_inetsock_internal(struct inetsock_arg *arg) if (lres->ai_family == res->ai_family) break; } - if (!lres) - continue; + if (!lres) { + if (res->ai_next) + continue; + /* Use a different family local address if no choice, this + * will cause EAFNOSUPPORT. */ + lres = arg->local.res; + } } status = rsock_socket(res->ai_family,res->ai_socktype,res->ai_protocol); syscall = "socket(2)"; -- cgit v1.2.3