From 09566be899469c36ddb6784e0fc023a1868573f8 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Tue, 21 Jan 2020 09:29:36 -0500 Subject: [PATCH] deps: uvwasi: cherry-pick ea73af5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message: unlock all fd mutexes in reverse order Some functions acquire mutexes for multiple file descriptors. This commit ensures that the mutexes are released in the reverse order that they are aquired. PR-URL: https://github.com/nodejs/node/pull/31432 Reviewed-By: Tobias Nießen Reviewed-By: Ben Noordhuis Reviewed-By: David Carlier Reviewed-By: Rich Trott Reviewed-By: Jiawen Geng --- deps/uvwasi/src/fd_table.c | 2 +- deps/uvwasi/src/uvwasi.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/deps/uvwasi/src/fd_table.c b/deps/uvwasi/src/fd_table.c index b6a43f0370e1e2..e4897769d987e1 100644 --- a/deps/uvwasi/src/fd_table.c +++ b/deps/uvwasi/src/fd_table.c @@ -366,8 +366,8 @@ uvwasi_errno_t uvwasi_fd_table_renumber(struct uvwasi_s* uvwasi, r = uv_fs_close(NULL, &req, dst_entry->fd, NULL); uv_fs_req_cleanup(&req); if (r != 0) { - uv_mutex_unlock(&dst_entry->mutex); uv_mutex_unlock(&src_entry->mutex); + uv_mutex_unlock(&dst_entry->mutex); err = uvwasi__translate_uv_error(r); goto exit; } diff --git a/deps/uvwasi/src/uvwasi.c b/deps/uvwasi/src/uvwasi.c index 5a73bfee777e0a..e4c2ac6e3b0dd1 100644 --- a/deps/uvwasi/src/uvwasi.c +++ b/deps/uvwasi/src/uvwasi.c @@ -1821,9 +1821,9 @@ uvwasi_errno_t uvwasi_path_link(uvwasi_t* uvwasi, err = UVWASI_ESUCCESS; exit: - uv_mutex_unlock(&old_wrap->mutex); + uv_mutex_unlock(&new_wrap->mutex); if (old_fd != new_fd) - uv_mutex_unlock(&new_wrap->mutex); + uv_mutex_unlock(&old_wrap->mutex); return err; } @@ -2136,9 +2136,9 @@ uvwasi_errno_t uvwasi_path_rename(uvwasi_t* uvwasi, err = UVWASI_ESUCCESS; exit: - uv_mutex_unlock(&old_wrap->mutex); + uv_mutex_unlock(&new_wrap->mutex); if (old_fd != new_fd) - uv_mutex_unlock(&new_wrap->mutex); + uv_mutex_unlock(&old_wrap->mutex); return err; }