summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2003-03-22 02:30:42 +0000
committerwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2003-03-22 02:30:42 +0000
commitefc746506079540bff6ea7b8bd7dc44f79a5a268 (patch)
tree438a6d40573453bdce988be0b168ac0780f89147
parentc4ec4ab96eb61e7a998b1adcba7662cce185b537 (diff)
downloadlibapr-efc746506079540bff6ea7b8bd7dc44f79a5a268.tar.gz
Given two solutions to the current mpm inheritence bugs,
1) track the target file's existing flags and register the proper sort of cleanup (a bug in the new design) or 2) revert to the previous behavior and retain the existing cleanup I've gone with option 2, since Joe Orton has expressed concern with introducing too many changes in the coming release. However, this implies that; apr_file_close(fd1); apr_file_dup2(fd1, fd2); is absolutely unsupported. Since it wouldn't work on Win32 in the first place, I'm not terribly concerned about this limitation. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64441 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--file_io/unix/filedup.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/file_io/unix/filedup.c b/file_io/unix/filedup.c
index 6a6f0d5ee..6997ff238 100644
--- a/file_io/unix/filedup.c
+++ b/file_io/unix/filedup.c
@@ -109,6 +109,16 @@ static apr_status_t _file_dup(apr_file_t **new_file,
/* make sure unget behavior is consistent */
(*new_file)->ungetchar = old_file->ungetchar;
+ /* apr_file_dup2() retains the original cleanup, reflecting
+ * the existing inherit and nocleanup flags. This means,
+ * that apr_file_dup2() cannot be called against an apr_file_t
+ * already closed with apr_file_close, because the expected
+ * cleanup was already killed.
+ */
+ if (which_dup == 2) {
+ return APR_SUCCESS;
+ }
+
/* apr_file_dup() clears the inherit attribute for normal files,
* but sets the inherit attribute for std[out,in,err] fd's.
* The user must call apr_file_inherit_[un]set() on the dupped
@@ -139,14 +149,6 @@ APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file,
APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file,
apr_file_t *old_file, apr_pool_t *p)
{
- /* an existing apr_file_t may already be closed, and therefore
- * have no cleanup remaining; but we don't want to double-register
- * the same cleanup in _file_dup. Kill the existing cleanup before
- * invoking _file_dup to the existing new_file.
- */
- apr_pool_cleanup_kill(new_file->pool, (void *)(new_file),
- apr_unix_file_cleanup);
-
return _file_dup(&new_file, old_file, p, 2);
}