You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/09/06 13:26:31 UTC
svn commit: r1165608 - in /tomcat/trunk/java/org/apache: coyote/http11/
tomcat/util/net/
Author: markt
Date: Tue Sep 6 11:26:30 2011
New Revision: 1165608
URL: http://svn.apache.org/viewvc?rev=1165608&view=rev
Log:
Make keptAlive initialization common between the connectors
Modified:
tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java
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/JIoEndpoint.java
tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1165608&r1=1165607&r2=1165608&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Tue Sep 6 11:26:30 2011
@@ -87,6 +87,16 @@ public abstract class AbstractHttp11Proc
/**
+ * Flag used to indicate that the socket should treat the next request
+ * processed like a keep-alive connection - i.e. one where there may not be
+ * any data to process. The initial value of this flag on entering the
+ * process method is different for connectors that use polling (NIO / APR -
+ * data is always expected) compared to those that use blocking (BIO - data
+ * is only expected if the connection isn't in the keep-alive state).
+ */
+ protected boolean keptAlive;
+
+ /**
* Flag that indicates that send file processing is in progress and that the
* socket should not be returned to the poller (where a poller is used).
*/
Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java?rev=1165608&r1=1165607&r2=1165608&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Tue Sep 6 11:26:30 2011
@@ -184,6 +184,11 @@ public class Http11AprProcessor extends
openSocket = false;
sendfileInProgress = false;
readComplete = true;
+ if (endpoint.getUsePolling()) {
+ keptAlive = false;
+ } else {
+ keptAlive = socketWrapper.isKeptAlive();
+ }
int soTimeout = endpoint.getSoTimeout();
@@ -191,8 +196,6 @@ public class Http11AprProcessor extends
socketWrapper.setKeepAliveLeft(0);
}
- boolean keptAlive = false;
-
long socketRef = socketWrapper.getSocket().longValue();
while (!error && keepAlive && !comet && !isAsync() &&
Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java?rev=1165608&r1=1165607&r2=1165608&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Tue Sep 6 11:26:30 2011
@@ -213,6 +213,11 @@ public class Http11NioProcessor extends
openSocket = false;
sendfileInProgress = false;
readComplete = true;
+ if (endpoint.getUsePolling()) {
+ keptAlive = false;
+ } else {
+ keptAlive = socketWrapper.isKeptAlive();
+ }
int soTimeout = endpoint.getSoTimeout();
@@ -220,8 +225,6 @@ public class Http11NioProcessor extends
socketWrapper.setKeepAliveLeft(0);
}
- boolean keptAlive = false;
-
while (!error && keepAlive && !comet && !isAsync() &&
!endpoint.isPaused()) {
Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java?rev=1165608&r1=1165607&r2=1165608&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java Tue Sep 6 11:26:30 2011
@@ -148,6 +148,11 @@ public class Http11Processor extends Abs
openSocket = false;
sendfileInProgress = false;
readComplete = true;
+ if (endpoint.getUsePolling()) {
+ keptAlive = false;
+ } else {
+ keptAlive = socketWrapper.isKeptAlive();
+ }
int soTimeout = endpoint.getSoTimeout();
@@ -155,8 +160,6 @@ public class Http11Processor extends Abs
socketWrapper.setKeepAliveLeft(0);
}
- boolean keptAlive = socketWrapper.isKeptAlive();
-
while (!error && keepAlive && !comet && !isAsync() &&
!endpoint.isPaused()) {
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=1165608&r1=1165607&r2=1165608&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java Tue Sep 6 11:26:30 2011
@@ -559,9 +559,12 @@ public abstract class AbstractEndpoint {
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();
public abstract boolean getUseComet();
public abstract boolean getUseCometTimeout();
+ public abstract boolean getUsePolling();
protected LimitLatch initializeConnectionLatch() {
if (connectionLimitLatch==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=1165608&r1=1165607&r2=1165608&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Tue Sep 6 11:26:30 2011
@@ -160,6 +160,8 @@ public class AprEndpoint extends Abstrac
public boolean getUseComet() { return useComet; }
@Override
public boolean getUseCometTimeout() { return false; } // Not supported
+ @Override
+ public boolean getUsePolling() { return true; } // Always supported
/**
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java?rev=1165608&r1=1165607&r2=1165608&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java Tue Sep 6 11:26:30 2011
@@ -108,6 +108,8 @@ public class JIoEndpoint extends Abstrac
public boolean getUseCometTimeout() { return false; } // Not supported
@Override
public boolean getDeferAccept() { return false; } // Not supported
+ @Override
+ public boolean getUsePolling() { return false; } // Not supported
// ------------------------------------------------ Handler Inner Interface
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=1165608&r1=1165607&r2=1165608&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Tue Sep 6 11:26:30 2011
@@ -332,6 +332,8 @@ public class NioEndpoint extends Abstrac
public boolean getUseComet() { return useComet; }
@Override
public boolean getUseCometTimeout() { return getUseComet(); }
+ @Override
+ public boolean getUsePolling() { return true; } // Always supported
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org