You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by wr...@apache.org on 2019/04/01 17:37:17 UTC

svn commit: r1856755 - in /apr/apr/trunk: configure.in file_io/unix/dir.c

Author: wrowe
Date: Mon Apr  1 17:37:16 2019
New Revision: 1856755

URL: http://svn.apache.org/viewvc?rev=1856755&view=rev
Log:
Revert r1789258, r1856189, r1856191 following discussion on list, in favor
of a simpler path of avoiding dirread_r always, by default. This saves us
various additional detection logic, and follows advice of library maintainers
and our library's behavior, any apparent "thread safety" offered by the _r()
flavors of this function were not truly supported by APR's allocation or
dirread_r reentrancy of parallel threads attemping to access the same open
directory descriptor.

Retains r1856192, r1856196 to avoid wasteful allocation in the dirread() case.


Modified:
    apr/apr/trunk/configure.in
    apr/apr/trunk/file_io/unix/dir.c

Modified: apr/apr/trunk/configure.in
URL: http://svn.apache.org/viewvc/apr/apr/trunk/configure.in?rev=1856755&r1=1856754&r2=1856755&view=diff
==============================================================================
--- apr/apr/trunk/configure.in (original)
+++ apr/apr/trunk/configure.in Mon Apr  1 17:37:16 2019
@@ -845,31 +845,8 @@ ac_cv_define_GETSERVBYNAME_IS_THREAD_SAF
 if test "$threads" = "1"; then
     AC_MSG_NOTICE([APR will use threads])
     AC_CHECK_LIB(c_r, readdir,
-                 apr_readdir_is_thread_safe=yes)
-    if test "x$apr_readdir_is_thread_safe" = "x"; then
-        AC_CHECK_HEADERS(dirent.h)
-        AC_CHECK_FUNCS(readdir_r)
-        APR_IFALLYES(header:dirent.h func:readdir_r,
-                     apr_has_readdir_r="1", apr_has_readdir_r="0")
-        if test "$apr_has_readdir_r" = "1"; then
-            dnl readdir_r() may exist but be deprecated, meaning
-            dnl the readdir() itself is thread-safe
-            APR_TRY_COMPILE_NO_WARNING([
-                #include <sys/types.h>
-                #include <dirent.h>
-            ],
-            [
-                DIR *dir = opendir("/tmp");
-                struct dirent entry, *result;
-                return readdir_r(dir, &entry, &result) != 0;
-            ], apr_readdir_is_thread_safe=no, apr_readdir_is_thread_safe=yes)
-        fi
-    fi
-    if test "$apr_readdir_is_thread_safe" = "yes"; then
-        AC_MSG_NOTICE([APR will use thread-safe readdir()])
         AC_DEFINE(READDIR_IS_THREAD_SAFE, 1, 
-                  [Define if readdir is thread safe])
-    fi
+                  [Define if readdir is thread safe]))
     if test "x$apr_gethostbyname_is_thread_safe" = "x"; then
         AC_CHECK_LIB(c_r, gethostbyname, apr_gethostbyname_is_thread_safe=yes)
     fi

Modified: apr/apr/trunk/file_io/unix/dir.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/unix/dir.c?rev=1856755&r1=1856754&r2=1856755&view=diff
==============================================================================
--- apr/apr/trunk/file_io/unix/dir.c (original)
+++ apr/apr/trunk/file_io/unix/dir.c Mon Apr  1 17:37:16 2019
@@ -188,10 +188,9 @@ apr_status_t apr_dir_read(apr_finfo_t *f
         ret = APR_ENOENT;
     }
 #else
-    /* 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.
-     */
+    /* 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. */
     errno = 0;
     thedir->entry = readdir(thedir->dirstruct);
     if (thedir->entry == NULL) {