Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 3322 invoked by uid 500); 4 Mar 2002 22:49:16 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 3311 invoked from network); 4 Mar 2002 22:49:16 -0000 Message-ID: <00f101c1c3cf$22a80d90$06000100@sashimi> From: "Bill Stoddard" To: "APR Development List" , Subject: apr_file_open() and caching file descriptors Date: Mon, 4 Mar 2002 17:51:29 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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); 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