On Tue, Mar 26, 2019 at 3:35 AM <yla...@apache.org> wrote: > Author: ylavic > Date: Tue Mar 26 08:35:35 2019 > New Revision: 1856274 > > URL: http://svn.apache.org/viewvc?rev=1856274&view=rev > Log: > Merge r1789258, r1856189, r1856191, r1856192, r1856196 from trunk: > > > 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). > > > Follow up to r1789258: configure to detect whether readdir() is > thread-safe. > > On platforms where readdir_r() is available but deprecated, readdir() is to > be used although it's not in libc_r (e.g. Linux has no libc_r). > > In this case we can APR_TRY_COMPILE_NO_WARNING readdir_r() and, if it's > deprecated, define READDIR_IS_THREAD_SAFE. > > With this we don't need user-defined APR_USE_READDIR{,64}_R from r1789258. > > > Follow up to r1856189: sys/types.h possibly needed. > > > Follow up to r1856189: use NAME_MAX from limits.h when available. > > > apr_dir: no need to allocate our dir entry if readdir{,64}_r() is not used. > > Modified: > apr/apr/branches/1.7.x/ (props changed) > apr/apr/branches/1.7.x/configure.in > apr/apr/branches/1.7.x/file_io/unix/dir.c > > URL: > http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/configure.in?rev=1856274&r1=1856273&r2=1856274&view=diff > > ============================================================================== > --- apr/apr/branches/1.7.x/configure.in (original) > +++ apr/apr/branches/1.7.x/configure.in Tue Mar 26 08:35:35 2019 > @@ -817,8 +817,31 @@ ac_cv_define_GETSERVBYNAME_IS_THREAD_SAF > if test "$threads" = "1"; then > echo "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])) > + [Define if readdir is thread safe]) > + fi > if test "x$apr_gethostbyname_is_thread_safe" = "x"; then > AC_CHECK_LIB(c_r, gethostbyname, > apr_gethostbyname_is_thread_safe=yes) > fi >
Let me just throw this out there and get your reaction, Yann, now that I'm back in town... The patch I was initially using to accomplish the equivalent was as simple as; --- configure.in (revision 1839621) +++ configure.in (working copy) @@ -835,15 +835,13 @@ fi fi -ac_cv_define_READDIR_IS_THREAD_SAFE=no +ac_cv_define_READDIR_IS_THREAD_SAFE=yes ac_cv_define_GETHOSTBYNAME_IS_THREAD_SAFE=no ac_cv_define_GETHOSTBYADDR_IS_THREAD_SAFE=no ac_cv_define_GETSERVBYNAME_IS_THREAD_SAFE=no if test "$threads" = "1"; then AC_MSG_NOTICE([APR will use threads]) - AC_CHECK_LIB(c_r, readdir, - AC_DEFINE(READDIR_IS_THREAD_SAFE, 1, - [Define if readdir is thread safe])) + AC_DEFINE(READDIR_IS_THREAD_SAFE, 1, [Modern 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 Seems much less wordy for a feature we agree should just be dropped altogether fairly soon. Thoughts?