commit | 6b021dac1112e90488d1d6fb710d97a8f9085e76 | [log] [tgz] |
---|---|---|
author | Alexey Serbin <alexey@apache.org> | Wed Sep 16 20:37:28 2020 -0700 |
committer | Alexey Serbin <aserbin@cloudera.com> | Thu Sep 17 21:21:10 2020 +0000 |
tree | d4337636f118cfb374166ef99375733a42a47a9a | |
parent | 7bc5d4e415d44aca6af4acd08aaaf1cf5a6860a1 [diff] |
[util] fix BaseName() on BSD-derived systems basename() is thread-safe on Linux in relatively new glibc implementations as per its manual page [1]. However, basename() is not thread-safe at least on contemporary version of Darwin/macOS as per basename() manual page ([2], [3], [4]): The basename() function returns a pointer to internal static storage space that will be overwritten by subsequent calls. So, let's use thread-safe basename_r() on macOS. With that, the only test scenario in file_cache-stress-test no longer fails on macOS. As a bit of bigger picture, starting FreeBSD 12.0, the basename() function was reimplemented to store its result in the provided input buffer [5]. [1] https://www.man7.org/linux/man-pages/man3/basename.3.html [2] https://www.freebsd.org/cgi/man.cgi?query=basename&sektion=3&manpath=Darwin+7.0.1 [3] https://www.unix.com/man-page/mojave/3/basename/ [4] https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/basename.3.html [5] https://www.freebsd.org/cgi/man.cgi?query=basename&sektion=3&manpath=FreeBSD+12.0-RELEASE Change-Id: I26b81757e48e0b7d5f79582349548f6e9e474d90 Reviewed-on: http://gerrit.cloudera.org:8080/16466 Tested-by: Alexey Serbin <aserbin@cloudera.com> Reviewed-by: Grant Henke <granthenke@apache.org>