You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by bo...@apache.org on 2007/05/21 08:49:56 UTC
svn commit: r540040 - in /apr/apr/branches/0.9.x: CHANGES
file_io/netware/mktemp.c file_io/unix/filedup.c file_io/unix/mktemp.c
file_io/unix/open.c include/arch/netware/apr_arch_file_io.h
include/arch/unix/apr_arch_file_io.h
Author: bojan
Date: Sun May 20 23:49:55 2007
New Revision: 540040
URL: http://svn.apache.org/viewvc?view=rev&rev=540040
Log:
Backport r538045 from the trunk.
Discard file buffers when running cleanups for exec.
PR 41119.
Original patches by Davi Arnaut.
Modified:
apr/apr/branches/0.9.x/CHANGES
apr/apr/branches/0.9.x/file_io/netware/mktemp.c
apr/apr/branches/0.9.x/file_io/unix/filedup.c
apr/apr/branches/0.9.x/file_io/unix/mktemp.c
apr/apr/branches/0.9.x/file_io/unix/open.c
apr/apr/branches/0.9.x/include/arch/netware/apr_arch_file_io.h
apr/apr/branches/0.9.x/include/arch/unix/apr_arch_file_io.h
Modified: apr/apr/branches/0.9.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/0.9.x/CHANGES?view=diff&rev=540040&r1=540039&r2=540040
==============================================================================
--- apr/apr/branches/0.9.x/CHANGES (original)
+++ apr/apr/branches/0.9.x/CHANGES Sun May 20 23:49:55 2007
@@ -1,5 +1,8 @@
Changes with APR 0.9.14
+ *) Discard file buffers when running cleanups for exec.
+ PR 41119. [Davi Arnaut <davi haxent.com.br>, Bojan Smojver]
+
*) Improve thread safety of assorted file_io functions.
PR 42400. [Davi Arnaut <davi haxent.com.br>]
Modified: apr/apr/branches/0.9.x/file_io/netware/mktemp.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/0.9.x/file_io/netware/mktemp.c?view=diff&rev=540040&r1=540039&r2=540040
==============================================================================
--- apr/apr/branches/0.9.x/file_io/netware/mktemp.c (original)
+++ apr/apr/branches/0.9.x/file_io/netware/mktemp.c Sun May 20 23:49:55 2007
@@ -42,7 +42,8 @@
APR_UREAD | APR_UWRITE, p)) == APR_SUCCESS) {
apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
- apr_unix_file_cleanup, apr_unix_file_cleanup);
+ apr_unix_file_cleanup,
+ apr_unix_child_file_cleanup);
}
return rv;
Modified: apr/apr/branches/0.9.x/file_io/unix/filedup.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/0.9.x/file_io/unix/filedup.c?view=diff&rev=540040&r1=540039&r2=540040
==============================================================================
--- apr/apr/branches/0.9.x/file_io/unix/filedup.c (original)
+++ apr/apr/branches/0.9.x/file_io/unix/filedup.c Sun May 20 23:49:55 2007
@@ -91,7 +91,7 @@
apr_pool_cleanup_register((*new_file)->pool, (void *)(*new_file),
apr_unix_file_cleanup,
- apr_unix_file_cleanup);
+ apr_unix_child_file_cleanup);
return APR_SUCCESS;
}
@@ -139,7 +139,7 @@
apr_unix_file_cleanup,
((*new_file)->flags & APR_INHERIT)
? apr_pool_cleanup_null
- : apr_unix_file_cleanup);
+ : apr_unix_child_file_cleanup);
}
old_file->filedes = -1;
Modified: apr/apr/branches/0.9.x/file_io/unix/mktemp.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/0.9.x/file_io/unix/mktemp.c?view=diff&rev=540040&r1=540039&r2=540040
==============================================================================
--- apr/apr/branches/0.9.x/file_io/unix/mktemp.c (original)
+++ apr/apr/branches/0.9.x/file_io/unix/mktemp.c Sun May 20 23:49:55 2007
@@ -198,7 +198,8 @@
(*fp)->fname = apr_pstrdup(p, template);
apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
- apr_unix_file_cleanup, apr_unix_file_cleanup);
+ apr_unix_file_cleanup,
+ apr_unix_child_file_cleanup);
#endif
return APR_SUCCESS;
}
Modified: apr/apr/branches/0.9.x/file_io/unix/open.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/0.9.x/file_io/unix/open.c?view=diff&rev=540040&r1=540039&r2=540040
==============================================================================
--- apr/apr/branches/0.9.x/file_io/unix/open.c (original)
+++ apr/apr/branches/0.9.x/file_io/unix/open.c Sun May 20 23:49:55 2007
@@ -26,14 +26,10 @@
#include "fsio.h"
#endif
-apr_status_t apr_unix_file_cleanup(void *thefile)
+static apr_status_t file_cleanup(apr_file_t *file)
{
- apr_file_t *file = thefile;
- apr_status_t flush_rv = APR_SUCCESS, rv = APR_SUCCESS;
+ apr_status_t rv = APR_SUCCESS;
- if (file->buffered) {
- flush_rv = apr_file_flush(file);
- }
if (close(file->filedes) == 0) {
file->filedes = -1;
if (file->flags & APR_DELONCLOSE) {
@@ -49,9 +45,28 @@
/* Are there any error conditions other than EINTR or EBADF? */
rv = errno;
}
+ return rv;
+}
+
+apr_status_t apr_unix_file_cleanup(void *thefile)
+{
+ apr_file_t *file = thefile;
+ apr_status_t flush_rv = APR_SUCCESS, rv = APR_SUCCESS;
+
+ if (file->buffered) {
+ flush_rv = apr_file_flush(file);
+ }
+
+ rv = file_cleanup(file);
+
return rv != APR_SUCCESS ? rv : flush_rv;
}
+apr_status_t apr_unix_child_file_cleanup(void *thefile)
+{
+ return file_cleanup(thefile);
+}
+
APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new,
const char *fname,
apr_int32_t flag,
@@ -159,7 +174,7 @@
if (!(flag & APR_FILE_NOCLEANUP)) {
apr_pool_cleanup_register((*new)->pool, (void *)(*new),
apr_unix_file_cleanup,
- apr_unix_file_cleanup);
+ apr_unix_child_file_cleanup);
}
return APR_SUCCESS;
}
@@ -262,6 +277,22 @@
APR_IMPLEMENT_INHERIT_SET(file, flags, pool, apr_unix_file_cleanup)
-APR_IMPLEMENT_INHERIT_UNSET(file, flags, pool, apr_unix_file_cleanup)
+/* We need to do this by hand instead of using APR_IMPLEMENT_INHERIT_UNSET
+ * because the macro sets both cleanups to the same function, which is not
+ * suitable on Unix (see PR 41119). */
+APR_DECLARE(apr_status_t) apr_file_inherit_unset(apr_file_t *thefile)
+{
+ if (thefile->flags & APR_FILE_NOCLEANUP) {
+ return APR_EINVAL;
+ }
+ if (thefile->flags & APR_INHERIT) {
+ thefile->flags &= ~APR_INHERIT;
+ apr_pool_child_cleanup_set(thefile->pool,
+ (void *)thefile,
+ apr_unix_file_cleanup,
+ apr_unix_child_file_cleanup);
+ }
+ return APR_SUCCESS;
+}
APR_POOL_IMPLEMENT_ACCESSOR(file)
Modified: apr/apr/branches/0.9.x/include/arch/netware/apr_arch_file_io.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/0.9.x/include/arch/netware/apr_arch_file_io.h?view=diff&rev=540040&r1=540039&r2=540040
==============================================================================
--- apr/apr/branches/0.9.x/include/arch/netware/apr_arch_file_io.h (original)
+++ apr/apr/branches/0.9.x/include/arch/netware/apr_arch_file_io.h Sun May 20 23:49:55 2007
@@ -149,6 +149,7 @@
apr_status_t filepath_compare_drive(const char *path1, const char *path2, apr_pool_t *p);
apr_status_t apr_unix_file_cleanup(void *);
+apr_status_t apr_unix_child_file_cleanup(void *);
apr_status_t apr_file_flush_locked(apr_file_t *thefile);
apr_status_t apr_file_info_get_locked(apr_finfo_t *finfo, apr_int32_t wanted,
Modified: apr/apr/branches/0.9.x/include/arch/unix/apr_arch_file_io.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/0.9.x/include/arch/unix/apr_arch_file_io.h?view=diff&rev=540040&r1=540039&r2=540040
==============================================================================
--- apr/apr/branches/0.9.x/include/arch/unix/apr_arch_file_io.h (original)
+++ apr/apr/branches/0.9.x/include/arch/unix/apr_arch_file_io.h Sun May 20 23:49:55 2007
@@ -126,6 +126,7 @@
};
apr_status_t apr_unix_file_cleanup(void *);
+apr_status_t apr_unix_child_file_cleanup(void *);
mode_t apr_unix_perms2mode(apr_fileperms_t perms);
apr_fileperms_t apr_unix_mode2perms(mode_t mode);
Re: svn commit: r540040 - in /apr/apr/branches/0.9.x: CHANGES
file_io/netware/mktemp.c file_io/unix/filedup.c file_io/unix/mktemp.c
file_io/unix/open.c include/arch/netware/apr_arch_file_io.h
include/arch/unix/apr_arch_file_io.h
Posted by Bojan Smojver <bo...@rexursive.com>.
On Mon, 2007-05-21 at 09:14 -0600, Brad Nicholes wrote:
> Replacing the macro APR_IMPLEMENT_INHERIT_UNSET with a real function,
> also removed the small macro that creates the deprecated function
> apr_file_unset_inherit(). Although this function is deprecated, it is
> still being used. At least the NetWare build of httpd no longer
> compiles because it can't find apr_file_unset_inherit(). You will
> probably need to reimplement this deprecated function for APR 0.9.x.
Thanks for pointing it out. Fixed in r540365.
--
Bojan
Re: svn commit: r540040 - in /apr/apr/branches/0.9.x: CHANGES
file_io/netware/mktemp.c file_io/unix/filedup.c
file_io/unix/mktemp.c file_io/unix/open.c
include/arch/netware/apr_arch_file_io.h
include/arch/unix/apr_arch_file_io.h
Posted by Brad Nicholes <BN...@novell.com>.
>>> On 5/21/2007 at 12:49 AM, in message
<20...@eris.apache.org>, <bo...@apache.org> wrote:
> Author: bojan
> Date: Sun May 20 23:49:55 2007
> New Revision: 540040
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=540040
> Log:
> Backport r538045 from the trunk.
> Discard file buffers when running cleanups for exec.
> PR 41119.
> Original patches by Davi Arnaut.
>
> Modified:
> apr/apr/branches/0.9.x/CHANGES
> apr/apr/branches/0.9.x/file_io/netware/mktemp.c
> apr/apr/branches/0.9.x/file_io/unix/filedup.c
> apr/apr/branches/0.9.x/file_io/unix/mktemp.c
> apr/apr/branches/0.9.x/file_io/unix/open.c
> apr/apr/branches/0.9.x/include/arch/netware/apr_arch_file_io.h
> apr/apr/branches/0.9.x/include/arch/unix/apr_arch_file_io.h
>
...
> Modified: apr/apr/branches/0.9.x/file_io/unix/open.c
> URL:
> http://svn.apache.org/viewvc/apr/apr/branches/0.9.x/file_io/unix/open.c?view=
> diff&rev=540040&r1=540039&r2=540040
> ============================================================================
> ==
> --- apr/apr/branches/0.9.x/file_io/unix/open.c (original)
> +++ apr/apr/branches/0.9.x/file_io/unix/open.c Sun May 20 23:49:55 2007
...
> @@ -262,6 +277,22 @@
>
> APR_IMPLEMENT_INHERIT_SET(file, flags, pool, apr_unix_file_cleanup)
>
> -APR_IMPLEMENT_INHERIT_UNSET(file, flags, pool, apr_unix_file_cleanup)
> +/* We need to do this by hand instead of using APR_IMPLEMENT_INHERIT_UNSET
> + * because the macro sets both cleanups to the same function, which is not
> + * suitable on Unix (see PR 41119). */
> +APR_DECLARE(apr_status_t) apr_file_inherit_unset(apr_file_t *thefile)
> +{
> + if (thefile->flags & APR_FILE_NOCLEANUP) {
> + return APR_EINVAL;
> + }
> + if (thefile->flags & APR_INHERIT) {
> + thefile->flags &= ~APR_INHERIT;
> + apr_pool_child_cleanup_set(thefile->pool,
> + (void *)thefile,
> + apr_unix_file_cleanup,
> + apr_unix_child_file_cleanup);
> + }
> + return APR_SUCCESS;
> +}
>
> APR_POOL_IMPLEMENT_ACCESSOR(file)
>
Replacing the macro APR_IMPLEMENT_INHERIT_UNSET with a real function, also removed the small macro that creates the deprecated function apr_file_unset_inherit(). Although this function is deprecated, it is still being used. At least the NetWare build of httpd no longer compiles because it can't find apr_file_unset_inherit(). You will probably need to reimplement this deprecated function for APR 0.9.x.
Brad