httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cliff Woolley <>
Subject Re: Implementing split() on pipe buckets?
Date Sun, 12 Nov 2000 02:54:47 GMT

--- Cliff Woolley <> wrote:
> That's why I mentioned in my preceding comments that pipe_split() might want to
> check the value of *len after calling pipe_readn(), comparing it to the value it
> passed in.  If the two differ, then there wasn't enough data in the pipe to split
> at the right place.  In that case, APR_EINVAL would be returned.  The pipe bucket
> would have been morphed in the process, but that's going to happen as soon as
> you read it anyway.

Like so:

static apr_status_t pipe_split(ap_bucket *a, apr_off_t point)
    apr_size_t *len;
    const char **str;
    apr_status_t rv;

    if (point < 0) {
        return APR_EINVAL;
    *len = point;
     * pipe_readn() takes care of the split for us.
     * its real purpose (to provide str) is just treated
     * as a side-effect here and str is ignored.  this
     * is fine since pipe_readn split the pipe into a heap
     * bucket (containing str) and a pipe bucket (containing
     * the rest of the pipe after *len bytes) anyway
    /* XXX: should this use AP_NONBLOCK_READ or not? */
    rv = pipe_readn(a, str, len, AP_NONBLOCK_READ);
    if (rv != APR_SUCCESS) {
        return rv;
    if (*len != point) {
        /* there wasn't enough data in the pipe to
         * split at the right place */
        return APR_EINVAL;
    return APR_SUCCESS;

Do You Yahoo!?
Yahoo! Calendar - Get organized for the holidays!

View raw message