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

Missing create events on OS X #14

Closed
nathany opened this issue Jun 29, 2014 · 1 comment
Closed

Missing create events on OS X #14

nathany opened this issue Jun 29, 2014 · 1 comment

Comments

@nathany
Copy link
Contributor

nathany commented Jun 29, 2014

@elgs reported this issue at howeyc/fsnotify#82

In the a directory, when I run touch a s d f g h k l, it outputs:

2014/02/02 03:31:00 event: "/Volumes/User/Home/Desktop/a/a": CREATE
2014/02/02 03:31:00 event: "/Volumes/User/Home/Desktop/a/d": CREATE
2014/02/02 03:31:00 event: "/Volumes/User/Home/Desktop/a/s": CREATE
2014/02/02 03:31:00 event: "/Volumes/User/Home/Desktop/a/l": CREATE

kqueue doesn't have a NOTE_CREATE event so fsnotify_bsd.go is doing a ReadDir and scanning for created files. However, it someone gets confused as to which files already exist:

/Users/nathany/Desktop/a/a false
/Users/nathany/Desktop/a/s false
2014/02/01 22:26:28 event: "/Users/nathany/Desktop/a/a": CREATE!
2014/02/01 22:26:28 event: "/Users/nathany/Desktop/a/s": CREATE!
/Users/nathany/Desktop/a/a true
/Users/nathany/Desktop/a/d true
/Users/nathany/Desktop/a/f true
/Users/nathany/Desktop/a/g true
/Users/nathany/Desktop/a/h true
/Users/nathany/Desktop/a/j true
/Users/nathany/Desktop/a/k true
/Users/nathany/Desktop/a/l false
/Users/nathany/Desktop/a/s true
2014/02/01 22:26:28 event: "/Users/nathany/Desktop/a/l": CREATE!

The problem is that sendDirectoryChangeEvents does a ReadDir and sends a create event for a file. Then it calls watchDirectoryFiles which does a ReadDir as well. By this time more files have been touched so ReadDir gets a different result.

watchDirectoryFiles is marking those files as existing without sending create events. And since they have been flagged as existing, those files are never sent as create events the next time sendDirectoryChangeEvents is called.

For some reason I haven't been able to reproduce the issue on FreeBSD, which uses nearly all the same code.

@nathany
Copy link
Contributor Author

nathany commented Jun 29, 2014

This is likely the cause of TestFsnotifySubdir fails intermittently on Mac OS X 10.9.2:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant