Skip to content

Commit ea73af5

Browse files
committedJan 22, 2020
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.
1 parent b19cfa5 commit ea73af5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed
 

‎src/fd_table.c

+1-1
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
}

‎src/uvwasi.c

+4-4
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)
Please sign in to comment.