Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36
fix(fspy): replace the IPC file lock with an in-mapping close gate#577
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,4 @@ | ||
| use std::io; | ||
| use fspy_shared::ipc::{ | ||
| PathAccess, | ||
| channel::{Receiver, ReceiverLockGuard}, | ||
| }; | ||
| use tokio::task::spawn_blocking; | ||
| // Shared memory size for storing path accesses. | ||
| // 4 GiB is large enough to store path accesses in almost any realistic scenario. | ||
| // This doesn't allocate physical memory until it's actually used. | ||
| pub const SHM_CAPACITY: usize = 4 * 1024 * 1024 * 1024; | ||
| #[ouroboros::self_referencing] | ||
| pub struct OwnedReceiverLockGuard { | ||
| /// Owns the shared memory | ||
| receiver: Receiver, | ||
| /// Borrows the shared memory and owns the file lock | ||
| #[borrows(receiver)] | ||
| #[covariant] | ||
| lock_guard: ReceiverLockGuard<'this>, | ||
| } | ||
| impl OwnedReceiverLockGuard { | ||
| pub fn lock(receiver: Receiver) -> io::Result<Self> { | ||
| Self::try_new(receiver, fspy_shared::ipc::channel::Receiver::lock) | ||
| } | ||
| pub async fn lock_async(receiver: Receiver) -> io::Result<Self> { | ||
| spawn_blocking(move || Self::lock(receiver)).await.expect("lock task panicked") | ||
| } | ||
| pub fn iter_path_accesses(&self) -> impl Iterator<Item = PathAccess<'_>> { | ||
| self.borrow_lock_guard() | ||
| .iter_frames() | ||
| .map(|frame| wincode::deserialize_exact(frame).unwrap()) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //! Drains in-flight sends before a voluntary exit. | ||
| //! | ||
| //! A process may call `exit` while another of its threads is between claiming | ||
| //! a frame and finishing it. Dying there abandons the frame's gate guard, and | ||
| //! the runner then treats the whole run's tracking as incomplete. The drain | ||
| //! lasts microseconds; signals and crashes still skip it, and the runner | ||
| //! handles those by not caching the run. | ||
| use libc::c_int; | ||
| use crate::{client::drain_in_flight_sends, macros::intercept}; | ||
| intercept!(exit: unsafe extern "C" fn(status: c_int) -> !); | ||
| unsafe extern "C" fn exit(status: c_int) -> ! { | ||
| drain_in_flight_sends(); | ||
| // SAFETY: forwarding to the real libc exit with the caller's status | ||
| unsafe { exit::original()(status) } | ||
| } | ||
| intercept!(_exit: unsafe extern "C" fn(status: c_int) -> !); | ||
| unsafe extern "C" fn _exit(status: c_int) -> ! { | ||
| drain_in_flight_sends(); | ||
| // SAFETY: forwarding to the real libc _exit with the caller's status | ||
| unsafe { _exit::original()(status) } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| mod access; | ||
| mod dirent; | ||
| mod exit; | ||
| mod open; | ||
| mod spawn; | ||
| mod stat; | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.