Author: markt Date: Sun Nov 23 22:50:54 2014 New Revision: 1641284 URL: http://svn.apache.org/r1641284 Log: Pull up useSendfile
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java 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=1641284&r1=1641283&r2=1641284&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java Sun Nov 23 22:50:54 2014 @@ -199,6 +199,20 @@ public abstract class AbstractEndpoint<S // ----------------------------------------------------------------- Properties /** + * Has the user requested that send file be used where possible? + */ + private boolean useSendfile = true; + public boolean getUseSendfile() { + return useSendfile; + } + public void setUseSendfile(boolean useSendfile) { + this.useSendfile = useSendfile; + } + + + + + /** * Time to wait for the internal executor (if used) to terminate when the * endpoint is stopped in milliseconds. Defaults to 5000 (5 seconds). */ @@ -821,10 +835,6 @@ public abstract class AbstractEndpoint<S } protected abstract Log getLog(); - // Flags to indicate optional feature support - // Some of these are always hard-coded, some are hard-coded to false (i.e. - // the endpoint does not support them) and some are configurable. - public abstract boolean getUseSendfile(); protected LimitLatch initializeConnectionLatch() { if (maxConnections==-1) return null; Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1641284&r1=1641283&r2=1641284&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Sun Nov 23 22:50:54 2014 @@ -144,10 +144,6 @@ public class AprEndpoint extends Abstrac public void setPollTime(int pollTime) { if (pollTime > 0) { this.pollTime = pollTime; } } - /** - * Use sendfile for sending static files. - */ - protected boolean useSendfile = false; /* * When the endpoint is created and configured, the APR library will not * have been initialised. This flag is used to determine if the default @@ -156,12 +152,17 @@ public class AprEndpoint extends Abstrac * by configuration, that configuration will always take priority. */ private boolean useSendFileSet = false; + @Override public void setUseSendfile(boolean useSendfile) { useSendFileSet = true; - this.useSendfile = useSendfile; + super.setUseSendfile(useSendfile); + } + /* + * For internal use to avoid setting the useSendFileSet flag + */ + private void setUseSendfileInternal(boolean useSendfile) { + super.setUseSendfile(useSendfile); } - @Override - public boolean getUseSendfile() { return useSendfile; } /** @@ -457,9 +458,9 @@ public class AprEndpoint extends Abstrac // Enable Sendfile by default if it has not been configured but usage on // systems which don't support it cause major problems if (!useSendFileSet) { - useSendfile = Library.APR_HAS_SENDFILE; - } else if (useSendfile && !Library.APR_HAS_SENDFILE) { - useSendfile = false; + setUseSendfileInternal(Library.APR_HAS_SENDFILE); + } else if (getUseSendfile() && !Library.APR_HAS_SENDFILE) { + setUseSendfileInternal(false); } // Initialize thread count default for acceptor @@ -596,8 +597,8 @@ public class AprEndpoint extends Abstrac } SSLContext.setVerify(sslContext, value, SSLVerifyDepth); // For now, sendfile is not supported with SSL - if (useSendfile) { - useSendfile = false; + if (getUseSendfile()) { + setUseSendfileInternal(false); if (useSendFileSet) { log.warn(sm.getString("endpoint.apr.noSendfileWithSSL")); } @@ -635,7 +636,7 @@ public class AprEndpoint extends Abstrac pollerThread.start(); // Start sendfile thread - if (useSendfile) { + if (getUseSendfile()) { sendfile = new Sendfile(); sendfile.init(); Thread sendfileThread = @@ -701,7 +702,7 @@ public class AprEndpoint extends Abstrac } poller = null; connections.clear(); - if (useSendfile) { + if (getUseSendfile()) { try { sendfile.destroy(); } catch (Exception e) { Modified: tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java?rev=1641284&r1=1641283&r2=1641284&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Sun Nov 23 22:50:54 2014 @@ -74,11 +74,6 @@ public class Nio2Endpoint extends Abstra private AsynchronousServerSocketChannel serverSock = null; /** - * use send file - */ - private boolean useSendfile = true; - - /** * The size of the OOM parachute. */ private int oomParachute = 1024*1024; @@ -160,10 +155,6 @@ public class Nio2Endpoint extends Abstra this.socketProperties = socketProperties; } - public void setUseSendfile(boolean useSendfile) { - this.useSendfile = useSendfile; - } - /** * Is deferAccept supported? */ @@ -462,11 +453,6 @@ public class Nio2Endpoint extends Abstra return socketProperties.getRxBufSize(); } - @Override - public boolean getUseSendfile() { - return useSendfile; - } - public int getOomParachute() { return oomParachute; } Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=1641284&r1=1641283&r2=1641284&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Sun Nov 23 22:50:54 2014 @@ -93,11 +93,6 @@ public class NioEndpoint extends Abstrac private ServerSocketChannel serverSock = null; /** - * use send file - */ - private boolean useSendfile = true; - - /** * The size of the OOM parachute. */ private int oomParachute = 1024*1024; @@ -215,10 +210,6 @@ public class NioEndpoint extends Abstrac this.socketProperties = socketProperties; } - public void setUseSendfile(boolean useSendfile) { - this.useSendfile = useSendfile; - } - /** * Is deferAccept supported? */ @@ -489,11 +480,6 @@ public class NioEndpoint extends Abstrac return selectorPool; } - @Override - public boolean getUseSendfile() { - return useSendfile; - } - public int getOomParachute() { return oomParachute; } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org