httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Stoddard" <>
Subject Re: apr_file_open() and caching file descriptors
Date Mon, 04 Mar 2002 23:09:59 GMT

> I am trying to make mod_mem_cache cache file descriptors. When opening a file to be
> across threads, we must call apr_file_open() with the APR_XTHREAD option (non-cached
> 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
> pass into the apr_file_open call? I could pass in r->pool, but then the apr_file_t
> 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
> 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
> 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
> 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
> bucket.
> Thoughts?
> Bill

View raw message