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

Ignore kqueue errors on removed entries #301

Merged
merged 1 commit into from Mar 15, 2015
Merged

Ignore kqueue errors on removed entries #301

merged 1 commit into from Mar 15, 2015

Conversation

ghost
Copy link

@ghost ghost commented Mar 14, 2015

When the BSD adapter decides it will watch a new file, it may happen
that the file was already removed when the call to watch this file
actually happens, raising Errno::ENOENT exception.

As a workaround, we rescue this specific error and log a warning, in
case of a more serious issue than just an ephemeral file.

Exception example:

E, [2015-03-14T20:07:52.726600 #2299] ERROR -- : run() in thread failed: No such file or directory - Failed to open file /.../src/my/listen-kqueue/tmp/toto: File doesn't exist.:/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/watcher/file.rb:19:in `initialize'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/queue.rb:227:in `new'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/queue.rb:227:in `watch_file'
/.../src/sys/listen/lib/listen/adapter/bsd.rb:96:in `_watch_file'
/.../src/sys/listen/lib/listen/adapter/bsd.rb:89:in `block in _watch_for_new_file'
/usr/local/lib/ruby/2.2/find.rb:48:in `block (2 levels) in find'
/usr/local/lib/ruby/2.2/find.rb:47:in `catch'
/usr/local/lib/ruby/2.2/find.rb:47:in `block in find'
/usr/local/lib/ruby/2.2/find.rb:42:in `each'
/usr/local/lib/ruby/2.2/find.rb:42:in `find'
/.../src/sys/listen/lib/listen/adapter/bsd.rb:103:in `_find'
/.../src/sys/listen/lib/listen/adapter/bsd.rb:87:in `_watch_for_new_file'
/.../src/sys/listen/lib/listen/adapter/bsd.rb:68:in `_process_event'
/.../src/sys/listen/lib/listen/adapter/base.rb:47:in `block (2 levels) in configure'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/watcher.rb:90:in `call'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/watcher.rb:90:in `callback!'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/event.rb:80:in `callback!'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/queue.rb:337:in `block in process'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/queue.rb:337:in `each'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/queue.rb:337:in `process'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/queue.rb:316:in `run'
/.../src/sys/listen/lib/listen/adapter/bsd.rb:50:in `_run'
/.../src/sys/listen/lib/listen/adapter/base.rb:58:in `block in start'
/.../src/sys/listen/lib/listen/internals/thread_pool.rb:7:in `call'
/.../src/sys/listen/lib/listen/internals/thread_pool.rb:7:in `block in add'

Warning example, with this change:

W, [2015-03-14T20:21:16.209281 #5997]  WARN -- : kqueue: watch file failed: No such file or directory - Failed to open file /.../src/my/listen-kqueue/tmp/toto: File doesn't exist.
I, [2015-03-14T20:21:16.313068 #5997]  INFO -- : listen: raw changes: [[:removed, "/.../src/my/listen-kqueue/tmp/toto"]]
I, [2015-03-14T20:21:16.313146 #5997]  INFO -- : listen: final changes: {:modified=>[], :added=>[], :removed=>["/.../src/my/listen-kqueue/tmp/toto"]}
[…]

  When the BSD adapter decides it will watch a new file, it may happen
that the file was already removed when the call to watch this file
actually happens, raising Errno::ENOENT exception.

  As a workaround, we rescue this specific error and log a warning, in
case of a more serious issue than just an ephemeral file.

  Exception example:

E, [2015-03-14T20:07:52.726600 #2299] ERROR -- : run() in thread failed: No such file or directory - Failed to open file /.../src/my/listen-kqueue/tmp/toto: File doesn't exist.:/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/watcher/file.rb:19:in `initialize'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/queue.rb:227:in `new'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/queue.rb:227:in `watch_file'
/.../src/sys/listen/lib/listen/adapter/bsd.rb:96:in `_watch_file'
/.../src/sys/listen/lib/listen/adapter/bsd.rb:89:in `block in _watch_for_new_file'
/usr/local/lib/ruby/2.2/find.rb:48:in `block (2 levels) in find'
/usr/local/lib/ruby/2.2/find.rb:47:in `catch'
/usr/local/lib/ruby/2.2/find.rb:47:in `block in find'
/usr/local/lib/ruby/2.2/find.rb:42:in `each'
/usr/local/lib/ruby/2.2/find.rb:42:in `find'
/.../src/sys/listen/lib/listen/adapter/bsd.rb:103:in `_find'
/.../src/sys/listen/lib/listen/adapter/bsd.rb:87:in `_watch_for_new_file'
/.../src/sys/listen/lib/listen/adapter/bsd.rb:68:in `_process_event'
/.../src/sys/listen/lib/listen/adapter/base.rb:47:in `block (2 levels) in configure'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/watcher.rb:90:in `call'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/watcher.rb:90:in `callback!'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/event.rb:80:in `callback!'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/queue.rb:337:in `block in process'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/queue.rb:337:in `each'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/queue.rb:337:in `process'
/.../.gem/ruby/22/gems/rb-kqueue-0.2.3/lib/rb-kqueue/queue.rb:316:in `run'
/.../src/sys/listen/lib/listen/adapter/bsd.rb:50:in `_run'
/.../src/sys/listen/lib/listen/adapter/base.rb:58:in `block in start'
/.../src/sys/listen/lib/listen/internals/thread_pool.rb:7:in `call'
/.../src/sys/listen/lib/listen/internals/thread_pool.rb:7:in `block in add'

  Warning example, with this change:

W, [2015-03-14T20:21:16.209281 #5997]  WARN -- : kqueue: watch file failed: No such file or directory - Failed to open file /.../src/my/listen-kqueue/tmp/toto: File doesn't exist.
I, [2015-03-14T20:21:16.313068 #5997]  INFO -- : listen: raw changes: [[:removed, "/.../src/my/listen-kqueue/tmp/toto"]]
I, [2015-03-14T20:21:16.313146 #5997]  INFO -- : listen: final changes: {:modified=>[], :added=>[], :removed=>["/.../src/my/listen-kqueue/tmp/toto"]}
[…]
e2 added a commit that referenced this pull request Mar 15, 2015
Ignore kqueue errors on removed entries
@e2 e2 merged commit 2030bac into guard:master Mar 15, 2015
@e2
Copy link
Contributor

e2 commented Mar 15, 2015

Done. Thanks for investigating and testing!

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

Successfully merging this pull request may close these issues.

1 participant