-
-
Notifications
You must be signed in to change notification settings - Fork 888
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
Watch.Add improvements (avoid race, fix consistency, reduce garbage) #189
Conversation
If Watcher.Add is called with the same name from multiple goroutines and name is not already in the watches map then the last call to complete wins and the watch created by the first call to complete is lost. This commit holds the mutex for the full duration of the update to the watches map.
Previously, the watch entry is the watches map was updated before the call to InotifyAddWatch. If InotifyAddWatch fails then this left the watch entry in an inconsistent state.
Any chance of getting this reviewed? |
Gentle ping :) |
Sorry for the delay. I'll try to carve out some time over the Christmas holiday to work on fsnotify. |
Gentle ping :) |
@twpayne - I'm not a maintainer of this package but these changes LGTM.
👍, moreover, it fixes potential deadlock when
(Unfortunately) this is not entirely true, because the current Overall, this PR is an improvement of current logic. |
Many thanks for the review! |
@nathany Any chance of getting this merged? |
@twpayne Thanks and apologies for the delay. @ppknap Thanks also for reviewing. One consideration is the performance of wide vs. narrow mutexes: But I think this is a good change, and we can come back to performance considerations later. I'll take a closer look and merge + prepare a release in the next few days. Thanks! |
Thanks! Note that in this case, the "wide vs. narrow mutexes" fix is about correctness, not performance. See the commit message of 81cea74 for more details. |
Four months after submission, this PR is approved, passed all checks, and ready to merge. Is this gonna happen? Is fsnotify abandonware? |
@twpayne It's only abandonware if nobody steps in to replace me. https://groups.google.com/forum/#!topic/golang-nuts/Ix4sg_gDLNE |
Sorry, I am not able to step in to replace you. I have sufficient maintenance burden with my existing open source projects. Is there any reason for not merging this PR? You only have to press the merge button. |
@twpayne No worries. You are right, for a Linux-only change, CI is enough and hitting merge is fine. Thanks @ppknap for reviewing and merging. @twpayne Did you happen to sign the Google CLA at some point? That process still needs to be automated. #193. There are a few more steps to do a release which should probably be documented somewhere. Updating the AUTHORS file, CHANGELOG, and Releases after tagging a version. Creating an issue around that: #201. |
Yes, I've signed the Google CLA. |
This PR fixes two potential problems in Watch.Add in
inotify.go
:Add()
is called concurrently.flags
stored whenInotifyAddWatch
fails.In addition, it re-uses the existing watch entry when modifying an existing watch.
The individual commits contain more details.