Fix a long-standing issue with Resolv.getaddress() being broken on Ruby 1.9.1 Windows
git-svn-id: file:///home/svn/framework3/trunk@10544 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
df8b9f8e95
commit
e2ed2f0d75
|
@ -135,11 +135,12 @@ module Socket
|
|||
# Wrapper for Resolv.getaddress that takes special care to see if the
|
||||
# supplied address is already a dotted quad, for instance. This is
|
||||
# necessary to prevent calls to gethostbyaddr (which occurs on windows).
|
||||
# These calls can be quite slow.
|
||||
# These calls can be quite slow. This also fixes an issue with the
|
||||
# Resolv.getaddress() call being non-functional on Ruby 1.9.1 (Win32).
|
||||
#
|
||||
def self.getaddress(addr)
|
||||
begin
|
||||
dotted_ip?(addr) ? addr : Resolv.getaddress(addr)
|
||||
dotted_ip?(addr) ? addr : self.addr_ntoa( ::Socket.gethostbyname(addr)[3] )
|
||||
rescue ::ArgumentError # Win32 bug
|
||||
nil
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue