nio4r 2.3.0 → 2.3.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: cfaa168a1d757e1242d427f89189e39f424039c30fe6a384194166ae7a6e6694
4
- data.tar.gz: fe2f130edf1d7963672302b21210a18d915583d096c1721b65e8ec9dc702b5ce
3
+ metadata.gz: f8796c2f2ce109bc99fe6fab1010bebdb8715cfbfbc31ca0aabbce1d9e56acd4
4
+ data.tar.gz: 15ff6b62bfa43c5d730c22961e7ab2c4232f4b060cb1632ca5ff649b108dd99e
5
5
  SHA512:
6
- metadata.gz: 0a195646b2139336075368785eeb77e2de30f700c0845cd14696572685dcfeded9e023761414ed01485e0d617ce96790c6e97cc810bfb95ed600e44cf467ac55
7
- data.tar.gz: fa758ef58d38dbe41c44936998d00830e9058b1daef51fe30f551b15ed2148121d5c536dfee8c2ac9c8f064000b8df170b30cb5f87fbc7c4cb6348bd92d3ec15
6
+ metadata.gz: 17d0b1f7c63515a6ce68b1451a682dd0e4b4a4b3fc5fb8709b368bc90733c9fa5f54da3f8178500b16f6a28c08bfb85fca2fe4a4c61b12fd3a93713f73ae964a
7
+ data.tar.gz: 904c80947418c7ef90405f9e392993de05666801882ba7ddaab190d86b8f76606c769f763a1da9a7b23f649499bb2ae5578f0717b40927d33fe39d7987b68714
@@ -13,7 +13,7 @@ branches:
13
13
  - master
14
14
 
15
15
  rvm:
16
- - jruby-9.1.15.0 # latest stable
16
+ - jruby-9.1.17.0 # latest stable
17
17
  - 2.2.7
18
18
  - 2.3.4
19
19
  - 2.4.1
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 2.3.1 (2018-05-03)
2
+
3
+ * [#188](https://github.com/socketry/nio4r/pull/188)
4
+ Fix remove interests
5
+ ([@ioquatix])
6
+
1
7
  ## 2.3.0 (2018-03-15)
2
8
 
3
9
  * [#183](https://github.com/socketry/nio4r/pull/183)
@@ -111,7 +111,9 @@ static VALUE NIO_Monitor_initialize(VALUE self, VALUE io, VALUE interests, VALUE
111
111
  object where it originally came from */
112
112
  monitor->selector = selector;
113
113
 
114
- ev_io_start(selector->ev_loop, &monitor->ev_io);
114
+ if (monitor->interests) {
115
+ ev_io_start(selector->ev_loop, &monitor->ev_io);
116
+ }
115
117
 
116
118
  return Qnil;
117
119
  }
@@ -127,7 +129,7 @@ static VALUE NIO_Monitor_close(int argc, VALUE *argv, VALUE self)
127
129
 
128
130
  if(selector != Qnil) {
129
131
  /* if ev_loop is 0, it means that the loop has been stopped already (see NIO_Selector_shutdown) */
130
- if(monitor->selector->ev_loop != 0) {
132
+ if(monitor->interests && monitor->selector->ev_loop) {
131
133
  ev_io_stop(monitor->selector->ev_loop, &monitor->ev_io);
132
134
  }
133
135
 
@@ -176,8 +178,8 @@ static VALUE NIO_Monitor_add_interest(VALUE self, VALUE interest) {
176
178
  struct NIO_Monitor *monitor;
177
179
  Data_Get_Struct(self, struct NIO_Monitor, monitor);
178
180
 
179
- monitor->interests |= NIO_Monitor_symbol2interest(interest);
180
- NIO_Monitor_update_interests(self, monitor->interests);
181
+ interest = monitor->interests | NIO_Monitor_symbol2interest(interest);
182
+ NIO_Monitor_update_interests(self, interest);
181
183
 
182
184
  return rb_ivar_get(self, rb_intern("interests"));
183
185
  }
@@ -186,8 +188,8 @@ static VALUE NIO_Monitor_remove_interest(VALUE self, VALUE interest) {
186
188
  struct NIO_Monitor *monitor;
187
189
  Data_Get_Struct(self, struct NIO_Monitor, monitor);
188
190
 
189
- monitor->interests &= ~NIO_Monitor_symbol2interest(interest);
190
- NIO_Monitor_update_interests(self, monitor->interests);
191
+ interest = monitor->interests & ~NIO_Monitor_symbol2interest(interest);
192
+ NIO_Monitor_update_interests(self, interest);
191
193
 
192
194
  return rb_ivar_get(self, rb_intern("interests"));
193
195
  }
@@ -297,10 +299,18 @@ static void NIO_Monitor_update_interests(VALUE self, int interests)
297
299
  }
298
300
 
299
301
  if(monitor->interests != interests) {
300
- monitor->interests = interests;
302
+ // If the monitor currently has interests, we should stop it.
303
+ if(monitor->interests) {
304
+ ev_io_stop(monitor->selector->ev_loop, &monitor->ev_io);
305
+ }
301
306
 
302
- ev_io_stop(monitor->selector->ev_loop, &monitor->ev_io);
307
+ // Assign the interests we are now monitoring for:
308
+ monitor->interests = interests;
303
309
  ev_io_set(&monitor->ev_io, monitor->ev_io.fd, monitor->interests);
304
- ev_io_start(monitor->selector->ev_loop, &monitor->ev_io);
310
+
311
+ // If we are interested in events, schedule the monitor back into the event loop:
312
+ if(monitor->interests) {
313
+ ev_io_start(monitor->selector->ev_loop, &monitor->ev_io);
314
+ }
305
315
  }
306
316
  }
@@ -552,6 +552,8 @@ void NIO_Selector_monitor_callback(ev_loop *ev_loop, struct ev_io *io, int reven
552
552
  struct NIO_Selector *selector = monitor_data->selector;
553
553
  VALUE monitor = monitor_data->self;
554
554
 
555
+ assert(monitor_data->interests != 0);
556
+
555
557
  assert(selector != 0);
556
558
  selector->ready_count++;
557
559
  monitor_data->revents = revents;
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NIO
4
- VERSION = "2.3.0".freeze
4
+ VERSION = "2.3.1".freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nio4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-16 00:00:00.000000000 Z
11
+ date: 2018-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler