howeyc/fsnotify

BSD: Open files with O_EVTONLY flag

robfig opened this issue · 6 comments

Reading about the subject online, I came across a recommendation that files be opened with the O_EVTONLY flag instead of O_RDONLY, when watching is desired -- is that applicable here? I'm not sure if the system performs any optimizations with that, but the only functional benefit is that it will then not prevent an unmount of the volume that the file is on. (This is not directly applicable to my use case, just thought I'd notify you of my finding)

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/open.2.html

This is an interesting idea. I'll take a look.

Thanks.

@robfig

Any chance you could test a change I made for this on OSX? I don't have an OSX machine.

It's on the "evtonly" branch.

Hi,

As part of running the test, I changed example_test.go to import github.com/howeyc/fsnotify instead of code.google.com/p/go.exp/fsnotify (good job getting it into go.exp btw!).

However, although I got it to pass twice, in generally "go test" fails on both master and evtonly. Here's a representative failure:

$ go test
--- FAIL: TestFsnotifyMultipleCreates (0.76 seconds)
    fsnotify_test.go:204: event received: "_test/TestFsnotifySeq.testfile": CREATE
    fsnotify_test.go:204: event received: "_test/TestFsnotifySeq.testfile": MODIFY
    fsnotify_test.go:204: event received: "_test/TestFsnotifySeq.testfile": DELETE
    fsnotify_test.go:204: event received: "_test/TestFsnotifySeq.testfile": CREATE
    fsnotify_test.go:204: event received: "_test/TestFsnotifySeq.testfile": MODIFY
    fsnotify_test.go:204: event received: "_test/TestFsnotifySeq.testfile": MODIFY
    fsnotify_test.go:204: event received: "_test/TestFsnotifySeq.testfile": MODIFY
    fsnotify_test.go:285: incorrect number of modify events received after 500 ms (4 vs atleast 3)
    fsnotify_test.go:204: event received: "_test/TestFsnotifySeq.testfile": DELETE
    fsnotify_test.go:204: event received: "_test": DELETE
--- FAIL: TestFsnotifySubDir (0.50 seconds)
    fsnotify_test.go:575: incorrect number of create events received after 500 ms (0 vs 2)
    fsnotify_test.go:524: event received: "_test": DELETE
FAIL
exit status 1
FAIL    github.com/howeyc/fsnotify  5.686s

That being said, I tested edits, creates, and deletes manually and it seemed to work fine (in conjunction with Revel)

Yeah, there's something not quite right with the tests. It's been like that since I made changes to them for go.exp.

Thanks for testing the evtonly part.

On a tangent -- should I update Revel to use go.exp/fsnotify? Are there any backwards incompatibilities to be worried about, or does it work strictly better?

Thanks!

I would advise against go.exp/fsnotify for now. I have not been very good at keeping it up to date.

I am also not sure what kind of API changes will be made there, as the reason it's in exp is so the API is not considered stable and can be changed before being included in the standard library.