From: fhanik Date: Fri, 23 Mar 2007 16:05:46 +0000 (+0000) Subject: big oopsie, forgot to do SSL for executor/socketprocessor X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=1a3e43dff319635cc8140f3d7e77f7d8b0ba7fd7;p=tomcat7.0 big oopsie, forgot to do SSL for executor/socketprocessor git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@521784 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index 33d5bcacb..4c455510e 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -846,8 +846,8 @@ public class NioEndpoint { } public boolean getUseSendfile() { - - return useSendfile; + //send file doesn't work with SSL + return useSendfile && (!isSSLEnabled()); } /** @@ -1956,18 +1956,50 @@ public class NioEndpoint { public void run() { - // Process the request from this socket - boolean closed = (status==null)?(handler.process(socket)==Handler.SocketState.CLOSED) : - (handler.event(socket,status)==Handler.SocketState.CLOSED); - if (closed) { - // Close socket and pool - try { - try {socket.close();}catch (Exception ignore){} - if ( socket.isOpen() ) socket.close(true); - } catch ( Exception x ) { - log.error("",x); - } + + SelectionKey key = socket.getIOChannel().keyFor(socket.getPoller().getSelector()); + int handshake = -1; + try { + handshake = socket.handshake(key.isReadable(), key.isWritable()); + }catch ( IOException x ) { + handshake = -1; + if ( log.isDebugEnabled() ) log.debug("Error during SSL handshake",x); + }catch ( CancelledKeyException ckx ) { + handshake = -1; } + if ( handshake == 0 ) { + // Process the request from this socket + // Process the request from this socket + boolean closed = (status==null)?(handler.process(socket)==Handler.SocketState.CLOSED) : + (handler.event(socket,status)==Handler.SocketState.CLOSED); + + if (closed) { + // Close socket and pool + try { + KeyAttachment att = (KeyAttachment)socket.getAttachment(true); + try {socket.close();}catch (Exception ignore){} + if ( socket.isOpen() ) socket.close(true); + key.cancel(); + key.attach(null); + nioChannels.offer(socket); + if ( att!=null ) keyCache.offer(att); + }catch ( Exception x ) { + log.error("",x); + } + } + } else if (handshake == -1 ) { + KeyAttachment ka = (KeyAttachment)key.attachment(); + socket.getPoller().cancelledKey(key,SocketStatus.DISCONNECT,false); + try {socket.close(true);}catch (IOException ignore){} + nioChannels.offer(socket); + if ( ka!=null ) keyCache.offer(ka); + } else { + final SelectionKey fk = key; + final int intops = handshake; + final KeyAttachment ka = (KeyAttachment)fk.attachment(); + ka.getPoller().add(socket,intops); + } + socket = null; status = null; //return to cache