Commit 382220b0 authored by Ryan Bloom's avatar Ryan Bloom
Browse files

Loop over the brigade when multiple buckets file are found, instead of

breaking out of the function.
Submitted by:   Greg Stein


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87805 13f79535-47bb-0310-9956-ffa450edef68
parent 5cfdcb3f
Loading
Loading
Loading
Loading
+128 −121
Original line number Diff line number Diff line
@@ -3343,9 +3343,9 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b)
    }

    /* Iterate over the brigade collecting iovecs */
    do {
        while (b) {
            nbytes = 0; /* in case more points to another brigade */
        more = NULL;
            APR_BRIGADE_FOREACH(e, b) {
                if (APR_BUCKET_IS_EOS(e) || APR_BUCKET_IS_FLUSH(e)) {
                    break;
@@ -3361,8 +3361,7 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b)
                     * so we split here and send the file we have already found.
                     */
                    if (fd) {
                    more = apr_brigade_split(b, APR_BUCKET_NEXT(e));
                    ap_save_brigade(f, &ctx->b, &more);
                        more = apr_brigade_split(b, e);
                        break;
                    }
    
@@ -3390,7 +3389,8 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b)
                    }
                }
    
            if ((nvec == MAX_IOVEC_TO_WRITE) || (nvec_trailers == MAX_IOVEC_TO_WRITE)) {
                if ((nvec == MAX_IOVEC_TO_WRITE) || 
                    (nvec_trailers == MAX_IOVEC_TO_WRITE)) {
                    /* Split the brigade and break */
                    if (APR_BUCKET_NEXT(e) != APR_BRIGADE_SENTINEL(b)) {
                        more = apr_brigade_split(b, APR_BUCKET_NEXT(e));
@@ -3399,15 +3399,16 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b)
                }
            }
    
        /* Completed iterating over the brigades, now determine if we want to
         * buffer the brigade or send the brigade out on the network
            /* Completed iterating over the brigades, now determine if we want 
             * to buffer the brigade or send the brigade out on the network
             */
        if ((!fd && (!more) && (nbytes < AP_MIN_BYTES_TO_WRITE) && !APR_BUCKET_IS_FLUSH(e))
            if ((!fd && (!more) && 
                (nbytes < AP_MIN_BYTES_TO_WRITE) && !APR_BUCKET_IS_FLUSH(e))
                || (APR_BUCKET_IS_EOS(e) && c->keepalive)) {
                
            /* NEVER save an EOS in here.  If we are saving a brigade with an
             * EOS bucket, then we are doing keepalive connections, and we want
             * to process to second request fully.
                /* NEVER save an EOS in here.  If we are saving a brigade with 
                 * an EOS bucket, then we are doing keepalive connections, and 
                 * we want to process to second request fully.
                 */
                if (APR_BUCKET_IS_EOS(e)) {
                    APR_BUCKET_REMOVE(e);
@@ -3446,13 +3447,14 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b)
                                                       headers                */
                                     flags);   /* apr_sendfile flags        */
    
            /* If apr_sendfile() returns APR_ENOTIMPL, call send_the_file() to
             * loop on apr_read/apr_send to send the file. Our Windows binary 
             * distributions (which work on Windows 9x/NT) are compiled on 
             * Windows NT. TransmitFile is not available on Windows 95/98 and
             * we discover this at runtime when apr_sendfile() returns 
             * APR_ENOTIMPL. Having apr_sendfile() return APR_ENOTIMPL seems
             * the cleanest way to handle this case.
                /* If apr_sendfile() returns APR_ENOTIMPL, call send_the_file()
                 * to loop on apr_read/apr_send to send the file. Our Windows 
                 * binary distributions (which work on Windows 9x/NT) are 
                 * compiled on Windows NT. TransmitFile is not available on 
                 * Windows 95/98 and we discover this at runtime when 
                 * apr_sendfile() returns APR_ENOTIMPL. Having apr_sendfile() 
                 * return APR_ENOTIMPL seems the cleanest way to handle this 
                 * case.
                 */
                if (rv == APR_ENOTIMPL) {
#endif
@@ -3462,6 +3464,7 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b)
#if APR_HAS_SENDFILE
                }
#endif
                fd = NULL;
            }
            else {
                rv = writev_it_all(c->client_socket, 
@@ -3480,8 +3483,12 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b)
            nvec_trailers = 0;
    
            b = more;
            more = NULL;
        }  /* end while () */

        b = more;
    } while (more);

    return APR_SUCCESS;
}