You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by "Brian J. France" <li...@firehawksystems.com> on 2007/03/21 15:31:13 UTC

mktemp.c patch

Here is a patch that makes apr_file_mktemp check for the  
APR_FILE_NOCLEANUP flag and not register a cleanup passed in.

APR_FILE_NOCLEANUP is being used in other places, but  
APR_FOPEN_NOCLEANUP might be a better choice.

Brian

Index: mktemp.c
===================================================================
--- mktemp.c    (revision 520897)
+++ mktemp.c    (working copy)
@@ -202,8 +202,10 @@
      apr_os_file_put(fp, &fd, flags, p);
      (*fp)->fname = apr_pstrdup(p, template);
-    apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
-                              apr_unix_file_cleanup,  
apr_unix_file_cleanup);
+    if (!(flag & APR_FILE_NOCLEANUP)) {
+       apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
+                                 apr_unix_file_cleanup,  
apr_unix_file_cleanup);
+    }
#endif
      return APR_SUCCESS;
}

Re: mktemp.c patch

Posted by "Brian J. France" <li...@firehawksystems.com>.
Doh! New patch (flag should have been flags).

Brian


On Mar 21, 2007, at 10:31 AM, Brian J. France wrote:

> Here is a patch that makes apr_file_mktemp check for the  
> APR_FILE_NOCLEANUP flag and not register a cleanup passed in.
>
> APR_FILE_NOCLEANUP is being used in other places, but  
> APR_FOPEN_NOCLEANUP might be a better choice.
>
> Brian

Index: mktemp.c
===================================================================
--- mktemp.c    (revision 520899)
+++ mktemp.c    (working copy)
@@ -202,8 +202,10 @@
      apr_os_file_put(fp, &fd, flags, p);
      (*fp)->fname = apr_pstrdup(p, template);
-    apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
-                              apr_unix_file_cleanup,  
apr_unix_file_cleanup);
+    if (!(flags & APR_FILE_NOCLEANUP)) {
+       apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
+                                 apr_unix_file_cleanup,  
apr_unix_file_cleanup);
+    }
#endif
      return APR_SUCCESS;
}