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 17:45:08 UTC
svn commit: r1165721 - in /tomcat/trunk/java/org/apache/coyote/http11:
AbstractHttp11Processor.java Http11AprProcessor.java
Http11NioProcessor.java Http11Processor.java
Author: markt
Date: Tue Sep 6 15:45:08 2011
New Revision: 1165721
URL: http://svn.apache.org/viewvc?rev=1165721&view=rev
Log:
Connector alignment - request line reading
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
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=1165721&r1=1165720&r2=1165721&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Tue Sep 6 15:45:08 2011
@@ -823,6 +823,14 @@ public abstract class AbstractHttp11Proc
/**
+ * Defines how a connector handles an incomplete request line read.
+ *
+ * @returns <code>true</code> if the processor should break out of the
+ * processing loop, otherwise <code>false</code>.
+ */
+ protected abstract boolean handleIncompleteRequestLineRead();
+
+ /**
* After reading the request headers, we have to setup the request filters.
*/
protected void prepareRequest() {
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=1165721&r1=1165720&r2=1165721&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Tue Sep 6 15:45:08 2011
@@ -204,16 +204,7 @@ public class Http11AprProcessor extends
setRequestLineReadTimeout();
if (!inputBuffer.parseRequestLine(keptAlive)) {
- // This means that no data is available right now
- // (long keepalive), so that the processor should be recycled
- // and the method should return true
- openSocket = true;
- if (endpoint.isPaused()) {
- // 503 - Service unavailable
- response.setStatus(503);
- adapter.log(request, response, 0);
- error = true;
- } else {
+ if (handleIncompleteRequestLineRead()) {
break;
}
}
@@ -389,9 +380,26 @@ public class Http11AprProcessor extends
@Override
+ protected boolean handleIncompleteRequestLineRead() {
+ // This means that no data is available right now
+ // (long keepalive), so that the processor should be recycled
+ // and the method should return true
+ openSocket = true;
+ if (endpoint.isPaused()) {
+ // 503 - Service unavailable
+ response.setStatus(503);
+ adapter.log(request, response, 0);
+ error = true;
+ } else {
+ return true;
+ }
+ return false;
+ }
+
+
+ @Override
protected void setCometTimeouts(SocketWrapper<Long> socketWrapper) {
// NO-OP for APR/native
- return;
}
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=1165721&r1=1165720&r2=1165721&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Tue Sep 6 15:45:08 2011
@@ -231,27 +231,7 @@ public class Http11NioProcessor extends
setRequestLineReadTimeout();
if (!inputBuffer.parseRequestLine(keptAlive)) {
- // Haven't finished reading the request so keep the socket
- // open
- openSocket = true;
- // Check to see if we have read any of the request line yet
- if (inputBuffer.getParsingRequestLinePhase()<2) {
- // No data read, OK to recycle the processor
- // Continue to use keep alive timeout
- if (keepAliveTimeout>0) {
- socketWrapper.setTimeout(keepAliveTimeout);
- }
- } else {
- // Started to read request line. Need to keep processor
- // associated with socket
- readComplete = false;
- }
- if (endpoint.isPaused()) {
- // 503 - Service unavailable
- response.setStatus(503);
- adapter.log(request, response, 0);
- error = true;
- } else {
+ if (handleIncompleteRequestLineRead()) {
break;
}
}
@@ -431,6 +411,35 @@ public class Http11NioProcessor extends
@Override
+ protected boolean handleIncompleteRequestLineRead() {
+ // Haven't finished reading the request so keep the socket
+ // open
+ openSocket = true;
+ // Check to see if we have read any of the request line yet
+ if (inputBuffer.getParsingRequestLinePhase()<2) {
+ // No data read, OK to recycle the processor
+ // Continue to use keep alive timeout
+ if (keepAliveTimeout>0) {
+ socket.setTimeout(keepAliveTimeout);
+ }
+ } else {
+ // Started to read request line. Need to keep processor
+ // associated with socket
+ readComplete = false;
+ }
+ if (endpoint.isPaused()) {
+ // 503 - Service unavailable
+ response.setStatus(503);
+ adapter.log(request, response, 0);
+ error = true;
+ } else {
+ return true;
+ }
+ return false;
+ }
+
+
+ @Override
protected void setCometTimeouts(SocketWrapper<NioChannel> socketWrapper) {
// Comet support
SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
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=1165721&r1=1165720&r2=1165721&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java Tue Sep 6 15:45:08 2011
@@ -154,8 +154,6 @@ public class Http11Processor extends Abs
keptAlive = socketWrapper.isKeptAlive();
}
- int soTimeout = endpoint.getSoTimeout();
-
if (disableKeepAlive()) {
socketWrapper.setKeepAliveLeft(0);
}
@@ -167,7 +165,12 @@ public class Http11Processor extends Abs
try {
setRequestLineReadTimeout();
- inputBuffer.parseRequestLine(false);
+ if (!inputBuffer.parseRequestLine(false)) {
+ if (handleIncompleteRequestLineRead()) {
+ break;
+ }
+ }
+
if (endpoint.isPaused()) {
// 503 - Service unavailable
response.setStatus(503);
@@ -177,7 +180,7 @@ public class Http11Processor extends Abs
request.setStartTime(System.currentTimeMillis());
keptAlive = true;
// Reset timeout for reading headers
- socket.getSocket().setSoTimeout(soTimeout);
+ socket.getSocket().setSoTimeout(endpoint.getSoTimeout());
inputBuffer.parseHeaders();
if (!disableUploadTimeout) {
socket.getSocket().setSoTimeout(connectionUploadTimeout);
@@ -382,9 +385,15 @@ public class Http11Processor extends Abs
@Override
+ protected boolean handleIncompleteRequestLineRead() {
+ // Not used with BIO since it uses blocking reads
+ return false;
+ }
+
+
+ @Override
protected void setCometTimeouts(SocketWrapper<Socket> socketWrapper) {
// NO-OP for BIO
- return;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org