summaryrefslogtreecommitdiff
path: root/file_io/unix
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2017-03-29 00:00:11 +0000
committerYann Ylavic <ylavic@apache.org>2017-03-29 00:00:11 +0000
commit1e05536c4955a6628d1c3362096df1d468eb6a9e (patch)
treea985c4c72aacea9b062bda9178267cc4b9a00651 /file_io/unix
parent402bb66728b6a45df39c0af336ebb9bd706ac8d0 (diff)
downloadapr-1e05536c4955a6628d1c3362096df1d468eb6a9e.tar.gz
apr_dir_read: Since readdir() is now thread safe on most (if not all) unixes
and readdir_r() is defective and deprecated, use the former by default unless APR_USE_READDIR_R is defined (no use case currently hence not autoconfigured). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1789258 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io/unix')
-rw-r--r--file_io/unix/dir.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/file_io/unix/dir.c b/file_io/unix/dir.c
index 28d9e0699..a94eb8e7f 100644
--- a/file_io/unix/dir.c
+++ b/file_io/unix/dir.c
@@ -138,7 +138,9 @@ apr_status_t apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted,
apr_filetype_e type;
#endif
#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) \
- && !defined(READDIR_IS_THREAD_SAFE)
+ && !defined(READDIR_IS_THREAD_SAFE) \
+ && (defined(APR_USE_READDIR64_R) \
+ || defined(APR_USE_READDIR_R))
#ifdef APR_USE_READDIR64_R
struct dirent64 *retent;
@@ -179,9 +181,10 @@ apr_status_t apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted,
ret = APR_ENOENT;
}
#else
- /* We're about to call a non-thread-safe readdir() that may
- possibly set `errno', and the logic below actually cares about
- errno after the call. Therefore we need to clear errno first. */
+ /* We're about to call readdir() that may possibly set errno, and the
+ * logic below actually cares about errno after the call. Therefore
+ * we need to clear errno first.
+ */
errno = 0;
thedir->entry = readdir(thedir->dirstruct);
if (thedir->entry == NULL) {