rb-inotify 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 508d32162686edac9f8899476c72f067947853be3bf54636c03e8e26af5f1db6
4
- data.tar.gz: 40ba36f43b4ddbc6659fdc60a23494fc0c3d3aea69e8da38100860b315410c10
3
+ metadata.gz: 803cf77fe31e9334147381cbc2fcdc911f5c8c060582af70afb80ba00caa4967
4
+ data.tar.gz: dc13bce654e7a7c20d17722db4a62d4a091a6f21918e8133702306d90d5e0ccb
5
5
  SHA512:
6
- metadata.gz: e6a89d3e902bd71ed29ae54023f0a54be8fa525fa062a272a4291b35072fe75b1d597ce1d095eda32df4b6d842ea73321e770a9c67bb1492248c74c226cfc2ab
7
- data.tar.gz: 70abecd11f1ceee101444d6cbd35c086ad0604a847d48b79c9fbda0658e3bc1ddad16c6047c1df50d84bdf7fa854251da66ede2106158b124eabe7d0b47bff7f
6
+ metadata.gz: 8b798f26a05bb0757e2bb29c49bdc07b694659c9bfd1a007be3fec48acbfccb59c049bbf17881c739f80f66fc63b03df15fb70574aaae73ce2f457667e726eec
7
+ data.tar.gz: c29ccd96375401b43d52ca09345ab235e11b044706ef4995525372961b126d4b845ac468c422c40dd77eec36995ac19855dccab85706a6458f34505bec5ac02b
@@ -11,11 +11,9 @@ matrix:
11
11
  - rvm: truffleruby
12
12
  - rvm: jruby-head
13
13
  - rvm: ruby-head
14
- - rvm: rbx-3
15
14
  allow_failures:
16
15
  - rvm: truffleruby
17
16
  - rvm: jruby
18
17
  - rvm: ruby-head
19
18
  - rvm: jruby-head
20
- - rvm: rbx-3
21
19
  fast_finish: true
data/LICENSE.md CHANGED
@@ -1,7 +1,7 @@
1
- # The MIT License (MIT)
1
+ # The MIT License
2
2
 
3
- Copyright, 2009, by [Natalie Weizenbaum](https://github.com/nex3).
4
- Copyright, 2017, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
3
+ Copyright, 2009, by [Natalie Weizenbaum](https://github.com/nex3).
4
+ Copyright, 2017, by [Samuel G. D. Williams](http://www.codeotaku.com).
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
7
 
data/README.md CHANGED
@@ -10,7 +10,7 @@ It uses the [FFI](http://wiki.github.com/ffi/ffi) gem to avoid having to compile
10
10
  [![Code Climate](https://codeclimate.com/github/guard/rb-inotify.svg)](https://codeclimate.com/github/guard/rb-inotify)
11
11
  [![Coverage Status](https://coveralls.io/repos/guard/rb-inotify/badge.svg)](https://coveralls.io/r/guard/rb-inotify)
12
12
 
13
- ## Basic Usage
13
+ ## Usage
14
14
 
15
15
  The API is similar to the inotify C API, but with a more Rubyish feel.
16
16
  First, create a notifier:
@@ -69,6 +69,16 @@ Unfortunately, this currently doesn't work under JRuby.
69
69
  JRuby currently doesn't use native file descriptors for the IO object,
70
70
  so we can't use the notifier's file descriptor as a stand-in.
71
71
 
72
+ ### Resource Limits
73
+
74
+ If you get an error like `inotify event queue has overflowed` you might be running into system limits. You can add the following to your `/etc/sysctl.conf` to increase the number of files that can be monitored:
75
+
76
+ ```
77
+ fs.inotify.max_user_watches = 100000
78
+ fs.inotify.max_queued_events = 100000
79
+ fs.inotify.max_user_instances = 100000
80
+ ```
81
+
72
82
  ## Contributing
73
83
 
74
84
  1. Fork it
@@ -51,12 +51,18 @@ module INotify
51
51
  def initialize
52
52
  @running = Mutex.new
53
53
  @pipe = IO.pipe
54
+ # JRuby shutdown sometimes runs IO finalizers before all threads finish.
55
+ if RUBY_ENGINE == 'jruby'
56
+ @pipe[0].autoclose = false
57
+ @pipe[1].autoclose = false
58
+ end
54
59
 
55
60
  @watchers = {}
56
61
 
57
62
  fd = Native.inotify_init
58
63
  unless fd < 0
59
64
  @handle = IO.new(fd)
65
+ @handle.autoclose = false if RUBY_ENGINE == 'jruby'
60
66
  return
61
67
  end
62
68
 
@@ -224,10 +230,13 @@ module INotify
224
230
  # @see #process
225
231
  def run
226
232
  @running.synchronize do
233
+ Thread.current[:INOTIFY_RUN_THREAD] = true
227
234
  @stop = false
228
235
 
229
236
  process until @stop
230
237
  end
238
+ ensure
239
+ Thread.current[:INOTIFY_RUN_THREAD] = false
231
240
  end
232
241
 
233
242
  # Stop watching for filesystem events.
@@ -237,8 +246,10 @@ module INotify
237
246
  @stop = true
238
247
  @pipe.last.write "."
239
248
 
240
- @running.synchronize do
241
- # no-op: we just needed to wait until the lock was available
249
+ unless Thread.current[:INOTIFY_RUN_THREAD]
250
+ @running.synchronize do
251
+ # no-op: we just needed to wait until the lock was available
252
+ end
242
253
  end
243
254
  end
244
255
 
@@ -20,5 +20,5 @@
20
20
  # THE SOFTWARE.
21
21
 
22
22
  module INotify
23
- VERSION = '0.10.0'
23
+ VERSION = '0.10.1'
24
24
  end
@@ -101,6 +101,16 @@ describe INotify::Notifier do
101
101
 
102
102
  expect(events.map(&:name)).to match_array(%w(one.txt two.txt))
103
103
  end
104
+
105
+ it "can be stopped from within a callback" do
106
+ barriers = Array.new(3) { Concurrent::Event.new }
107
+ barrier_queue = barriers.dup
108
+ events = recording(dir, :create) { @notifier.stop }
109
+
110
+ run_thread = Thread.new { @notifier.run }
111
+ dir.join("one.txt").write("hello world")
112
+ run_thread.join
113
+ end
104
114
  end
105
115
 
106
116
  describe :fd do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rb-inotify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Natalie Weizenbaum
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-12-15 00:00:00.000000000 Z
12
+ date: 2019-12-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -127,8 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
129
  requirements: []
130
- rubyforge_project:
131
- rubygems_version: 2.7.8
130
+ rubygems_version: 3.0.4
132
131
  signing_key:
133
132
  specification_version: 4
134
133
  summary: A Ruby wrapper for Linux inotify, using FFI