soylatte and

Landon Fuller landonf at
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, I found  
> that the time is all taken up inside of the native method:  
> If I trace with (the default), I  
> found that the native method  
> 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 > 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 - TestHostName
	Found: in: 9 ms.


Thanks again for the report,

More information about the porters-dev mailing list