Skip to content

Commit

Permalink
deps: uvwasi: cherry-pick ea73af5
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
cjihrig authored and codebytere committed Feb 17, 2020
1 parent 04f2799 commit 09566be
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion deps/uvwasi/src/fd_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions deps/uvwasi/src/uvwasi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 09566be

Please sign in to comment.