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/10/20 18:30:23 UTC
svn commit: r1186890 - in /tomcat/trunk/java/org/apache/coyote/http11:
Http11AprProcessor.java Http11NioProcessor.java
Author: markt
Date: Thu Oct 20 16:30:22 2011
New Revision: 1186890
URL: http://svn.apache.org/viewvc?rev=1186890&view=rev
Log:
Clean-up. No functional change.
Modified:
tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
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=1186890&r1=1186889&r2=1186890&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Thu Oct 20 16:30:22 2011
@@ -61,7 +61,7 @@ public class Http11AprProcessor extends
int maxTrailerSize) {
super(endpoint);
-
+
inputBuffer = new InternalAprInputBuffer(request, headerBufferSize);
request.setInputBuffer(inputBuffer);
@@ -106,7 +106,7 @@ public class Http11AprProcessor extends
* provider is used to perform the conversion. For example it is used with
* the AJP connectors, the HTTP APR connector and with the
* {@link org.apache.catalina.valves.SSLValve}. If not specified, the
- * default provider will be used.
+ * default provider will be used.
*/
protected String clientCertProvider = null;
public String getClientCertProvider() { return clientCertProvider; }
@@ -125,9 +125,9 @@ public class Http11AprProcessor extends
@Override
public SocketState event(SocketStatus status)
throws IOException {
-
+
RequestInfo rp = request.getRequestProcessor();
-
+
try {
rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);
error = !adapter.event(request, response, status);
@@ -141,7 +141,7 @@ public class Http11AprProcessor extends
adapter.log(request, response, 0);
error = true;
}
-
+
rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
if (error) {
@@ -156,7 +156,7 @@ public class Http11AprProcessor extends
return SocketState.LONG;
}
}
-
+
@Override
protected boolean disableKeepAlive() {
return false;
@@ -170,10 +170,10 @@ public class Http11AprProcessor extends
// APR uses simulated blocking so if some request line data is present
// then it must all be presented (with the normal socket timeout).
-
+
// When entering the processing loop for the first time there will
// always be some data to read so the keep-alive timeout is not required
-
+
// For the second and subsequent executions of the processing loop, if
// there is no request line data present then no further data will be
// read from the socket. If there is request line data present then it
@@ -182,7 +182,7 @@ public class Http11AprProcessor extends
// When the socket is created it is given the correct timeout.
// sendfile may change the timeout but will restore it
// This processor may change the timeout for uploads but will restore it
-
+
// NO-OP
}
@@ -209,8 +209,8 @@ public class Http11AprProcessor extends
protected void setSocketTimeout(int timeout) {
Socket.timeoutSet(socket.getSocket().longValue(), timeout * 1000);
}
-
-
+
+
@Override
protected void setCometTimeouts(SocketWrapper<Long> socketWrapper) {
// NO-OP for APR/native
@@ -257,7 +257,7 @@ public class Http11AprProcessor extends
socket = null;
sendfileData = null;
}
-
+
// ----------------------------------------------------- ActionHook Methods
@@ -272,7 +272,7 @@ public class Http11AprProcessor extends
public void actionInternal(ActionCode actionCode, Object param) {
long socketRef = socket.getSocket().longValue();
-
+
if (actionCode == ActionCode.REQ_HOST_ADDR_ATTRIBUTE) {
// Get remote host address
@@ -375,10 +375,10 @@ public class Http11AprProcessor extends
certs = new X509Certificate[certLength + 1];
CertificateFactory cf;
if (clientCertProvider == null) {
- cf = CertificateFactory.getInstance("X.509");
+ cf = CertificateFactory.getInstance("X.509");
} else {
cf = CertificateFactory.getInstance("X.509",
- clientCertProvider);
+ clientCertProvider);
}
certs[0] = (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(clientCert));
for (int i = 0; i < certLength; i++) {
@@ -422,7 +422,7 @@ public class Http11AprProcessor extends
if (SSLSocket.renegotiate(socketRef) == 0) {
// Don't look for certs unless we know renegotiation worked.
// Get client certificate and the certificate chain if present
- // certLength == -1 indicates an error
+ // certLength == -1 indicates an error
int certLength = SSLSocket.getInfoI(socketRef,SSL.SSL_INFO_CLIENT_CERT_CHAIN);
byte[] clientCert = SSLSocket.getInfoB(socketRef, SSL.SSL_INFO_CLIENT_CERT);
X509Certificate[] certs = null;
@@ -461,7 +461,9 @@ public class Http11AprProcessor extends
SocketStatus.OPEN);
}
} else if (actionCode == ActionCode.ASYNC_SETTIMEOUT) {
- if (param==null) return;
+ if (param==null) {
+ return;
+ }
long timeout = ((Long)param).longValue();
socket.setTimeout(timeout);
} else if (actionCode == ActionCode.ASYNC_DISPATCH) {
@@ -470,7 +472,7 @@ public class Http11AprProcessor extends
SocketStatus.OPEN);
}
}
-
+
}
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=1186890&r1=1186889&r2=1186890&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Thu Oct 20 16:30:22 2011
@@ -127,7 +127,9 @@ public class Http11NioProcessor extends
attach.setComet(comet);
if (comet) {
Integer comettimeout = (Integer) request.getAttribute("org.apache.tomcat.comet.timeout");
- if (comettimeout != null) attach.setTimeout(comettimeout.longValue());
+ if (comettimeout != null) {
+ attach.setTimeout(comettimeout.longValue());
+ }
} else {
//reset the timeout
if (keepAlive) {
@@ -160,7 +162,7 @@ public class Http11NioProcessor extends
return SocketState.LONG;
}
}
-
+
@Override
protected void resetTimeouts() {
@@ -194,14 +196,14 @@ public class Http11NioProcessor extends
// When entering the processing loop there will always be data to read
// so no point changing timeouts at this point
-
+
// For the second and subsequent executions of the processing loop, a
// non-blocking read is used so again no need to set the timeouts
-
+
// Because NIO supports non-blocking reading of the request line and
// headers the timeouts need to be set when returning the socket to
// the poller rather than here.
-
+
// NO-OP
}
@@ -242,7 +244,7 @@ public class Http11NioProcessor extends
socket.getSocket().getIOChannel().socket().setSoTimeout(timeout);
}
-
+
@Override
protected void setCometTimeouts(SocketWrapper<NioChannel> socketWrapper) {
// Comet support
@@ -254,7 +256,9 @@ public class Http11NioProcessor extends
attach.setComet(comet);
if (comet) {
Integer comettimeout = (Integer) request.getAttribute("org.apache.tomcat.comet.timeout");
- if (comettimeout != null) attach.setTimeout(comettimeout.longValue());
+ if (comettimeout != null) {
+ attach.setTimeout(comettimeout.longValue());
+ }
}
}
}
@@ -341,8 +345,9 @@ public class Http11NioProcessor extends
} else if (actionCode == ActionCode.REQ_LOCAL_ADDR_ATTRIBUTE) {
- if (localAddr == null)
- localAddr = socket.getSocket().getIOChannel().socket().getLocalAddress().getHostAddress();
+ if (localAddr == null) {
+ localAddr = socket.getSocket().getIOChannel().socket().getLocalAddress().getHostAddress();
+ }
request.localAddr().setString(localAddr);
@@ -365,21 +370,25 @@ public class Http11NioProcessor extends
try {
if (sslSupport != null) {
Object sslO = sslSupport.getCipherSuite();
- if (sslO != null)
+ if (sslO != null) {
request.setAttribute
(SSLSupport.CIPHER_SUITE_KEY, sslO);
+ }
sslO = sslSupport.getPeerCertificateChain(false);
- if (sslO != null)
+ if (sslO != null) {
request.setAttribute
(SSLSupport.CERTIFICATE_KEY, sslO);
+ }
sslO = sslSupport.getKeySize();
- if (sslO != null)
+ if (sslO != null) {
request.setAttribute
(SSLSupport.KEY_SIZE_KEY, sslO);
+ }
sslO = sslSupport.getSessionId();
- if (sslO != null)
+ if (sslO != null) {
request.setAttribute
(SSLSupport.SESSION_ID_KEY, sslO);
+ }
request.setAttribute(SSLSupport.SESSION_MGR, sslSupport);
}
} catch (Exception e) {
@@ -433,7 +442,9 @@ public class Http11NioProcessor extends
} else if (actionCode == ActionCode.COMET_END) {
comet = false;
} else if (actionCode == ActionCode.COMET_CLOSE) {
- if (socket==null || socket.getSocket().getAttachment(false)==null) return;
+ if (socket==null || socket.getSocket().getAttachment(false)==null) {
+ return;
+ }
NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment)socket.getSocket().getAttachment(false);
attach.setCometOps(NioEndpoint.OP_CALLBACK);
RequestInfo rp = request.getRequestProcessor();
@@ -444,22 +455,31 @@ public class Http11NioProcessor extends
socket.getSocket().getPoller().add(socket.getSocket());
}
} else if (actionCode == ActionCode.COMET_SETTIMEOUT) {
- if (param==null) return;
- if (socket==null || socket.getSocket().getAttachment(false)==null) return;
+ if (param==null) {
+ return;
+ }
+ if (socket==null || socket.getSocket().getAttachment(false)==null) {
+ return;
+ }
NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment)socket.getSocket().getAttachment(false);
long timeout = ((Long)param).longValue();
//if we are not piggy backing on a worker thread, set the timeout
RequestInfo rp = request.getRequestProcessor();
- if ( rp.getStage() != org.apache.coyote.Constants.STAGE_SERVICE ) //async handling
+ if ( rp.getStage() != org.apache.coyote.Constants.STAGE_SERVICE ) {
attach.setTimeout(timeout);
+ }
} else if (actionCode == ActionCode.ASYNC_COMPLETE) {
if (asyncStateMachine.asyncComplete()) {
((NioEndpoint)endpoint).processSocket(this.socket.getSocket(),
SocketStatus.OPEN, true);
}
} else if (actionCode == ActionCode.ASYNC_SETTIMEOUT) {
- if (param==null) return;
- if (socket==null || socket.getSocket().getAttachment(false)==null) return;
+ if (param==null) {
+ return;
+ }
+ if (socket==null || socket.getSocket().getAttachment(false)==null) {
+ return;
+ }
NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment)socket.getSocket().getAttachment(false);
long timeout = ((Long)param).longValue();
//if we are not piggy backing on a worker thread, set the timeout
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org