Skip to content

Commit 5e7f487

Browse files
committed
Pull latest changes/fixes
1 parent 27882b1 commit 5e7f487

File tree

5 files changed

+103
-6
lines changed

5 files changed

+103
-6
lines changed

deps/uv/src/unix/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,13 +1882,13 @@ int uv__search_path(const char* prog, char* buf, size_t* buflen) {
18821882
#if defined(__linux__) || defined (__FreeBSD__)
18831883
# define uv__cpu_count(cpuset) CPU_COUNT(cpuset)
18841884
#elif defined(__NetBSD__)
1885-
static int uv__cpu_count(cpuset_t *cpuset) {
1885+
static int uv__cpu_count(cpuset_t* set) {
18861886
int rc;
18871887
cpuid_t i;
18881888

18891889
rc = 0;
18901890
for (i = 0;; i++) {
1891-
int r = cpuset_isset(cpu, set);
1891+
int r = cpuset_isset(i, set);
18921892
if (r < 0)
18931893
break;
18941894
if (r)

deps/uv/src/unix/fs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,12 @@ static ssize_t uv__pwritev_emul(int fd,
461461

462462
/* The function pointer cache is an uintptr_t because _Atomic void*
463463
* doesn't work on macos/ios/etc...
464+
* Disable optimization on armv7 to work around the bug described in
465+
* https://github.com/libuv/libuv/issues/4532
464466
*/
467+
#if defined(__arm__) && (__ARM_ARCH == 7)
468+
__attribute__((optimize("O0")))
469+
#endif
465470
static ssize_t uv__preadv_or_pwritev(int fd,
466471
const struct iovec* bufs,
467472
size_t nbufs,

deps/uv/src/win/fs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,12 +1651,12 @@ void fs__readdir(uv_fs_t* req) {
16511651
goto error;
16521652

16531653
/* Copy file type. */
1654-
if ((find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
1655-
dent.d_type = UV__DT_DIR;
1654+
if ((find_data->dwFileAttributes & FILE_ATTRIBUTE_DEVICE) != 0)
1655+
dent.d_type = UV__DT_CHAR;
16561656
else if ((find_data->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0)
16571657
dent.d_type = UV__DT_LINK;
1658-
else if ((find_data->dwFileAttributes & FILE_ATTRIBUTE_DEVICE) != 0)
1659-
dent.d_type = UV__DT_CHAR;
1658+
else if ((find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
1659+
dent.d_type = UV__DT_DIR;
16601660
else
16611661
dent.d_type = UV__DT_FILE;
16621662

deps/uv/test/test-fs-readdir.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ static uv_fs_t readdir_req;
2929
static uv_fs_t closedir_req;
3030

3131
static uv_dirent_t dirents[1];
32+
static uv_dirent_t symlink_dirents[2];
3233

3334
static int empty_opendir_cb_count;
3435
static int empty_closedir_cb_count;
@@ -460,3 +461,88 @@ TEST_IMPL(fs_readdir_non_empty_dir) {
460461
MAKE_VALGRIND_HAPPY(uv_default_loop());
461462
return 0;
462463
}
464+
465+
static void readdir_symlink_readdir_cb(uv_fs_t* req) {
466+
uv_dir_t* dir;
467+
468+
ASSERT_PTR_EQ(req, &readdir_req);
469+
ASSERT_EQ(req->fs_type, UV_FS_READDIR);
470+
dir = req->ptr;
471+
472+
if (req->result == 0) {
473+
uv_fs_req_cleanup(req);
474+
ASSERT_EQ(3, non_empty_readdir_cb_count);
475+
uv_fs_closedir(uv_default_loop(),
476+
&closedir_req,
477+
dir,
478+
non_empty_closedir_cb);
479+
} else {
480+
if (strcmp(symlink_dirents[0].name, "test_symlink") == 0) {
481+
ASSERT_EQ(symlink_dirents[0].type, UV_DIRENT_LINK);
482+
} else {
483+
ASSERT_EQ(symlink_dirents[1].type, UV_DIRENT_LINK);
484+
}
485+
uv_fs_req_cleanup(req);
486+
}
487+
}
488+
489+
static void readdir_symlink_opendir_cb(uv_fs_t* req) {
490+
uv_dir_t* dir;
491+
int r;
492+
493+
ASSERT_PTR_EQ(req, &opendir_req);
494+
ASSERT_EQ(req->fs_type, UV_FS_OPENDIR);
495+
ASSERT_OK(req->result);
496+
ASSERT_NOT_NULL(req->ptr);
497+
498+
dir = req->ptr;
499+
dir->dirents = symlink_dirents;
500+
dir->nentries = ARRAY_SIZE(symlink_dirents);
501+
502+
r = uv_fs_readdir(uv_default_loop(),
503+
&readdir_req,
504+
dir,
505+
readdir_symlink_readdir_cb);
506+
ASSERT_OK(r);
507+
uv_fs_req_cleanup(req);
508+
}
509+
510+
static void cleanup_symlink_test_files(void) {
511+
uv_fs_t req;
512+
513+
uv_fs_rmdir(NULL, &req, "test_symlink_dir/test_subdir", NULL);
514+
uv_fs_req_cleanup(&req);
515+
uv_fs_unlink(NULL, &req, "test_symlink_dir/test_symlink", NULL);
516+
uv_fs_req_cleanup(&req);
517+
uv_fs_rmdir(NULL, &req, "test_symlink_dir", NULL);
518+
uv_fs_req_cleanup(&req);
519+
}
520+
521+
TEST_IMPL(fs_readdir_symlink) {
522+
523+
uv_fs_t mkdir_req;
524+
uv_fs_t symlink_req;
525+
int r;
526+
527+
cleanup_symlink_test_files();
528+
529+
r = uv_fs_mkdir(uv_default_loop(), &mkdir_req, "test_symlink_dir", 0755, NULL);
530+
ASSERT_OK(r);
531+
532+
r = uv_fs_mkdir(uv_default_loop(), &mkdir_req, "test_symlink_dir/test_subdir", 0755, NULL);
533+
ASSERT_OK(r);
534+
535+
r = uv_fs_symlink(uv_default_loop(), &symlink_req, "test_symlink_dir/test_subdir", "test_symlink_dir/test_symlink", UV_FS_SYMLINK_DIR, NULL);
536+
ASSERT_OK(r);
537+
538+
r = uv_fs_opendir(uv_default_loop(), &opendir_req, "test_symlink_dir", readdir_symlink_opendir_cb);
539+
ASSERT_OK(r);
540+
541+
r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
542+
ASSERT_OK(r);
543+
544+
cleanup_symlink_test_files();
545+
546+
MAKE_VALGRIND_HAPPY(uv_default_loop());
547+
return 0;
548+
}

deps/uv/test/test-list.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,9 @@ TEST_DECLARE (fs_readdir_empty_dir)
428428
TEST_DECLARE (fs_readdir_file)
429429
TEST_DECLARE (fs_readdir_non_empty_dir)
430430
TEST_DECLARE (fs_readdir_non_existing_dir)
431+
#ifdef _WIN32
432+
TEST_DECLARE (fs_readdir_symlink)
433+
#endif
431434
TEST_DECLARE (fs_rename_to_existing_file)
432435
TEST_DECLARE (fs_write_multiple_bufs)
433436
TEST_DECLARE (fs_read_write_null_arguments)
@@ -1138,6 +1141,9 @@ TASK_LIST_START
11381141
TEST_ENTRY (fs_readdir_file)
11391142
TEST_ENTRY (fs_readdir_non_empty_dir)
11401143
TEST_ENTRY (fs_readdir_non_existing_dir)
1144+
#ifdef _WIN32
1145+
TEST_ENTRY (fs_readdir_symlink)
1146+
#endif
11411147
TEST_ENTRY (fs_rename_to_existing_file)
11421148
TEST_ENTRY (fs_write_multiple_bufs)
11431149
TEST_ENTRY (fs_write_alotof_bufs)

0 commit comments

Comments
 (0)