-
Notifications
You must be signed in to change notification settings - Fork 106
fsmonitor: use an opaque token for the last update #225
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
Conversation
870e47b to
a04d76c
Compare
derrickstolee
left a comment
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.
This is looking promising!
a04d76c to
e465554
Compare
derrickstolee
left a comment
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.
I don't really have any complaints. This looks like a good approach.
Have you started building installers so you can test this paired with the C# layer?
dscho
left a comment
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.
I left a couple of comments/suggestions; Hopefully you find them useful!
Also, I'd like to see the fixup! "rebased away".
fsmonitor.c
Outdated
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.
Just a thought: getnanotime() has a bunch of slop in it. For example, the first call to it within the process always gets a value ending with 000 on Windows (observed when I started trace2). And there's some other mysterious magic in there that I don't completely understand.
We might want to consider just getting the whole seconds since epoch, subtract 1 or 2, and then convert that to nanoseconds for storage in the header. And err on the side of caution.
…token Some file system monitors might not use or take a timestamp for processing and in the case of watchman could have race conditions with using a timestamp. Change the fsmonitor_last_update from being a uint64_t to a char pointer so that any arbitrary data can be stored in it. Signed-off-by: Kevin Willford <[email protected]>
1b80381 to
a3b5397
Compare
d2a0316 to
2ce4d82
Compare
Some file monitors like watchman will use a clock id to keep better track of what changes happen in between calls to query the monitor. Update the hook version handle the clock id so that it can be stored with the index and the dirty flags. Because the version of the fsmonitor hook will need to be updated to support a clockid from watchman, create a config value for the hook version that can be set. This will help be able to stay backwards compatible with version 1 of the hook but allow for a new version. Signed-off-by: Kevin Willford <[email protected]>
f778723 to
8acf258
Compare
Need scripts used in testing fsmonitor using version 2. Signed-off-by: Kevin Willford <[email protected]>
A new config value for core.fsmonitorHookVersion was added to be able to force the version of the fsmonitor hook. A version has been added to the fsmonitor hook to be able to handle clock ids that are used with watchman. Signed-off-by: Kevin Willford <[email protected]>
8acf258 to
49a3ae1
Compare
Resolves #291. Mostly a code move from `CloneVerb` to `ConfigStep`. We lose some output during clone, like "Watchman configured!" as we don't have access to `Output` during the `ConfigStep`. The `CloneVerb` runs the `ConfigStep` directly, but so does the `RegisterStep` and background maintenance. There is a benefit, though: we will try configuring Watchman on every upgrade and once a day. If a user installs Watchman after cloning, then we will configure it automatically. One remaining thing to think about: we are currently _copying_ the existing hook template from the hooks directory. As this changes (see microsoft/git#225 and gitgitgadget/git#510), we will need a different way to populate the hook. Perhaps we should store the hook contents in the Scalar codebase to avoid using a stale (or malicious) hook. Cc @kewillford for thoughts on this.
|
I'm thrilled that this is in v2.26.0-rc0, so will be in our fork as part of vfs-2.26.0. When I get installers working for #251, then we can test microsoft/scalar#255 with that build. |
Applications that are used for monitoring the file system might not use a timestamp for querying. Watchman for example uses a clock id to remove race conditions that come from using a timestamp.
Switch to using an opaque token in the fsmonitor code so that the clock id from watchman or any other token from a file monitor can be stored.
Update the watchman scripts to get the clock id and send that back to the caller. This is sent back as the first NUL terminated entry in the output stream.
Still want to clean up the watchman scripts because it is not very well organized or understandable for me at least.