soylatte and java.net.preferIPv4Stack=true
Landon Fuller
landonf at bikemonkey.org
Sat Dec 8 12:47:15 PST 2007
On Dec 6, 2007, at 8:56 AM, Leif Nelson wrote:
> Also, each subsequent invocation of InetAddress.getLocalHost()
> takes another 8 seconds, and apparently this method is called
> several times! I did some tests on several macs running both Tiger
> & Leopard with java5 and java6 to demonstrate the issue.
> After some tracing with -Djava.net.preferIPv4Stack=true, I found
> that the time is all taken up inside of the native method:
> java.net.Inet4AddressImpl.getLocalHostName().
>
> If I trace with -Djava.net.preferIPv4Stack=false (the default), I
> found that the native method
> java.net.Inet6AddressImpl.getLocalHostName() gets called instead
> returns very quickly.
>
> I hope this narrows it down enough to find out what's wrong. :-)
Thanks!
I tracked it down to this copy/paste bug in the BSD-specific code
(which I believe I wrote some time ago, so it's my bug)
error = getaddrinfo(hostname, "domain", &hints, &res);
The "domain" service argument causes getaddrinfo() on Mac OS X to make
(time consuming) MDNS SRV requests for the service:
12:16:03.619145 IP 10.0.50.246.mdns > 224.0.0.251.mdns: 0 SRV (QM)?
_domain._udp.max.local. (40)
The service argument should have been NULL. I committed a fix for this
upstream, and will include it in the next release:
landonf at max:/tmp> /tmp/j-build/bsd-i586/bin/java -
Djava.net.preferIPv4Stack=true TestHostName
Found: 10.0.50.246 in: 9 ms.
Patch: http://hg.bikemonkey.org/javasrc_1_6_jrl_darwin_stable/rev/219cd1380f35
Thanks again for the report,
-landonf
More information about the porters-dev
mailing list