Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

BSD: Open files with O_EVTONLY flag #44

Closed
robfig opened this issue May 22, 2013 · 6 comments
Closed

BSD: Open files with O_EVTONLY flag #44

robfig opened this issue May 22, 2013 · 6 comments

Comments

@robfig
Copy link
Contributor

robfig commented May 22, 2013

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

@howeyc
Copy link
Owner

howeyc commented May 23, 2013

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

Thanks.

@howeyc
Copy link
Owner

howeyc commented May 25, 2013

@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.

@robfig
Copy link
Contributor Author

robfig commented May 26, 2013

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)

@howeyc
Copy link
Owner

howeyc commented May 26, 2013

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.

@howeyc howeyc closed this as completed May 26, 2013
@robfig
Copy link
Contributor Author

robfig commented May 28, 2013

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!

@howeyc
Copy link
Owner

howeyc commented May 28, 2013

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.

rsc pushed a commit to golang/exp that referenced this issue Dec 7, 2014
WatchFlags of files created in Watched directories are now the same as the
parent directory. (howeyc/fsnotify#33)

Darwin now uses EVT_ONLY flag on Open file for watching.
(howeyc/fsnotify#44)

Linux has been updated to ignore events that occur after delete.
(howeyc/fsnotify#36)

Symlink test updated.
(howeyc/fsnotify#42)

Rename tests use external "mv" where available.

R=golang-dev, dave, fullung, rsc
CC=golang-dev
https://golang.org/cl/9827046
GoogleCodeExporter pushed a commit to bsed/go-zh.exp that referenced this issue May 31, 2015
WatchFlags of files created in Watched directories are now the same as the
parent directory. (howeyc/fsnotify#33)

Darwin now uses EVT_ONLY flag on Open file for watching.
(howeyc/fsnotify#44)

Linux has been updated to ignore events that occur after delete.
(howeyc/fsnotify#36)

Symlink test updated.
(howeyc/fsnotify#42)

Rename tests use external "mv" where available.

R=golang-dev, dave, fullung, rsc
CC=golang-dev
https://codereview.appspot.com/9827046

Committer: Russ Cox <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants