-
Notifications
You must be signed in to change notification settings - Fork 7
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
Simulate file locks in blockio-sim
#415
Conversation
3e19457
to
63d7868
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.
@dcoutts looks great
-- Warning: This implementation is not robust under concurrent use (because | ||
-- operations on files are not atomic) but should be ok for casual use. A | ||
-- proper implementation would need to be part of the underlying 'HasFs' | ||
-- implementations. |
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.
👍
It's an adequate implementation, but not perfect. It passes the test, but would fail if there were genuine concurrency. Doing it properly would need an implementation in fs-api and fs-sim. Fortunately we do not need a concurrency safe implementation (for now). Co-authored-by: Duncan Coutts <duncan@well-typed.com> Co-authored-by: Joris Dral <joris@welltyped.com>
With the nice addition that we now assert that there are no open file handles at the end of each iteration of the tests! We also tweak the state machine tests. We now follow a more normal convention, and allow running individual tests more easily in GHCi via `quickCheck $ theProperty`. Co-authored-by: Duncan Coutts <duncan@well-typed.com> Co-authored-by: Joris Dral <joris@welltyped.com>
2ee8a84
to
a868ca2
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.
LGTM!
-- Warning: regular file operations on the "locked" file, like 'hOpen' or | ||
-- 'removeFile', will still work. 'simTryLockFile' only defines how multiple | ||
-- lock acquisitions on the same file interact, not how lock acquisition | ||
-- interacts with other file operations. |
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.
The same is true for the normal API too.
What's neat is that we can now find out in our
StateMachine
tests whether our implementation is leaking file descriptors!