ok.  then how about a new apr_file_xread() function and changing
bucket_read to use it?

something like:
apr_status_t apr_file_xread(apr_file_t **f, void *buf,
                            apr_size_t *nbytes, apr_off_t *offset,
                            apr_pool_t *pool)
{
    apr_status_t rv;
#if APR_HAS_THREADS && !APR_HAS_XTHREAD_FILES
    apr_int32_t flags;
#endif

#if APR_HAS_THREADS && !APR_HAS_XTHREAD_FILES
    if ((flags = apr_file_flags_get(f)) & APR_XTHREAD) {
        /* this file descriptor is shared across multiple threads and
         * this OS doesn't support that natively, so as a workaround
         * we must reopen the file into pool */
        const char *fname;
        apr_file_name_get(&fname, *f);

        rv = apr_file_open(*f, fname, (flags & ~APR_XTHREAD), 0, pool);
        if (rv != APR_SUCCESS)
            return rv;
    }
#endif

    /* Handle offset ... */
    rv = apr_file_seek(*f, APR_SET, offset);
    if (rv != APR_SUCCESS) {
        return rv;
    }

    return apr_file_read(*f, buf, nbytes);
}


Reply via email to