View | Details | Raw Unified | Return to bug 61222
Collapse All | Expand All

(-)server/protocol.c (-24 / +36 lines)
Lines 1725-1764 Link Here
1725
             * prior to this, and then read the data for this bucket.
1725
             * prior to this, and then read the data for this bucket.
1726
             */
1726
             */
1727
            rv = apr_bucket_read(e, &ignored, &len, eblock);
1727
            rv = apr_bucket_read(e, &ignored, &len, eblock);
1728
            if ((rv != APR_SUCCESS) && !APR_STATUS_IS_EAGAIN(rv)) {
1729
                ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(00574)
1730
                              "ap_content_length_filter: "
1731
                              "apr_bucket_read() failed");
1732
                return rv;
1733
            }
1728
            if (rv == APR_SUCCESS) {
1734
            if (rv == APR_SUCCESS) {
1735
                /* include just read bucket in flush */
1736
                e = APR_BUCKET_NEXT(e);
1729
                /* Attempt a nonblocking read next time through */
1737
                /* Attempt a nonblocking read next time through */
1730
                eblock = APR_NONBLOCK_READ;
1738
                eblock = APR_NONBLOCK_READ;
1731
                r->bytes_sent += len;
1739
                r->bytes_sent += len;
1732
            }
1740
            }
1733
            else if (APR_STATUS_IS_EAGAIN(rv)) {
1741
            else if (APR_STATUS_IS_EAGAIN(rv)) {
1734
                /* Output everything prior to this bucket, and then
1742
                eblock = APR_BLOCK_READ;
1735
                 * do a blocking read on the next batch.
1743
            }
1736
                 */
1744
            /* Output everything prior to this bucket, and then
1737
                if (e != APR_BRIGADE_FIRST(b)) {
1745
             * do a blocking read on the next batch.
1738
                    apr_bucket *flush;
1746
             */
1739
                    apr_brigade_split_ex(b, e, ctx->tmpbb);
1747
            if (e != APR_BRIGADE_FIRST(b)) {
1740
                    flush = apr_bucket_flush_create(r->connection->bucket_alloc);
1748
                /* Note: e could be the brigade sentinel here, in
1749
                 * which case the split is a noop, and (as desired)
1750
                 * the entire brigade b will be passed. */
1751
                apr_brigade_split_ex(b, e, ctx->tmpbb);
1741
1752
1753
                if (eblock == APR_BLOCK_READ) {
1754
                    /* If the next read will block, flush first. */
1755
                    apr_bucket *flush = apr_bucket_flush_create(f->c->bucket_alloc);;
1756
                    
1742
                    APR_BRIGADE_INSERT_TAIL(b, flush);
1757
                    APR_BRIGADE_INSERT_TAIL(b, flush);
1743
                    rv = ap_pass_brigade(f->next, b);
1758
                }
1744
                    if (rv != APR_SUCCESS || f->c->aborted) {
1759
                
1745
                        return rv;
1760
                rv = ap_pass_brigade(f->next, b);
1746
                    }
1761
                if (rv != APR_SUCCESS) {
1747
                    apr_brigade_cleanup(b);
1762
                    return rv;
1748
                    APR_BRIGADE_CONCAT(b, ctx->tmpbb);
1763
                }
1749
                    e = APR_BRIGADE_FIRST(b);
1764
                else if (f->c->aborted) {
1765
                    return APR_ECONNABORTED;
1766
                }
1767
                apr_brigade_cleanup(b);
1768
                APR_BRIGADE_CONCAT(b, ctx->tmpbb);
1769
                e = APR_BRIGADE_FIRST(b);
1750
1770
1751
                    ctx->data_sent = 1;
1771
                ctx->data_sent = 1;
1752
                }
1753
                eblock = APR_BLOCK_READ;
1754
                continue;
1755
            }
1772
            }
1756
            else {
1773
            continue;
1757
                ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(00574)
1758
                              "ap_content_length_filter: "
1759
                              "apr_bucket_read() failed");
1760
                return rv;
1761
            }
1762
        }
1774
        }
1763
        else {
1775
        else {
1764
            r->bytes_sent += e->length;
1776
            r->bytes_sent += e->length;

Return to bug 61222