cool.io 1.9.1 → 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d38b3958d9ad5505fb4a53ded526d2ab347d46200a567a9aa0681cc5ca487cc
4
- data.tar.gz: 42cb1b75db2c409dfc48756b8df29663675e31a104d03c37bbbfce9344592d6d
3
+ metadata.gz: 5cdd11354b2fc68835f7380b7f529a5c41c29280dd489287eb99fbc605978f18
4
+ data.tar.gz: 51e173aadc18fdd12915648b7ac58553ab0b22c13be146e2273d507135cefe58
5
5
  SHA512:
6
- metadata.gz: 6e3358de317e34735ca0f264c75f93d34d38325482c02eabf4d1289b3c44ef6557918bd59078a34c809322d69d05299ccb58f89db630c4054dc0162de8ab49b6
7
- data.tar.gz: 775568343fe8788adbc43757a6f06ef5474e1d19477571317f29e21ff3da777d8567a6401377c6eb854e9f0c4060d97da7c84dafa56dc1e772f636417365d338
6
+ metadata.gz: 4449d8f0cec3c081e3ff3625351d66e1eb19ec4cdc23d547a4c2862d0b3a25e8a71bf43eb803559b3758ed284bd3f4a4f5e6008b04e490530604c6cc6551a9eb
7
+ data.tar.gz: 7607bab107f686eb8f1a16bc013f0a78815238fc1063de51d75b3e6299f00384583bd311de2841ea1d5bd43e4b72eaad5b43f3f22face9bd327ca9c0629f1a0f
data/ext/cool.io/loop.c CHANGED
@@ -113,6 +113,12 @@ void Coolio_Loop_process_event(VALUE watcher, int revents)
113
113
  /* The Global VM lock isn't held right now, but hopefully
114
114
  * we can still do this safely */
115
115
  watcher_data = Coolio_Watcher_ptr(watcher);
116
+
117
+ if (watcher_data->enabled == 0) {
118
+ /* Ignore event because watcher was already detached. */
119
+ return;
120
+ }
121
+
116
122
  loop_data = Coolio_Loop_ptr(watcher_data->loop);
117
123
 
118
124
  /* Well, what better place to explain how this all works than
@@ -33,6 +33,10 @@
33
33
  if(watcher_data->loop == Qnil) \
34
34
  rb_raise(rb_eRuntimeError, "not attached to a loop"); \
35
35
  \
36
+ if (watcher_data->enabled == 0) { \
37
+ /* Ignore because watcher was already detached. */ \
38
+ return Qnil; \
39
+ } \
36
40
  loop_data = Coolio_Loop_ptr(watcher_data->loop); \
37
41
  \
38
42
  ev_##watcher_type##_stop(loop_data->ev_loop, &watcher_data->event_types.ev_##watcher_type); \
@@ -1,5 +1,5 @@
1
1
  module Coolio
2
- VERSION = "1.9.1"
2
+ VERSION = "1.9.2"
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cool.io::Loop do
4
+ class Victim < Cool.io::IOWatcher
5
+ def initialize(io)
6
+ super
7
+ @io = io
8
+ end
9
+
10
+ def on_readable
11
+ begin
12
+ @io.read_nonblock(1024)
13
+ rescue IO::WaitReadable, EOFError
14
+ end
15
+ end
16
+ end
17
+
18
+ # https://github.com/socketry/cool.io/issues/87
19
+ it "does not raise TypeError when a watcher is detached while an event is pending" do
20
+ loop = Cool.io::Loop.default
21
+
22
+ iterations = 200
23
+
24
+ expect {
25
+ iterations.times do
26
+ r_victim, w_victim = IO.pipe
27
+ victim_watcher = Victim.new(r_victim)
28
+ victim_watcher.attach(loop)
29
+
30
+ t1 = Thread.new do
31
+ sleep 0.01
32
+ w_victim.write("dummy\n")
33
+ end
34
+
35
+ t2 = Thread.new do
36
+ sleep 0.01
37
+ victim_watcher.detach
38
+ end
39
+
40
+ loop.run_once
41
+
42
+ t1.join
43
+ t2.join
44
+
45
+ r_victim.close
46
+ w_victim.close
47
+ end
48
+ }.not_to raise_error
49
+ end
50
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cool.io
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
@@ -140,6 +140,7 @@ files:
140
140
  - libev_ruby_gil.diff
141
141
  - libev_win_select.diff
142
142
  - spec/async_watcher_spec.rb
143
+ - spec/detach_race_condition_spec.rb
143
144
  - spec/dns_spec.rb
144
145
  - spec/iobuffer_spec.rb
145
146
  - spec/spec_helper.rb
@@ -168,11 +169,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
169
  - !ruby/object:Gem::Version
169
170
  version: '0'
170
171
  requirements: []
171
- rubygems_version: 4.0.0.dev
172
+ rubygems_version: 4.0.3
172
173
  specification_version: 4
173
174
  summary: A cool framework for doing high performance I/O in Ruby
174
175
  test_files:
175
176
  - spec/async_watcher_spec.rb
177
+ - spec/detach_race_condition_spec.rb
176
178
  - spec/dns_spec.rb
177
179
  - spec/iobuffer_spec.rb
178
180
  - spec/spec_helper.rb