Commit 2793534d authored by Ryan Bloom's avatar Ryan Bloom
Browse files

Back out the recent change to ap_get_brigade, to make it use indirection

again.  The problem is that the amount of data read from the network,
is not necessarily the amount of data returned from the filters.  It is
possible for input filters to add bytes to the data read from the network.

To fix the original bug, I just removed the line from ap_get_client_block
that decremented r->remaining, we allow the http_filter to do that for
us.

I have also removed an incorrect comment.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89041 13f79535-47bb-0310-9956-ffa450edef68
parent 998a5eda
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ typedef struct ap_filter_t ap_filter_t;
 */
typedef apr_status_t (*ap_out_filter_func)(ap_filter_t *f, apr_bucket_brigade *b);
typedef apr_status_t (*ap_in_filter_func)(ap_filter_t *f, apr_bucket_brigade *b, 
                                          ap_input_mode_t mode, apr_size_t readbytes);
                                          ap_input_mode_t mode, apr_size_t *readbytes);

typedef union ap_filter_func {
    ap_out_filter_func out_func;
@@ -276,7 +276,7 @@ struct ap_filter_t {
 *                  a single line should be read.
 */
AP_DECLARE(apr_status_t) ap_get_brigade(ap_filter_t *filter, apr_bucket_brigade *bucket, 
                                        ap_input_mode_t mode, apr_size_t readbytes);
                                        ap_input_mode_t mode, apr_size_t *readbytes);

/**
 * Pass the current bucket brigade down to the next filter on the filter
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ static void CaseFilterInInsertFilter(request_rec *r)

static apr_status_t CaseFilterInFilter(ap_filter_t *f,
				       apr_bucket_brigade *pbbOut,
				       ap_input_mode_t eMode,apr_size_t nBytes)
				       ap_input_mode_t eMode,apr_size_t *nBytes)
{
    CaseFilterInContext *pCtx=f->ctx;
    apr_status_t ret;
+1 −1
Original line number Diff line number Diff line
@@ -1005,7 +1005,7 @@ static void transfer_brigade(apr_bucket_brigade *in, apr_bucket_brigade *out)
}

static int xlate_in_filter(ap_filter_t *f, apr_bucket_brigade *bb, 
                           ap_input_mode_t mode, apr_size_t readbytes)
                           ap_input_mode_t mode, apr_size_t *readbytes)
{
    apr_status_t rv;
    charset_req_t *reqinfo = ap_get_module_config(f->r->request_config,
+1 −1
Original line number Diff line number Diff line
@@ -749,7 +749,7 @@ static apr_status_t ef_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)

#if 0
static int ef_input_filter(ap_filter_t *f, apr_bucket_brigade *bb, 
                           ap_input_mode_t mode, apr_size_t readbytes)
                           ap_input_mode_t mode, apr_size_t *readbytes)
{
    apr_status_t rv;
    apr_bucket *b;
+10 −11
Original line number Diff line number Diff line
@@ -424,7 +424,7 @@ struct dechunk_ctx {
static long get_chunk_size(char *);

apr_status_t ap_dechunk_filter(ap_filter_t *f, apr_bucket_brigade *bb,
                               ap_input_mode_t mode, apr_size_t readbytes)
                               ap_input_mode_t mode, apr_size_t *readbytes)
{
    apr_status_t rv;
    struct dechunk_ctx *ctx = f->ctx;
@@ -484,7 +484,7 @@ apr_status_t ap_dechunk_filter(ap_filter_t *f, apr_bucket_brigade *bb,
        apr_size_t chunk_bytes = ctx->chunk_size - ctx->bytes_delivered;

        if ((rv = ap_get_brigade(f->next, bb, mode,
                                 chunk_bytes)) != APR_SUCCESS) {
                                 &chunk_bytes)) != APR_SUCCESS) {
            return rv;
        }

@@ -518,7 +518,7 @@ typedef struct http_filter_ctx {
    apr_bucket_brigade *b;
} http_ctx_t;

apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_size_t readbytes)
apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_size_t *readbytes)
{
    apr_bucket *e;
    char *buff;
@@ -577,7 +577,7 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode
    }

    /* readbytes == 0 is "read a single line". otherwise, read a block. */
    if (readbytes) {
    if (*readbytes) {

        /* ### the code below, which moves bytes from one brigade to the
           ### other is probably bogus. presuming the next filter down was
@@ -604,12 +604,12 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode
                 * a time - don't assume that one call to apr_bucket_read()
                 * will return the full string.
                 */
                if (readbytes < len) {
                    apr_bucket_split(e, readbytes);
                    readbytes = 0;
                if (*readbytes < len) {
                    apr_bucket_split(e, *readbytes);
                    *readbytes = 0;
                }
                else {
                    readbytes -= len;
                    *readbytes -= len;
                }
                APR_BUCKET_REMOVE(e);
                APR_BRIGADE_INSERT_TAIL(b, e);
@@ -628,7 +628,7 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode
           ### chunks to determine where the end of the request is, so we
           ### shouldn't be monkeying with EOS buckets.
        */
        if (readbytes == 0) {
        if (*readbytes == 0) {
            apr_bucket *eos = apr_bucket_eos_create();
                
            APR_BRIGADE_INSERT_TAIL(b, eos);
@@ -1403,7 +1403,7 @@ AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz)
    do {
        if (APR_BRIGADE_EMPTY(bb)) {
            if (ap_get_brigade(r->input_filters, bb, AP_MODE_BLOCKING,
                               r->remaining) != APR_SUCCESS) {
                               &r->remaining) != APR_SUCCESS) {
                /* if we actually fail here, we want to just return and
                 * stop trying to read data from the client.
                 */
@@ -1449,7 +1449,6 @@ AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz)
         * these
         */
        r->read_length += len_read;      /* XXX yank me? */
        r->remaining -= len_read;        /* XXX yank me? */
        old = b;
        b = APR_BUCKET_NEXT(b);
        apr_bucket_delete(old);
Loading