Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.3.1
-
Fix Version/s: JRuby 1.7.0.pre1
-
Component/s: Core Classes/Modules
-
Labels:None
-
Patch Submitted:Yes
-
Number of attachments :
Description
Socket::gethostbyname(host_name) finds IP address of host_name and then does reverse DNS lookup for IP address (was traced down using tcpdump on Mac OS X).
If DNS server is not returning reverse DNS name for IP adress, then this method on Mac OS X took about 20 seconds.
Discussed with headius on IRC and here are potential reasons:
headius:http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6413593
headius: it seems that it's not our call to getByName, but a subsequent call to getCanonicalHostName that does it
On MRI it is not doing reverse DNS lookup and always is very fast.
Socket::gethostbyname(Socket::gethostname) call is used in DataObjects drivers and as a result on some machines loading DataObjects JDBC driver could take very long time.
The problem here is that whenever we look up an InetAddress, we build our structure for Ruby with a call to getCanonicalName. But because InetAddress instances are getting created without a name (because they're from the result of an IP lookup) there's no name to return. This results in InetAddress doing a second reverse lookup to turn the IP address back into a name.
We need a better way to get InetAddress and the appropriate hostname (canonical or otherwise) without doing the extra lookup.