Skip to content
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

Some fixes regarding unwatching and rewatching a path #129

Merged
merged 14 commits into from
Oct 4, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
readdcw: Fix race (missing lock)
  • Loading branch information
imsodin committed Oct 4, 2017
commit de41129de4dcb93ba35b81ff278d4f5ba269816c
6 changes: 2 additions & 4 deletions watcher_readdcw.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,20 +349,18 @@ func (r *readdcw) loop() {

// TODO(pknap) : doc
func (r *readdcw) loopstate(overEx *overlappedEx) {
r.Lock()
defer r.Unlock()
filter := atomic.LoadUint32(&overEx.parent.parent.filter)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably we won't need atomic here anymore.

Copy link
Contributor Author

@imsodin imsodin Oct 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the same in nonStateWatched, as it is only called when the lock is held, right?
https://github.com/rjeczalik/notify/pull/129/files/45213bd71c5145dd70d258df0acaf721b59a7d90#diff-ac809f36d763355597370ab566b6d71aR478

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed 👍 🥇

if filter&onlyMachineStates == 0 {
return
}
if overEx.parent.parent.count--; overEx.parent.parent.count == 0 {
switch filter & onlyMachineStates {
case stateRewatch:
r.Lock()
overEx.parent.parent.recreate(r.cph)
r.Unlock()
case stateUnwatch:
r.Lock()
delete(r.m, syscall.UTF16ToString(overEx.parent.pathw))
r.Unlock()
case stateCPClose:
default:
panic(`notify: windows loopstate logic error`)
Expand Down