Fix save_to_file() crash from concurrent writes - #773
Merged
Conversation
save_to_file() runs in a background thread, and the file handle from a previous write can still be held open when the next save-state triggers another spawn. The second write fails with OS error 0x0E02 and hits the .expect(), panicking the plugin. - Add an AtomicBool guard so a second call while one is in flight is skipped - Replace the .expect() on std::fs::write with error! logging - Log info! on success for visibility in skyline logs Signed-off-by: danbugs <danilochiarlone@gmail.com>
Collaborator
|
LGTM, thanks for the pull request! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
save_to_file()is spawned on a background thread, and a previous write's file handle can still be held open when the next save-state triggers another spawn--the secondstd::fs::writefails with Horizon FS error 0x0E02 (TargetLocked) and hits the.expect(), panicking the plugin. Added anAtomicBoolguard so overlapping calls are skipped, and swapped the.expect()forerror!logging so a failed write is non-fatal.