Author: markt Date: Tue Nov 29 22:08:25 2016 New Revision: 1771963 URL: http://svn.apache.org/viewvc?rev=1771963&view=rev Log: Ensure that the endpoint is able to unlock the acceptor thread during shutdown if the endpoint is configured to listen to any local address of a specific type such as "0.0.0.0" or "::".
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java?rev=1771963&r1=1771962&r2=1771963&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java Tue Nov 29 22:08:25 2016 @@ -19,7 +19,9 @@ package org.apache.tomcat.util.net; import java.io.OutputStreamWriter; import java.net.InetAddress; import java.net.InetSocketAddress; +import java.net.NetworkInterface; import java.util.ArrayList; +import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Set; @@ -764,6 +766,27 @@ public abstract class AbstractEndpoint<S // Need to create a connection to unlock the accept(); if (address == null) { saddr = new InetSocketAddress("localhost", getLocalPort()); + } else if (address.isAnyLocalAddress()) { + // Need a local address of the same type (IPv4 or IPV6) as the + // configured bind address since the connector may be configured + // to not map between types. + InetAddress localAddress = null; + Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); + while (localAddress == null && networkInterfaces.hasMoreElements()) { + NetworkInterface networkInterface = networkInterfaces.nextElement(); + Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses(); + while (localAddress == null && inetAddresses.hasMoreElements()) { + InetAddress inetAddress = inetAddresses.nextElement(); + if (address.getClass().isAssignableFrom(inetAddress.getClass())) { + localAddress = inetAddress; + } + } + } + // Fall-back option + if (localAddress == null) { + saddr = new InetSocketAddress("localhost", getLocalPort()); + } + saddr = new InetSocketAddress(localAddress, getLocalPort()); } else { saddr = new InetSocketAddress(address, getLocalPort()); } Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1771963&r1=1771962&r2=1771963&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Tue Nov 29 22:08:25 2016 @@ -171,6 +171,12 @@ <bug>60409</bug>: When unable to complete sendfile request, ensure the Processor will be added to the cache only once. (markt/violetagg) </fix> + <fix> + Ensure that the endpoint is able to unlock the acceptor thread during + shutdown if the endpoint is configured to listen to any local address + of a specific type such as <code>0.0.0.0</code> or <code>::</code>. + (markt) + </fix> </changelog> </subsection> <subsection name="Web applications"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org