You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Bill Stoddard <bi...@wstoddard.com> on 2001/05/11 19:45:44 UTC

core.c still broken..

This piece of code is still broken.   We should not be calling
apr_bucket_read() on a file bucket unless the file is less than
AP_MIN_SENDFILE_BYTES.

I'll look into this later because my head is exploding from a nasty sinus
infection...

Bill

    if ((!fd && !more &&
            (nbytes + flen < AP_MIN_BYTES_TO_WRITE) &&
!APR_BUCKET_IS_FLUSH(e))
            || (nbytes + flen < AP_MIN_BYTES_TO_WRITE &&
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.
             */

            if (APR_BUCKET_IS_EOS(e)) {
                apr_bucket *bucket = NULL;
                /* If we are in here, then this request is a keepalive.  We
                 * need to be certain that any data in a bucket is valid
                 * after the request_pool is cleared.
                 */
                if (ctx->b == NULL) {
                    ctx->b = apr_brigade_create(f->c->pool);
                }

                APR_BRIGADE_FOREACH(bucket, b) {
                    const char *str;
                    apr_size_t n;

                    rv = apr_bucket_read(bucket, &str, &n, APR_BLOCK_READ);



Re: core.c still broken..

Posted by Bill Stoddard <bi...@wstoddard.com>.
> > > > This piece of code is still broken.   We should not be calling
> > > > apr_bucket_read() on a file bucket unless the file is less than
> > > > AP_MIN_SENDFILE_BYTES.
> > >
> > > This isn't strictly true.  If the file is smaller than
> > > AP_MIN_BYTES_TO_WRITE, and we are on a keepalive connection, then we will
> > > read the file into memory.  This is done so that we don't have to allocate
> > > the file out of the connection pool.
> > >
> > > What exactly are you seeing?
> >
> > Not using apr_sendfile() when we have a file descriptor on a 500 byte file.
> 
> Is it a keepalive connection?  If so, then we are behaving correctly.  We
> had to make a trade-off.  Either we can use sendfile, or we can buffer
> data and send multiple responses in the same packet.  We chose the latter.

Ahh, okay I understand.  

Bill


Re: core.c still broken..

Posted by rb...@covalent.net.
> > > This piece of code is still broken.   We should not be calling
> > > apr_bucket_read() on a file bucket unless the file is less than
> > > AP_MIN_SENDFILE_BYTES.
> >
> > This isn't strictly true.  If the file is smaller than
> > AP_MIN_BYTES_TO_WRITE, and we are on a keepalive connection, then we will
> > read the file into memory.  This is done so that we don't have to allocate
> > the file out of the connection pool.
> >
> > What exactly are you seeing?
>
> Not using apr_sendfile() when we have a file descriptor on a 500 byte file.

Is it a keepalive connection?  If so, then we are behaving correctly.  We
had to make a trade-off.  Either we can use sendfile, or we can buffer
data and send multiple responses in the same packet.  We chose the latter.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: core.c still broken..

Posted by Bill Stoddard <bi...@wstoddard.com>.
> On Fri, 11 May 2001, Bill Stoddard wrote:
>
> > This piece of code is still broken.   We should not be calling
> > apr_bucket_read() on a file bucket unless the file is less than
> > AP_MIN_SENDFILE_BYTES.
>
> This isn't strictly true.  If the file is smaller than
> AP_MIN_BYTES_TO_WRITE, and we are on a keepalive connection, then we will
> read the file into memory.  This is done so that we don't have to allocate
> the file out of the connection pool.
>
> What exactly are you seeing?
>
> Ryan
>

Not using apr_sendfile() when we have a file descriptor on a 500 byte file.

Bill


Re: core.c still broken..

Posted by rb...@covalent.net.
On Fri, 11 May 2001, Bill Stoddard wrote:

> This piece of code is still broken.   We should not be calling
> apr_bucket_read() on a file bucket unless the file is less than
> AP_MIN_SENDFILE_BYTES.

This isn't strictly true.  If the file is smaller than
AP_MIN_BYTES_TO_WRITE, and we are on a keepalive connection, then we will
read the file into memory.  This is done so that we don't have to allocate
the file out of the connection pool.

What exactly are you seeing?

Ryan

>
> I'll look into this later because my head is exploding from a nasty sinus
> infection...
>
> Bill
>
>     if ((!fd && !more &&
>             (nbytes + flen < AP_MIN_BYTES_TO_WRITE) &&
> !APR_BUCKET_IS_FLUSH(e))
>             || (nbytes + flen < AP_MIN_BYTES_TO_WRITE &&
> 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.
>              */
>
>             if (APR_BUCKET_IS_EOS(e)) {
>                 apr_bucket *bucket = NULL;
>                 /* If we are in here, then this request is a keepalive.  We
>                  * need to be certain that any data in a bucket is valid
>                  * after the request_pool is cleared.
>                  */
>                 if (ctx->b == NULL) {
>                     ctx->b = apr_brigade_create(f->c->pool);
>                 }
>
>                 APR_BRIGADE_FOREACH(bucket, b) {
>                     const char *str;
>                     apr_size_t n;
>
>                     rv = apr_bucket_read(bucket, &str, &n, APR_BLOCK_READ);
>
>
>


_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------