-
Notifications
You must be signed in to change notification settings - Fork 375
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
[ ttc ] Compare modification time with nanosecond precision #3046
Conversation
69a8153
to
e72f0c2
Compare
@@ -441,15 +442,18 @@ TTC Nat where | |||
|
|||
||| Get a file's modified time. If it doesn't exist, return 0 (UNIX Epoch) |
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.
Can you please edit the comment to document what these Ints are?
Better yet: why not introduce a record type with meaningful field names?
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.
That sounds reasonable, I'll add a record for timestamps.
I guess another improvement I should make is adding a function that would get both seconds and nanoseconds of a timestamp and return a structure from C that would be turned into the newly introduced record. This would allow us to get both parts of timestamp in a single system call and potentially prevent a dangerous situation where time is modified between two system calls.
b58bc30
to
dd464ef
Compare
faa9657
to
4ab4991
Compare
4ab4991
to
982de4f
Compare
I've introduced a record as requested. Additionally, I've revisited the low-level interface to add capability to get both parts of timestamp and all time attributes of a file in a single syscall. This should eliminate the possibility of races when checking file's time. It looks like currently this PR ticks off two points in #2207. I have also discovered that the current implementation of |
Description
This PR changes TTC modification time comparison to use nanosecond-precision timestamps. It addresses the issue described in #3042, but, unlike the original PR, it does not break safety guarantees and does not risk missed rebuilds of source files. Since getting high-precision timestamps is platform-dependent and might not be supported everywhere, it reverts to current behaviour whenever there is no proper way to get nanosecond part of file's mtime.
This PR depends on #3044 to pass CI and avoid bootstrapping the compiler when upgrading.