httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <trawi...@bellsouth.net>
Subject Re: cvs commit: apache-2.0/src/main http_core.c http_protocol.c
Date Thu, 21 Sep 2000 17:03:06 GMT
stoddard@locus.apache.org writes:

> stoddard    00/09/21 09:22:14
> 
>   Modified:    src      ApacheCore.dsp
>                src/include ap_buckets.h
>                src/main http_core.c http_protocol.c
>   Log:
>   First cut at a file bucket. Modify the core_filter to handle use
>   of apr_sendfile(). Modify ap_send_fd() to use the new file bucket.
...

>   +         else if (e->type == AP_BUCKET_FILE) {
>   +#if APR_HAS_SENDFILE
>   +             /* If a file bucket gets all the way down to the core filter,
>   +              * the bucket by definition represents the unfiltered contents
>   +              * of a file. Thus it is acceptable to use apr_sendfile().
>   +              */
>   +             rv = send_the_file(e->data, e->offset, e->length, r, &bytes_sent);

I'm thinking that written should be passed instead of bytes_sent, so
that when bytes_sent is incremented by written below we'll get the
right answer.

>   +          
>   +             if (rv == APR_SUCCESS) {

We're not necessarily through with the brigade here.  There could be
more buckets (e.g., AP_BUCKET_EOS).

>   +                 ap_brigade_destroy(b);
>   +                 return APR_SUCCESS;
>   +             }
>   +
>   +             /* If apr_sendfile is not implemented (e.g. Win95/98), then
>   +              * continue to the read/write loop.
>   +              */
>   +             if (rv != APR_ENOTIMPL) {
>   +                 /* check_first_conn_error(r, "send_fd", rv); */
>   +                 return rv;
>   +             }
>   +#endif
>   +         }
>   +         rv = e->read(e, &str, &len, 0);
>   +         if (rv != APR_SUCCESS) {
>   +             return rv;
>   +         }
>   +         rv = ap_bwrite(r->connection->client, str, len, &written);
>   +         if (rv != APR_SUCCESS) {
>   +             return rv;
>   +         }
>   +         bytes_sent += written;
>   +     }
>   +
>        ap_brigade_destroy(b);
>        /* This line will go away as soon as the BUFFs are removed */
>        if (len == AP_END_OF_BRIGADE) {
>   -        ap_bflush(f->r->connection->client);
>   +        ap_bflush(r->connection->client);
>        }
>   +
>        return APR_SUCCESS;
>    #if 0
>        }
>   
>   Index: http_protocol.c

>   +/*
>   + * Send the body of a response to the client.
>   + */
>   +API_EXPORT(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset,

>   +                                    apr_size_t len, apr_size_t *nbytes) 
>    {
...
>   +    ap_bucket_brigade *bb = NULL;
>   +    ap_bucket *b;
>    
>   -    *nbytes = length;
>   +    bb = ap_brigade_create(r->pool);
>   +    b = ap_bucket_create_file(fd, offset, len);
>   +    AP_BRIGADE_INSERT_TAIL(bb, b);
>   +
>   +    /* Hummm, is this the right place to insert eos? */

If no more response body can come after ap_send_fd() returns, then it
is fine to insert eos here.

-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Mime
View raw message