Skip to content

Commit 09566be

Browse files
cjihrigcodebytere
authored andcommitted
deps: uvwasi: cherry-pick ea73af5
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: #31432 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Jiawen Geng <[email protected]>
1 parent 04f2799 commit 09566be

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

deps/uvwasi/src/fd_table.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ uvwasi_errno_t uvwasi_fd_table_renumber(struct uvwasi_s* uvwasi,
366366
r = uv_fs_close(NULL, &req, dst_entry->fd, NULL);
367367
uv_fs_req_cleanup(&req);
368368
if (r != 0) {
369-
uv_mutex_unlock(&dst_entry->mutex);
370369
uv_mutex_unlock(&src_entry->mutex);
370+
uv_mutex_unlock(&dst_entry->mutex);
371371
err = uvwasi__translate_uv_error(r);
372372
goto exit;
373373
}

deps/uvwasi/src/uvwasi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,9 +1821,9 @@ uvwasi_errno_t uvwasi_path_link(uvwasi_t* uvwasi,
18211821

18221822
err = UVWASI_ESUCCESS;
18231823
exit:
1824-
uv_mutex_unlock(&old_wrap->mutex);
1824+
uv_mutex_unlock(&new_wrap->mutex);
18251825
if (old_fd != new_fd)
1826-
uv_mutex_unlock(&new_wrap->mutex);
1826+
uv_mutex_unlock(&old_wrap->mutex);
18271827
return err;
18281828
}
18291829

@@ -2136,9 +2136,9 @@ uvwasi_errno_t uvwasi_path_rename(uvwasi_t* uvwasi,
21362136

21372137
err = UVWASI_ESUCCESS;
21382138
exit:
2139-
uv_mutex_unlock(&old_wrap->mutex);
2139+
uv_mutex_unlock(&new_wrap->mutex);
21402140
if (old_fd != new_fd)
2141-
uv_mutex_unlock(&new_wrap->mutex);
2141+
uv_mutex_unlock(&old_wrap->mutex);
21422142

21432143
return err;
21442144
}

0 commit comments

Comments
 (0)