> I am trying to make mod_mem_cache cache file descriptors. When opening a file 
> to be
shared
> across threads, we must call apr_file_open() with the APR_XTHREAD option 
> (non-cached
files
> are not and should not be opened with this option).
>
> So, when I am about to cache a file I am serving, I need to use the
> apr_file_open(APR_XTHREAD) call to re-open the file to be put in the cache. 
> What pool to
> pass into the apr_file_open call? I could pass in r->pool, but then the 
> apr_file_t would
> be cleaned up at the end of the request, which is not right.  I could pass in 
> some long
> lived pool but then the pool storage would not be cleaned up when the file is 
> garbage
> collected (because it has expired, changed, whatever). It is unreasonable to 
> give each
> open file its own pool (unless we can make that pool precisely the size of the
apr_file_t,
> which I am assuming cannot be done in a reasonable fashion...).  A 
> conundrum...
>
> I would like to be able to call apr_file_open with an option to suppress 
> registering the
> cleanup, something like this...
>
> apr_file_open(yadda,..., APR_XTHREAD|APR_DO_NOT_REGISTER_CLEANUP, r->pool);

Rather than an option to not register a cleanup, perhaps a function to kill the 
cleanup
would be more generally useful.

apr_file_kill_cleanups(apr_file_t *file);

>
> Then call apr_os_file_get() to retrieve the file descriptor which is the 
> thing I will
put
> in the cache object. When we serve a file out of the cache object, we can call
> apr_os_file_put(cache->fd, r->pool); to create the apr_file_t that we then 
> place in a
file
> bucket.
>
> Thoughts?
>
> Bill
>

Reply via email to