Author: fhanik Date: Wed Dec 10 12:28:19 2008 New Revision: 725417 URL: http://svn.apache.org/viewvc?rev=725417&view=rev Log: implement timeout on sendfile write as wellimplement timeout on sendfile write as wellimplement timeout on sendfile write as wellimplement timeout on sendfile write as wellimplement timeout on sendfile write as wellimplement timeout on sendfile write as wellimplement timeout on sendfile write as wellimplement timeout on sendfile write as wellimplement timeout on sendfile write as well
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioChannel.java 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/NioChannel.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioChannel.java?rev=725417&r1=725416&r2=725417&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/NioChannel.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/NioChannel.java Wed Dec 10 12:28:19 2008 @@ -199,8 +199,13 @@ return 0; } - public void flushOutbound() throws IOException { - + /** + * Return true if the buffer wrote data + * @return + * @throws IOException + */ + public boolean flushOutbound() throws IOException { + return false; } public boolean isSendFile() { 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=725417&r1=725416&r2=725417&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Wed Dec 10 12:28:19 2008 @@ -1577,12 +1577,15 @@ WritableByteChannel wc =(WritableByteChannel) ((sc instanceof SecureNioChannel)?sc:sc.getIOChannel()); if (sc.getOutboundRemaining()>0) { - sc.flushOutbound(); + if (sc.flushOutbound()) { + attachment.access(); + } } else { long written = sd.fchannel.transferTo(sd.pos,sd.length,wc); if ( written > 0 ) { sd.pos += written; sd.length -= written; + attachment.access(); } } if ( sd.length <= 0 && sc.getOutboundRemaining()<=0) { @@ -1662,13 +1665,14 @@ if ( ka == null ) { cancelledKey(key, SocketStatus.ERROR,false); //we don't support any keys without attachments } else if ( ka.getError() ) { - cancelledKey(key, SocketStatus.ERROR,true); + cancelledKey(key, SocketStatus.ERROR,true);//TODO this is not yet being used } else if (ka.getComet() && ka.getCometNotify() ) { ka.setCometNotify(false); reg(key,ka,0);//avoid multiple calls, this gets reregistered after invokation //if (!processSocket(ka.getChannel(), SocketStatus.OPEN_CALLBACK)) processSocket(ka.getChannel(), SocketStatus.DISCONNECT); if (!processSocket(ka.getChannel(), SocketStatus.OPEN, true)) processSocket(ka.getChannel(), SocketStatus.DISCONNECT, true); - }else if ((ka.interestOps()&SelectionKey.OP_READ) == SelectionKey.OP_READ) { + }else if ((ka.interestOps()&SelectionKey.OP_READ) == SelectionKey.OP_READ || + (ka.interestOps()&SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE) { //only timeout sockets that we are waiting for a read from long delta = now - ka.getLastAccess(); long timeout = (ka.getTimeout()==-1)?((long) socketProperties.getSoTimeout()):(ka.getTimeout()); 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=725417&r1=725416&r2=725417&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java Wed Dec 10 12:28:19 2008 @@ -440,8 +440,11 @@ } @Override - public void flushOutbound() throws IOException { + public boolean flushOutbound() throws IOException { + int remaining = netOutBuffer.remaining(); flush(netOutBuffer); + int remaining2= netOutBuffer.remaining(); + return remaining2 < remaining; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]