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).
@@ -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) {
