On an IPv6-enabled host the normal Java Connectors will bind to the IPv6 unspecified address ::0 (if no address is configured for the Connector element). OTOH APR Connectors will bind only to the IPv4 unspecified address 0.0.0.0 - even on an IPv6-enabled host. IMO it shouldn't depend on the type of connector used to which address(-family) Tomcat binds. Therefore I propose to use APR_INET6 instead of APR_INET as address family when creating the APR endpoint. Since I'm in no way familiar with the Tomcat source, I'm not sure if the trivial change I made to org.apache.tomcat.util.net.AprEndpoint is the right thing at the right place. What I can say after trying out the so-patched Tomcat is the following: - On an IPv6-enabled Linux host, Tomcat's APR Connector bound to ::0. - On an IPv4-only Linux host and an IPv4-only Windows XP host, Tomcat still worked (binding to 0.0.0.0 obviously).
Created attachment 17149 [details] Change AprEndpoint to use APR_INET6 as address family when creating socket
The patch looks reasonable to me, but I would like to do further testing before committing
Upon further testing here, the better solution is to use APR_UNSPEC, which allows for APR to correctly make the required selection. Can you also test with the change of APR_INET -> APR_UNSPEC in your environment as well. I'd like to commit this. Thanks!
(In reply to comment #3) > Upon further testing here, the better solution is to use APR_UNSPEC, which allows for APR to correctly > make the required selection. Can you also test with the change of APR_INET -> APR_UNSPEC in your > environment as well. I'd like to commit this. I seemed to remember that changing APR_INET -> APR_UNSPEC was my first attempt to get the AprEndpoint to listen on IPv6 addresses, and that I dropped it in favour of APR_INET6 for some reason. I just did try APR_UNSPEC again and the JVM crashed on starting up tomcat - so this is obviously the reason I had forgotten about. If the HotSpot error log the JVM writes is of any interest to you, just say so and I'll attach it. System spec: Gentoo Linux with kernel 2.6.15-gentoo-r1 Sun JDK 1.5.0.06 APR 1.2.2 tomcat-native-1.1.1 gcc 3.4.4 Tomcat built today (Jan 28th 2006) from svn
Yes, please attach. I cannot recreate the crash here; using UNSPEC it works as expected.
Created attachment 17525 [details] HotSpot error log of JVM crash when using APR_UNSPEC
Hotspot shows, and others confirm, that the exception is due to several places where the family value is being unduly restrictive. Will be addressed in HEAD.