diff options
author | Yann Ylavic <ylavic@apache.org> | 2021-09-10 00:51:53 +0000 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2021-09-10 00:51:53 +0000 |
commit | 6e6613787d3a8cc24f60a758f7b29f28292ae488 (patch) | |
tree | baf6fe7009f35032e2d66639a87eac30856e7426 /file_io | |
parent | e80637be48a55828e2d453113d3ce12dc401bd8e (diff) | |
download | apr-6e6613787d3a8cc24f60a758f7b29f28292ae488.tar.gz |
apr_file_setaside: don't blindly kill the old cleanup and file descriptor.
There is no cleanup with APR_FOPEN_NOCLEANUP, so apr_pool_cleanup_kill() can
go in the !(old_file->flags & APR_FOPEN_NOCLEANUP) block.
The file descriptor can't be invalidated either, the file may be split in
multiple buckets and setting aside one shouldn't invalidate the others.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1893204 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r-- | file_io/os2/filedup.c | 6 | ||||
-rw-r--r-- | file_io/unix/filedup.c | 5 | ||||
-rw-r--r-- | file_io/win32/filedup.c | 6 |
3 files changed, 6 insertions, 11 deletions
diff --git a/file_io/os2/filedup.c b/file_io/os2/filedup.c index ff937eb68..15040c7c6 100644 --- a/file_io/os2/filedup.c +++ b/file_io/os2/filedup.c @@ -113,14 +113,12 @@ APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, } if (!(old_file->flags & APR_FOPEN_NOCLEANUP)) { + apr_pool_cleanup_kill(old_file->pool, (void *)old_file, + apr_file_cleanup); apr_pool_cleanup_register(p, (void *)(*new_file), apr_file_cleanup, apr_file_cleanup); } - old_file->filedes = -1; - apr_pool_cleanup_kill(old_file->pool, (void *)old_file, - apr_file_cleanup); - return APR_SUCCESS; } diff --git a/file_io/unix/filedup.c b/file_io/unix/filedup.c index c68d2e970..446642b3f 100644 --- a/file_io/unix/filedup.c +++ b/file_io/unix/filedup.c @@ -179,6 +179,8 @@ APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, (*new_file)->fname = apr_pstrdup(p, old_file->fname); } if (!(old_file->flags & APR_FOPEN_NOCLEANUP)) { + apr_pool_cleanup_kill(old_file->pool, (void *)old_file, + apr_unix_file_cleanup); apr_pool_cleanup_register(p, (void *)(*new_file), apr_unix_file_cleanup, ((*new_file)->flags & APR_INHERIT) @@ -186,9 +188,6 @@ APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, : apr_unix_child_file_cleanup); } - old_file->filedes = -1; - apr_pool_cleanup_kill(old_file->pool, (void *)old_file, - apr_unix_file_cleanup); #ifndef WAITIO_USES_POLL (*new_file)->pollset = NULL; #endif diff --git a/file_io/win32/filedup.c b/file_io/win32/filedup.c index eaafaff42..9b4730199 100644 --- a/file_io/win32/filedup.c +++ b/file_io/win32/filedup.c @@ -211,15 +211,13 @@ APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, (*new_file)->fname = apr_pstrdup(p, old_file->fname); } if (!(old_file->flags & APR_FOPEN_NOCLEANUP)) { + apr_pool_cleanup_kill(old_file->pool, (void *)old_file, + file_cleanup); apr_pool_cleanup_register(p, (void *)(*new_file), file_cleanup, file_cleanup); } - old_file->filehand = INVALID_HANDLE_VALUE; - apr_pool_cleanup_kill(old_file->pool, (void *)old_file, - file_cleanup); - #if APR_FILES_AS_SOCKETS /* Create a pollset with room for one descriptor. */ /* ### check return codes */ |