Author: markt Date: Thu Aug 8 22:26:38 2013 New Revision: 1512073 URL: http://svn.apache.org/r1512073 Log: Fix refactoring in r1512034 that broke HTTP BIO and APR
Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.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=1512073&r1=1512072&r2=1512073&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Thu Aug 8 22:26:38 2013 @@ -81,12 +81,6 @@ public class Http11AprProcessor extends /** - * Socket associated with the current connection. - */ - protected SocketWrapper<Long> socket = null; - - - /** * When client certificate information is presented in a form other than * instances of {@link java.security.cert.X509Certificate} it needs to be * converted before it can be used and this property controls which JSSE @@ -192,7 +186,7 @@ public class Http11AprProcessor extends @Override protected void setSocketTimeout(int timeout) { - Socket.timeoutSet(socket.getSocket().longValue(), timeout * 1000); + Socket.timeoutSet(socketWrapper.getSocket().longValue(), timeout * 1000); } @@ -234,7 +228,7 @@ public class Http11AprProcessor extends @Override protected void registerForEvent(boolean read, boolean write) { ((AprEndpoint) endpoint).getPoller().add( - socket.getSocket().longValue(), -1, read, write); + socketWrapper.getSocket().longValue(), -1, read, write); } @@ -246,7 +240,7 @@ public class Http11AprProcessor extends @Override public void recycleInternal() { - socket = null; + socketWrapper = null; sendfileData = null; } @@ -268,22 +262,22 @@ public class Http11AprProcessor extends @Override public void actionInternal(ActionCode actionCode, Object param) { - long socketRef = socket.getSocket().longValue(); + long socketRef = socketWrapper.getSocket().longValue(); if (actionCode == ActionCode.REQ_HOST_ADDR_ATTRIBUTE) { if (socketRef == 0) { request.remoteAddr().recycle(); } else { - if (socket.getRemoteAddr() == null) { + if (socketWrapper.getRemoteAddr() == null) { try { long sa = Address.get(Socket.APR_REMOTE, socketRef); - socket.setRemoteAddr(Address.getip(sa)); + socketWrapper.setRemoteAddr(Address.getip(sa)); } catch (Exception e) { log.warn(sm.getString("http11processor.socket.info"), e); } } - request.remoteAddr().setString(socket.getRemoteAddr()); + request.remoteAddr().setString(socketWrapper.getRemoteAddr()); } } else if (actionCode == ActionCode.REQ_LOCAL_NAME_ATTRIBUTE) { @@ -291,15 +285,15 @@ public class Http11AprProcessor extends if (socketRef == 0) { request.localName().recycle(); } else { - if (socket.getLocalName() == null) { + if (socketWrapper.getLocalName() == null) { try { long sa = Address.get(Socket.APR_LOCAL, socketRef); - socket.setLocalName(Address.getnameinfo(sa, 0)); + socketWrapper.setLocalName(Address.getnameinfo(sa, 0)); } catch (Exception e) { log.warn(sm.getString("http11processor.socket.info"), e); } } - request.localName().setString(socket.getLocalName()); + request.localName().setString(socketWrapper.getLocalName()); } } else if (actionCode == ActionCode.REQ_HOST_ATTRIBUTE) { @@ -307,23 +301,23 @@ public class Http11AprProcessor extends if (socketRef == 0) { request.remoteHost().recycle(); } else { - if (socket.getRemoteHost() == null) { + if (socketWrapper.getRemoteHost() == null) { try { long sa = Address.get(Socket.APR_REMOTE, socketRef); - socket.setRemoteHost(Address.getnameinfo(sa, 0)); - if (socket.getRemoteHost() == null) { - if (socket.getRemoteAddr() == null) { - socket.setRemoteAddr(Address.getip(sa)); + socketWrapper.setRemoteHost(Address.getnameinfo(sa, 0)); + if (socketWrapper.getRemoteHost() == null) { + if (socketWrapper.getRemoteAddr() == null) { + socketWrapper.setRemoteAddr(Address.getip(sa)); } - if (socket.getRemoteAddr() != null) { - socket.setRemoteHost(socket.getRemoteAddr()); + if (socketWrapper.getRemoteAddr() != null) { + socketWrapper.setRemoteHost(socketWrapper.getRemoteAddr()); } } } catch (Exception e) { log.warn(sm.getString("http11processor.socket.info"), e); } } else { - request.remoteHost().setString(socket.getRemoteHost()); + request.remoteHost().setString(socketWrapper.getRemoteHost()); } } @@ -332,15 +326,15 @@ public class Http11AprProcessor extends if (socketRef == 0) { request.localAddr().recycle(); } else { - if (socket.getLocalAddr() == null) { + if (socketWrapper.getLocalAddr() == null) { try { long sa = Address.get(Socket.APR_LOCAL, socketRef); - socket.setLocalAddr(Address.getip(sa)); + socketWrapper.setLocalAddr(Address.getip(sa)); } catch (Exception e) { log.warn(sm.getString("http11processor.socket.info"), e); } } - request.localAddr().setString(socket.getLocalAddr()); + request.localAddr().setString(socketWrapper.getLocalAddr()); } } else if (actionCode == ActionCode.REQ_REMOTEPORT_ATTRIBUTE) { @@ -348,16 +342,16 @@ public class Http11AprProcessor extends if (socketRef == 0) { request.setRemotePort(0); } else { - if (socket.getRemotePort() == -1) { + if (socketWrapper.getRemotePort() == -1) { try { long sa = Address.get(Socket.APR_REMOTE, socketRef); Sockaddr addr = Address.getInfo(sa); - socket.setRemotePort(addr.port); + socketWrapper.setRemotePort(addr.port); } catch (Exception e) { log.warn(sm.getString("http11processor.socket.info"), e); } } - request.setRemotePort(socket.getRemotePort()); + request.setRemotePort(socketWrapper.getRemotePort()); } } else if (actionCode == ActionCode.REQ_LOCALPORT_ATTRIBUTE) { @@ -365,16 +359,16 @@ public class Http11AprProcessor extends if (socketRef == 0) { request.setLocalPort(0); } else { - if (socket.getLocalPort() == -1) { + if (socketWrapper.getLocalPort() == -1) { try { long sa = Address.get(Socket.APR_LOCAL, socketRef); Sockaddr addr = Address.getInfo(sa); - socket.setLocalPort(addr.port); + socketWrapper.setLocalPort(addr.port); } catch (Exception e) { log.warn(sm.getString("http11processor.socket.info"), e); } } - request.setLocalPort(socket.getLocalPort()); + request.setLocalPort(socketWrapper.getLocalPort()); } } else if (actionCode == ActionCode.REQ_SSL_ATTRIBUTE ) { @@ -469,13 +463,13 @@ public class Http11AprProcessor extends } else if (actionCode == ActionCode.COMET_END) { comet = false; } else if (actionCode == ActionCode.COMET_CLOSE) { - ((AprEndpoint)endpoint).processSocketAsync(this.socket, + ((AprEndpoint)endpoint).processSocketAsync(this.socketWrapper, SocketStatus.OPEN_READ); } else if (actionCode == ActionCode.COMET_SETTIMEOUT) { //no op } else if (actionCode == ActionCode.ASYNC_COMPLETE) { if (asyncStateMachine.asyncComplete()) { - ((AprEndpoint)endpoint).processSocketAsync(this.socket, + ((AprEndpoint)endpoint).processSocketAsync(this.socketWrapper, SocketStatus.OPEN_READ); } } else if (actionCode == ActionCode.ASYNC_SETTIMEOUT) { @@ -483,10 +477,10 @@ public class Http11AprProcessor extends return; } long timeout = ((Long)param).longValue(); - socket.setTimeout(timeout); + socketWrapper.setTimeout(timeout); } else if (actionCode == ActionCode.ASYNC_DISPATCH) { if (asyncStateMachine.asyncDispatch()) { - ((AprEndpoint)endpoint).processSocketAsync(this.socket, + ((AprEndpoint)endpoint).processSocketAsync(this.socketWrapper, SocketStatus.OPEN_READ); } } 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=1512073&r1=1512072&r2=1512073&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java Thu Aug 8 22:26:38 2013 @@ -73,12 +73,6 @@ public class Http11Processor extends Abs /** - * Socket associated with the current connection. - */ - protected SocketWrapper<Socket> socket; - - - /** * The percentage of threads that have to be in use before keep-alive is * disabled to aid scalability. */ @@ -138,13 +132,13 @@ public class Http11Processor extends Abs * This is a little hacky but better than exposing the socket * and the timeout info to the InputBuffer */ - if (inputBuffer.lastValid == 0 && socket.getLastAccess() > -1) { + if (inputBuffer.lastValid == 0 && socketWrapper.getLastAccess() > -1) { int firstReadTimeout; if (keepAliveTimeout == -1) { firstReadTimeout = 0; } else { long queueTime = - System.currentTimeMillis() - socket.getLastAccess(); + System.currentTimeMillis() - socketWrapper.getLastAccess(); if (queueTime >= keepAliveTimeout) { // Queued for longer than timeout but there might be @@ -156,7 +150,7 @@ public class Http11Processor extends Abs firstReadTimeout = keepAliveTimeout - (int) queueTime; } } - socket.getSocket().setSoTimeout(firstReadTimeout); + socketWrapper.getSocket().setSoTimeout(firstReadTimeout); // Blocking IO so fill() always blocks if (!inputBuffer.fill(true)) { throw new EOFException(sm.getString("iib.eof.error")); @@ -181,7 +175,7 @@ public class Http11Processor extends Abs @Override protected void setSocketTimeout(int timeout) throws IOException { - socket.getSocket().setSoTimeout(timeout); + socketWrapper.getSocket().setSoTimeout(timeout); } @@ -217,7 +211,7 @@ public class Http11Processor extends Abs @Override protected void recycleInternal() { // Recycle - this.socket = null; + this.socketWrapper = null; // Recycle ssl info sslSupport = null; } @@ -270,87 +264,87 @@ public class Http11Processor extends Abs } else if (actionCode == ActionCode.REQ_HOST_ADDR_ATTRIBUTE) { - if (socket == null) { + if (socketWrapper == null) { request.remoteAddr().recycle(); } else { - if (socket.getRemoteAddr() == null) { - InetAddress inetAddr = socket.getSocket().getInetAddress(); + if (socketWrapper.getRemoteAddr() == null) { + InetAddress inetAddr = socketWrapper.getSocket().getInetAddress(); if (inetAddr != null) { - socket.setRemoteAddr(inetAddr.getHostAddress()); + socketWrapper.setRemoteAddr(inetAddr.getHostAddress()); } } - request.remoteAddr().setString(socket.getRemoteAddr()); + request.remoteAddr().setString(socketWrapper.getRemoteAddr()); } } else if (actionCode == ActionCode.REQ_LOCAL_NAME_ATTRIBUTE) { - if (socket == null) { + if (socketWrapper == null) { request.localName().recycle(); } else { - if (socket.getLocalName() == null) { - InetAddress inetAddr = socket.getSocket().getLocalAddress(); + if (socketWrapper.getLocalName() == null) { + InetAddress inetAddr = socketWrapper.getSocket().getLocalAddress(); if (inetAddr != null) { - socket.setLocalName(inetAddr.getHostName()); + socketWrapper.setLocalName(inetAddr.getHostName()); } } - request.localName().setString(socket.getLocalName()); + request.localName().setString(socketWrapper.getLocalName()); } } else if (actionCode == ActionCode.REQ_HOST_ATTRIBUTE) { - if (socket == null) { + if (socketWrapper == null) { request.remoteHost().recycle(); } else { - if (socket.getRemoteHost() == null) { - InetAddress inetAddr = socket.getSocket().getInetAddress(); + if (socketWrapper.getRemoteHost() == null) { + InetAddress inetAddr = socketWrapper.getSocket().getInetAddress(); if (inetAddr != null) { - socket.setRemoteHost(inetAddr.getHostName()); + socketWrapper.setRemoteHost(inetAddr.getHostName()); } - if (socket.getRemoteHost() == null) { - if (socket.getRemoteAddr() == null && + if (socketWrapper.getRemoteHost() == null) { + if (socketWrapper.getRemoteAddr() == null && inetAddr != null) { - socket.setRemoteAddr(inetAddr.getHostAddress()); + socketWrapper.setRemoteAddr(inetAddr.getHostAddress()); } - if (socket.getRemoteAddr() != null) { - socket.setRemoteHost(socket.getRemoteAddr()); + if (socketWrapper.getRemoteAddr() != null) { + socketWrapper.setRemoteHost(socketWrapper.getRemoteAddr()); } } } - request.remoteHost().setString(socket.getRemoteHost()); + request.remoteHost().setString(socketWrapper.getRemoteHost()); } } else if (actionCode == ActionCode.REQ_LOCAL_ADDR_ATTRIBUTE) { - if (socket == null) { + if (socketWrapper == null) { request.localAddr().recycle(); } else { - if (socket.getLocalAddr() == null) { - socket.setLocalAddr( - socket.getSocket().getLocalAddress().getHostAddress()); + if (socketWrapper.getLocalAddr() == null) { + socketWrapper.setLocalAddr( + socketWrapper.getSocket().getLocalAddress().getHostAddress()); } - request.localAddr().setString(socket.getLocalAddr()); + request.localAddr().setString(socketWrapper.getLocalAddr()); } } else if (actionCode == ActionCode.REQ_REMOTEPORT_ATTRIBUTE) { - if (socket == null) { + if (socketWrapper == null) { request.setRemotePort(0); } else { - if (socket.getRemotePort() == -1) { - socket.setRemotePort(socket.getSocket().getPort()); + if (socketWrapper.getRemotePort() == -1) { + socketWrapper.setRemotePort(socketWrapper.getSocket().getPort()); } - request.setRemotePort(socket.getRemotePort()); + request.setRemotePort(socketWrapper.getRemotePort()); } } else if (actionCode == ActionCode.REQ_LOCALPORT_ATTRIBUTE) { - if (socket == null) { + if (socketWrapper == null) { request.setLocalPort(0); } else { - if (socket.getLocalPort() == -1) { - socket.setLocalPort(socket.getSocket().getLocalPort()); + if (socketWrapper.getLocalPort() == -1) { + socketWrapper.setLocalPort(socketWrapper.getSocket().getLocalPort()); } - request.setLocalPort(socket.getLocalPort()); + request.setLocalPort(socketWrapper.getLocalPort()); } } else if (actionCode == ActionCode.REQ_SSL_CERTIFICATE) { @@ -376,17 +370,17 @@ public class Http11Processor extends Abs } } else if (actionCode == ActionCode.ASYNC_COMPLETE) { if (asyncStateMachine.asyncComplete()) { - ((JIoEndpoint) endpoint).processSocketAsync(this.socket, + ((JIoEndpoint) endpoint).processSocketAsync(this.socketWrapper, SocketStatus.OPEN_READ); } } else if (actionCode == ActionCode.ASYNC_SETTIMEOUT) { if (param == null) return; long timeout = ((Long)param).longValue(); // if we are not piggy backing on a worker thread, set the timeout - socket.setTimeout(timeout); + socketWrapper.setTimeout(timeout); } else if (actionCode == ActionCode.ASYNC_DISPATCH) { if (asyncStateMachine.asyncDispatch()) { - ((JIoEndpoint) endpoint).processSocketAsync(this.socket, + ((JIoEndpoint) endpoint).processSocketAsync(this.socketWrapper, SocketStatus.OPEN_READ); } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org