Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#15528 closed defect (fixed)

ruby @1.8.6-p114 patch to get Ruby's Socket classes to work with getaddrinfo under 10.5.3

Reported by: aguynamedryan+macports@… Owned by: pguyot@…
Priority: Normal Milestone:
Component: ports Version: 1.6.0
Keywords: ruby getaddrinfo 10.5.3 drb TCPServer Cc:
Port:

Description

Kurt Schrader posted in this thread, that after upgrading to Mac OS X 10.5.3 some calls to DRb fail with:

/opt/local/lib/ruby/1.8/drb/drb.rb:865:in `initialize': getaddrinfo:
nodename nor servname provided, or not known (SocketError)
from /opt/local/lib/ruby/1.8/drb/drb.rb:865:in `open'
from /opt/local/lib/ruby/1.8/drb/drb.rb:865:in `open_server'

It appears that Ruby's calls to getaddrinfo which pass "0" for the servname argument are now returning EAI_NONAME instead of 0, which causes ruby to raise a SocketError

Andy Keep discovered that feeding nil in place of of "0" for the service number works:

irb(main):001:0> require 'socket'
=> true
irb(main):011:0> Socket.getaddrinfo(Socket.gethostname, 0, 
Socket::AF_INET, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME)
SocketError: getaddrinfo: nodename nor servname provided, or not known
  from (irb):11:in `getaddrinfo'
  from (irb):11
  from :0
irb(main):012:0> Socket.getaddrinfo(Socket.gethostname, nil, 
Socket::AF_INET, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME)
=> [["AF_INET", 0, "192.168.1.95", "192.168.1.95", 2, 1, 6]]

I have discovered that TCPServer.open('localhost', 0) also fails under 10.5.3 both in MacPorts and in the Ruby installation that ships with Mac OS X Leopard.

I have very little socket programming experience, but I have made a patch that changes Socket's servname argument of "0" and replaces it with NULL before it is passed to getaddrinfo.

I have no idea what unintended effects this might cause, but it seems to have cleared up my problems with DRb and TCPServer for the time being.

Attachments (3)

patch-test_socket.rb (706 bytes) - added by aguynamedryan+macports@… 10 years ago.
Adds a few test cases which expose some of the breakage caused by 10.5.3's change to getaddrinfo
patch-socket.c (1.5 KB) - added by aguynamedryan+macports@… 10 years ago.
Adds a some code that replaces a servname of "0" with NULL before calling getaddrinfo
Portfile-ruby.diff (381 bytes) - added by aguynamedryan+macports@… 10 years ago.
Updated Portfile to apply new patches when compiling on the darwin 9 platform

Download all attachments as: .zip

Change History (7)

Changed 10 years ago by aguynamedryan+macports@…

Attachment: patch-test_socket.rb added

Adds a few test cases which expose some of the breakage caused by 10.5.3's change to getaddrinfo

Changed 10 years ago by aguynamedryan+macports@…

Attachment: patch-socket.c added

Adds a some code that replaces a servname of "0" with NULL before calling getaddrinfo

Changed 10 years ago by aguynamedryan+macports@…

Attachment: Portfile-ruby.diff added

Updated Portfile to apply new patches when compiling on the darwin 9 platform

comment:1 Changed 10 years ago by aguynamedryan+macports@…

Cc: aguynamedryan+macports@… added

Cc Me!

comment:2 Changed 10 years ago by jmroot (Joshua Root)

Cc: aguynamedryan+macports@… removed
Owner: changed from macports-tickets@… to pguyot@…

Assigning to maintainer.

comment:3 Changed 10 years ago by pguyot@…

Resolution: fixed
Status: newclosed

Thanks for the patch. I've included it in r37600.

comment:4 Changed 9 years ago by (none)

Milestone: Port Bugs

Milestone Port Bugs deleted

Note: See TracTickets for help on using tickets.