unix,fs: use uv__load_relaxed and uv__store_relaxed

This is more clear about the intended semantics with multiple threads.

PR-URL: https://github.com/libuv/libuv/pull/3124
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
This commit is contained in:
Darshan Sen 2021-05-13 20:48:43 +05:30 committed by GitHub
parent b94934f012
commit 9864053c9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -965,18 +965,20 @@ static ssize_t uv__fs_sendfile(uv_fs_t* req) {
#ifdef __linux__
{
static int copy_file_range_support = 1;
static int no_copy_file_range_support;
if (copy_file_range_support) {
if (uv__load_relaxed(&no_copy_file_range_support) == 0) {
r = uv__fs_copy_file_range(in_fd, &off, out_fd, NULL, req->bufsml[0].len, 0);
if (r == -1 && errno == ENOSYS) {
/* ENOSYS - it will never work */
errno = 0;
copy_file_range_support = 0;
uv__store_relaxed(&no_copy_file_range_support, 1);
} else if (r == -1 && errno == EACCES && uv__is_buggy_cephfs(in_fd)) {
/* EACCES - pre-4.20 kernels have a bug where CephFS uses the RADOS
copy-from command when it shouldn't */
errno = 0;
copy_file_range_support = 0;
uv__store_relaxed(&no_copy_file_range_support, 1);
} else if (r == -1 && (errno == ENOTSUP || errno == EXDEV)) {
/* ENOTSUP - it could work on another file system type */
/* EXDEV - it will not work when in_fd and out_fd are not on the same