Bugs: Browse | Submit New | Admin

[#5627] gem_server fails with getnameinfo: ai_family not supported

Date:
2006-09-05 05:48
Priority:
3
Submitted By:
Roy Wright (royw)
Assigned To:
Eric Hodel (drbrain)
Category:
Network / Comm / Protocols
State:
Open
Platform:
 
Summary:
gem_server fails with getnameinfo: ai_family not supported

Detailed description
system info:
gentoo x86
dev-lang/ruby-1.8.5  USE="doc examples socks5 tcltk threads -cjk -debug -ipv6"

If gem_server is ran on a system without IPV6 support it will generate the following error:

2006-09-04 16:49:30] INFO  WEBrick 1.3.1
[2006-09-04 16:49:30] INFO  ruby 1.8.5 (2006-08-25) [i686-linux]
/usr/lib/ruby/1.8/webrick/utils.rb:63:in `getaddrinfo': getnameinfo: ai_family
not supported (SocketError)
        from /usr/lib/ruby/1.8/webrick/utils.rb:63:in `create_listeners'
        from /usr/lib/ruby/1.8/webrick/server.rb:75:in `listen'
        from /usr/lib/ruby/1.8/webrick/server.rb:63:in `initialize'
        from /usr/lib/ruby/1.8/webrick/httpserver.rb:24:in `initialize'
        from /usr/bin/gem_server:351:in `new'
        from /usr/bin/gem_server:351

The cause is this line in /usr/lib/ruby/1.8/webrick/utils.rb:

      res = Socket::getaddrinfo(address, port,
                                Socket::AF_UNSPEC,   # address family
                                Socket::SOCK_STREAM, # socket type
                                0,                   # protocol
                                Socket::AI_PASSIVE)  # flag

The problem is the Socket::AF_UNSPEC which is apparently causing getaddrinfo to
try some IPv6 processing.  Substituting Socket::AF_INET will let gem_server run just fine.

According to the Socket.getaddrinfo documentation, "You will usually pass either nil or Socket::AF_UNSPEC, allowing
the IPv6 information to be returned first if host is reachable via IPv6, and IPv4 information otherwise."  I think
this is assuming that the underlying OS has IPv6 support.

Thank you,
Roy

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-03-01 05:17
Sender: Eric Hodel

Linux/glibc's getaddrinfo is broken when IPv6 is missing.  Try
either building ruby with these flags:

./configure --enable-ipv6 --with-lookup-order-hack=INET

Or leaving IPv6 in your system.

Originally referenced in this thread, but the rest of the messages
are munged because of crappy HTML:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/48191
Date: 2007-03-01 02:04
Sender: Ryan Davis

possibly/probably related:

http://groups.google.com/group/comp.lang.ruby/browse_thread/threa
d/ff27de64fc8940fc/ba9267aaa8addeda%23ba9267aaa8addeda
Date: 2006-11-02 06:40
Sender: Ryan Davis

I'm going to get eric's eyeballs on this one.

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
category_idMisc / Other Standard Library2007-05-29 21:46zenspider
assigned_tozenspider2007-03-20 00:30zenspider
assigned_tonone2006-11-02 06:40zenspider