~ubuntu-branches/ubuntu/vivid/tomcat6/vivid

« back to all changes in this revision

Viewing changes to java/org/apache/tomcat/util/net/NioEndpoint.java

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2012-12-06 21:10:11 UTC
  • Revision ID: package-import@ubuntu.com-20121206211011-zuimndvjmjiwul9z
Tags: 6.0.35-6
* Acknowledge NMU: 6.0.35-5+nmu1 (Closes: #692440)
  - Thank you to Michael Gilbert.
* Add patches for the following security issues: (Closes: #695250)
  - CVE-2012-4534, CVE-2012-4431, CVE-2012-3546

Show diffs side-by-side

added added

removed removed

Lines of Context:
1713
1713
        public boolean processSendfile(SelectionKey sk, KeyAttachment attachment, boolean reg, boolean event) {
1714
1714
            NioChannel sc = null;
1715
1715
            try {
1716
 
                //unreg(sk,attachment);//only do this if we do process send file on a separate thread
 
1716
                unreg(sk, attachment, sk.readyOps());
1717
1717
                SendfileData sd = attachment.getSendfileData();
 
1718
 
 
1719
                if (log.isTraceEnabled()) {
 
1720
                    log.trace("Processing send file for: " + sd.fileName);
 
1721
                }
 
1722
 
 
1723
                //setup the file channel
1718
1724
                if ( sd.fchannel == null ) {
1719
1725
                    File f = new File(sd.fileName);
1720
1726
                    if ( !f.exists() ) {
1723
1729
                    }
1724
1730
                    sd.fchannel = new FileInputStream(f).getChannel();
1725
1731
                }
 
1732
 
 
1733
                //configure output channel
1726
1734
                sc = attachment.getChannel();
1727
1735
                sc.setSendFile(true);
 
1736
                //ssl channel is slightly different
1728
1737
                WritableByteChannel wc =(WritableByteChannel) ((sc instanceof SecureNioChannel)?sc:sc.getIOChannel());
1729
 
                
 
1738
 
 
1739
                //we still have data in the buffer
1730
1740
                if (sc.getOutboundRemaining()>0) {
1731
1741
                    if (sc.flushOutbound()) {
1732
1742
                        attachment.access();
1753
1763
                    attachment.setSendfileData(null);
1754
1764
                    try {sd.fchannel.close();}catch(Exception ignore){}
1755
1765
                    if ( sd.keepAlive ) {
1756
 
                        if (reg) {
1757
 
                            if (log.isDebugEnabled()) {
1758
 
                                log.debug("Connection is keep alive, registering back for OP_READ");
1759
 
                            }
1760
 
                            if (event) {
1761
 
                                this.add(attachment.getChannel(),SelectionKey.OP_READ);
1762
 
                            } else {
1763
 
                                reg(sk,attachment,SelectionKey.OP_READ);
1764
 
                            }
 
1766
                        if (log.isDebugEnabled()) {
 
1767
                            log.debug("Connection is keep alive, registering back for OP_READ");
 
1768
                        }
 
1769
                        if (event) {
 
1770
                            this.add(attachment.getChannel(),SelectionKey.OP_READ);
 
1771
                        } else {
 
1772
                            reg(sk,attachment,SelectionKey.OP_READ);
1765
1773
                        }
1766
1774
                    } else {
1767
1775
                        if (log.isDebugEnabled()) {
1770
1778
                        cancelledKey(sk,SocketStatus.STOP,false);
1771
1779
                        return false;
1772
1780
                    }
1773
 
                } else if ( attachment.interestOps() == 0 && reg ) {
 
1781
                } else {
1774
1782
                    if (log.isDebugEnabled()) {
1775
 
                        log.debug("OP_WRITE for sendilfe:"+sd.fileName);
 
1783
                        log.debug("OP_WRITE for sendfile:" + sd.fileName);
1776
1784
                    }
1777
1785
                    if (event) {
1778
1786
                        add(attachment.getChannel(),SelectionKey.OP_WRITE);