uvwasi_fd_close() performed the following operations:
lock the file descriptor mutex
close the file
release the file descriptor mutex
call the file table's remove() function
Once the fd's mutex is released, another thread could acquire it
before the fd is removed from the file table. If this happens,
remove() could destroy a held mutex.
This commit updates uvwasi_fd_close() to perform the entire
sequence while holding the file table's lock, preventing new
acquisitions of the fd's mutex.
This depends on https://github.com/cjihrig/uvwasi/pull/90 (the first commit in this PR).
uvwasi_fd_close()
performed the following operations:remove()
functionOnce the fd's mutex is released, another thread could acquire it before the fd is removed from the file table. If this happens,
remove()
could destroy a held mutex.This commit updates
uvwasi_fd_close()
to perform the entire sequence while holding the file table's lock, preventing new acquisitions of the fd's mutex.Fixes: https://github.com/cjihrig/uvwasi/issues/88