soylatte and java.net.preferIPv4Stack=true
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:
> 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. :-)
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 > 220.127.116.11.mdns: 0 SRV (QM)?
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 -
Found: 10.0.50.246 in: 9 ms.
Thanks again for the report,
More information about the porters-dev