-
-
Notifications
You must be signed in to change notification settings - Fork 32
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write files atomically: don't act on signals. #224
Conversation
5749667
to
5856ea8
Compare
Approach looks good! We should definitely add a testcase for this, even just a syntetic one to check the mechanics used without anything spellcheck specific and excute that with 100 or 1000 iterations |
I agree. Would you rather fake the SIG or is it enough to 'reimplement' the signal-handler and just test the atomic approach? |
Either is fine by me. |
Raising signals to self can be done via a I guess I'd rather just test the |
It would only be for
Without the signal interaction, it's rather pointless :] |
I'm a bit sick these days, I'll be back on it soon :) |
5856ea8
to
edbb7c1
Compare
Unfortunately, it's not as easy as I thought. unning 1 test
error: test failed, to rerun pass '--bin cargo-spellcheck'
Caused by:
process didn't exit successfully: `/home/korbinian/RustProjects/cargo-spellcheck/target/debug/deps/cargo_spellcheck-d23a42f4a693c8d9 atomic` (signal: 2, SIGINT: terminal interrupt signal) If I run the above test manually, it seems to work though: # target/debug/deps/cargo_spellcheck-d23a42f4a693c8d9 atomic
running 1 test
# echo $?
130 Do you have any idea how to circumvent this? Or a different approach how to test this? |
I kind of anticipated this happening 馃槰 Adding a binary target that is guarded by a |
This is a first draft, just moved main.rs to lib.rs and created an Any comments on the main.rs? E.g., documentation wise etc. |
Gentle ping 馃檭 |
2e76787
to
da6d497
Compare
Finally found some time. I added a binary which is run manually by concourse and exits with 130. If the signal is not properly caught it panics, i.e. exit code 101. I added the run to concourse for the pr-checks. If the test is fine in general I'll add it to master as well. Let me know what you're thinking, especially about the main.rs-lib.rs split :) |
c573204
to
c748d29
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small nits. I'll do some poking in a local checkout, generally looks good!
After looking into it for a bit, it seems best to call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed a few small things, so it can run as regular integration test without the additional setup or CI chores :)
8a5c285
to
c8f6cea
Compare
What does this PR accomplish?
Closes #214 .
Changes proposed by this PR:
Use an
AtomicBool
to check if writing to disk is currently in progress. Wait for write to be finished and then act on signal as before.Notes to reviewer:
I thought of surrounding
write_changes_to_disk()
(action/mod.rs:333
). This would be more robust in the future if thematch
inmod.rs:263
called something else thencorrect_files()
. However, I went for the smaller scope to not ignore signals for too long.The signal handler is just busy-waiting until the write has been finished.
馃摐 Checklist
./demo
sub directory