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

(-)server/protocol.c (-45 / +1 lines)
Lines 1684-1690 Link Here
1684
                     * least one bucket on to the next output filter
1684
                     * least one bucket on to the next output filter
1685
                     * for this request
1685
                     * for this request
1686
                     */
1686
                     */
1687
    apr_bucket_brigade *tmpbb;
1688
};
1687
};
1689
1688
1690
/* This filter computes the content length, but it also computes the number
1689
/* This filter computes the content length, but it also computes the number
Lines 1699-1711 Link Here
1699
    struct content_length_ctx *ctx;
1698
    struct content_length_ctx *ctx;
1700
    apr_bucket *e;
1699
    apr_bucket *e;
1701
    int eos = 0;
1700
    int eos = 0;
1702
    apr_read_type_e eblock = APR_NONBLOCK_READ;
1703
1701
1704
    ctx = f->ctx;
1702
    ctx = f->ctx;
1705
    if (!ctx) {
1703
    if (!ctx) {
1706
        f->ctx = ctx = apr_palloc(r->pool, sizeof(*ctx));
1704
        f->ctx = ctx = apr_palloc(r->pool, sizeof(*ctx));
1707
        ctx->data_sent = 0;
1705
        ctx->data_sent = 0;
1708
        ctx->tmpbb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
1709
    }
1706
    }
1710
1707
1711
    /* Loop through this set of buckets to compute their length
1708
    /* Loop through this set of buckets to compute their length
Lines 1717-1764 Link Here
1717
            break;
1714
            break;
1718
        }
1715
        }
1719
        if (e->length == (apr_size_t)-1) {
1716
        if (e->length == (apr_size_t)-1) {
1720
            apr_size_t len;
1717
            break;
1721
            const char *ignored;
1722
            apr_status_t rv;
1723
1724
            /* This is probably a pipe bucket.  Send everything
1725
             * prior to this, and then read the data for this bucket.
1726
             */
1727
            rv = apr_bucket_read(e, &ignored, &len, eblock);
1728
            if (rv == APR_SUCCESS) {
1729
                /* Attempt a nonblocking read next time through */
1730
                eblock = APR_NONBLOCK_READ;
1731
                r->bytes_sent += len;
1732
            }
1733
            else if (APR_STATUS_IS_EAGAIN(rv)) {
1734
                /* Output everything prior to this bucket, and then
1735
                 * do a blocking read on the next batch.
1736
                 */
1737
                if (e != APR_BRIGADE_FIRST(b)) {
1738
                    apr_bucket *flush;
1739
                    apr_brigade_split_ex(b, e, ctx->tmpbb);
1740
                    flush = apr_bucket_flush_create(r->connection->bucket_alloc);
1741
1742
                    APR_BRIGADE_INSERT_TAIL(b, flush);
1743
                    rv = ap_pass_brigade(f->next, b);
1744
                    if (rv != APR_SUCCESS || f->c->aborted) {
1745
                        return rv;
1746
                    }
1747
                    apr_brigade_cleanup(b);
1748
                    APR_BRIGADE_CONCAT(b, ctx->tmpbb);
1749
                    e = APR_BRIGADE_FIRST(b);
1750
1751
                    ctx->data_sent = 1;
1752
                }
1753
                eblock = APR_BLOCK_READ;
1754
                continue;
1755
            }
1756
            else {
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
        }
1718
        }
1763
        else {
1719
        else {
1764
            r->bytes_sent += e->length;
1720
            r->bytes_sent += e->length;

Return to bug 61222