Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a patch for corrupt freed FD lists after replaying journals #4990

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/wasix/src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,11 @@ impl WasiFs {
}
}

pub fn clear_free_fd_list(&self) {
john-sharratt marked this conversation as resolved.
Show resolved Hide resolved
let mut freed_fds = self.freed_fds.write().unwrap();
freed_fds.clear();
}

/// Closes all the file handles.
#[allow(clippy::await_holding_lock)]
pub async fn close_all(&self) {
Expand Down
4 changes: 4 additions & 0 deletions lib/wasix/src/syscalls/journal/restore_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ pub unsafe fn restore_snapshot(
.map_err(anyhow_err_to_runtime_err)?;
}

// Reset the freed FD's so that none of them will be reused after
// the journal resumes
runner.ctx.data().state().fs.clear_free_fd_list();

// Once we get to this point we are no longer replaying the journal
// and need to clear this flag, the reason is that restoring the
// background threads may immediately process requests while this
Expand Down
Loading