Author: remm
Date: Thu Sep 17 14:52:39 2015
New Revision: 1703640

URL: http://svn.apache.org/r1703640
Log:
Remove finally and leave the channel in sendfile mode until the sendfile is 
done. Also check for close first since sendfile is reset on closing.
Note: this could hide away 57265, so it's probably a good idea to not port it 
to 8.

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
    tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java

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=1703640&r1=1703639&r2=1703640&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Thu Sep 17 
14:52:39 2015
@@ -958,7 +958,9 @@ public class NioEndpoint extends Abstrac
 
                 // Configure output channel
                 sc = socketWrapper.getSocket();
-                sc.setSendFile(true);
+                if (calledByProcessor) {
+                    sc.setSendFile(true);
+                }
                 // TLS/SSL channel is slightly different
                 WritableByteChannel wc = ((sc instanceof 
SecureNioChannel)?sc:sc.getIOChannel());
 
@@ -987,6 +989,7 @@ public class NioEndpoint extends Abstrac
                         log.debug("Send file complete for: "+sd.fileName);
                     }
                     socketWrapper.setSendfileData(null);
+                    sc.setSendFile(false);
                     try {
                         sd.fchannel.close();
                     } catch (Exception ignore) {
@@ -1035,8 +1038,6 @@ public class NioEndpoint extends Abstrac
                     cancelledKey(sk);
                 }
                 return SendfileState.ERROR;
-            } finally {
-                if (sc!=null) sc.setSendFile(false);
             }
         }
 

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java?rev=1703640&r1=1703639&r2=1703640&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java Thu Sep 
17 14:52:39 2015
@@ -583,12 +583,12 @@ public class SecureNioChannel extends Ni
             int written = sc.write(src);
             return written;
         } else {
+            //are we closing or closed?
+            if ( closing || closed) throw new 
IOException(sm.getString("channel.nio.ssl.closing"));
             //make sure we can handle expand, and that we only use one buffer
             if (!this.isSendFile() && src != bufHandler.getWriteBuffer()) {
                 throw new 
IllegalArgumentException(sm.getString("channel.nio.ssl.invalidBuffer"));
             }
-            //are we closing or closed?
-            if ( closing || closed) throw new 
IOException(sm.getString("channel.nio.ssl.closing"));
 
             //the number of bytes written
             int written = 0;



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to