On Fri, 9 Mar 2007, Joe Schaefer wrote:

Randy, do you know why we use the APR_FILE_NOCLEANUP flag?  Maybe
we should just remove that and see if it fixes the problem Vinay
is seeing.

Hi Steve, and all,
 If you remember from
   http://marc.theaimsgroup.com/?t=115337629400001&r=1&w=2
there was a problem with stray temp files in apreq
remaining after uploads; we came up with a fix that
worked most of the time, but Vinay has come up with
something that appears better, and more understandable.
The attached diff against library/util.c (in the svn
sources) works for me in getting multiple invocations
of the glue/perl/t/apreq/upload.t to pass; if you have
time, could you try it out to see how it fares on
your system? Thanks.

--
best regards,
Randy
Index: util.c
===================================================================
--- util.c      (revision 516656)
+++ util.c      (working copy)
@@ -775,12 +775,14 @@
 
 struct cleanup_data {
     const char *fname;
+    apr_file_t *f;
     apr_pool_t *pool;
 };
 
 static apr_status_t apreq_file_cleanup(void *d)
 {
     struct cleanup_data *data = d;
+    apr_file_close(data->f);
     return apr_file_remove(data->fname, data->pool);
 }
 
@@ -823,19 +825,12 @@
 
     /* NO APR_DELONCLOSE! see comment above */
     flag = APR_CREATE | APR_READ | APR_WRITE | APR_EXCL | APR_BINARY;
-    /* Win32 needs the following to remove temp files.
-     * XXX: figure out why the APR_SHARELOCK flag works;
-     * a grep through the httpd sources seems to indicate
-     * it's only used in sdbm files??
-    */
-#ifdef WIN32
-    flag |= APR_FILE_NOCLEANUP | APR_SHARELOCK;
-#endif
-    rc = apr_file_mktemp(fp, tmpl, flag, pool);
 
+    rc = apr_file_mktemp(fp, tmpl, flag, pool);
     if (rc == APR_SUCCESS) {
         apr_file_name_get(&data->fname, *fp);
         data->pool = pool;
+        data->f = *fp;
     }
     else {
         apr_pool_cleanup_kill(pool, data, apreq_file_cleanup);

Reply via email to