celluloid-io 0.16.5.pre0 → 0.17.0

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
  SHA1:
3
- metadata.gz: bf0058f46b15fb91d5363861cc8035e0f41f6396
4
- data.tar.gz: cad3855d8ca89f73731dceaa18716ba25f315484
3
+ metadata.gz: eb0a9cc2d4727a3ecd2fbe0670d9ec5f4ced84da
4
+ data.tar.gz: 49a9f4469ef1f043cb836716b7106ce63a556c53
5
5
  SHA512:
6
- metadata.gz: 39ce8ad8e39920264f26c199bf14e5dbd03c6e97943d7d5a636e68d6e9cc687aa79d14b3d6542ff5af8e11eb19e118e8ff3b262fd61966c89814d3966bcfc0fb
7
- data.tar.gz: 03ffeaedee0b08276537ff5cfedf5d11157c34c932129f1c394626ff45923b93867901bb67f2718e5fe6b032649dd7112d910c527c983e82b1c8c6c7c532f026
6
+ metadata.gz: 766df703611837323e613ef64ffe817cf98920a91ff6e7f300bf110f0cf8dd4352648a9fd08396a42079c5a1c60536c11e10a081d13f94afbe868e8d327a177e
7
+ data.tar.gz: 146dc425c772ca7689334aaaf7316248c225bcd94ed795a8985efad1f31fd63367aa2ccdf8e49ca8d0f855955db194b18431ce02458127340b1e75b84c8a2600
data/.travis.yml CHANGED
@@ -16,7 +16,6 @@ rvm:
16
16
  matrix:
17
17
  fast_finish: true
18
18
  allow_failures:
19
- - rvm: rbx-2
20
19
  - rvm: ruby-head
21
20
  - rvm: jruby-head
22
21
  - env: CELLULOID_BACKPORTED=true
data/Gemfile CHANGED
@@ -1,2 +1,4 @@
1
1
  require File.expand_path("../culture/sync", __FILE__)
2
+
2
3
  Celluloid::Sync::Gemfile[self]
4
+
data/celluloid-io.gemspec CHANGED
@@ -5,8 +5,8 @@ Gem::Specification.new do |gem|
5
5
  gem.name = "celluloid-io"
6
6
  gem.version = Celluloid::IO::VERSION
7
7
  gem.license = 'MIT'
8
- gem.authors = ["Tony Arcieri"]
9
- gem.email = ["tony.arcieri@gmail.com"]
8
+ gem.authors = ["Tony Arcieri", "Donovan Keme"]
9
+ gem.email = ["tony.arcieri@gmail.com", "code@extremist.digital"]
10
10
  gem.description = "Evented IO for Celluloid actors"
11
11
  gem.summary = "Celluloid::IO allows you to monitor multiple IO objects within a Celluloid actor"
12
12
  gem.homepage = "http://github.com/celluloid/celluloid-io"
@@ -18,8 +18,7 @@ Gem::Specification.new do |gem|
18
18
 
19
19
  Celluloid::Sync::Gemspec[gem]
20
20
 
21
- gem.add_dependency 'nio4r', '>= 1.1.0'
21
+ gem.add_dependency 'nio4r', '>= 1.1'
22
22
 
23
- gem.add_development_dependency 'guard-rspec'
24
23
  gem.add_development_dependency 'rb-fsevent', '~> 0.9.1' if RUBY_PLATFORM =~ /darwin/
25
24
  end
@@ -77,7 +77,7 @@ module Celluloid
77
77
  end
78
78
 
79
79
  def resolve_host(host)
80
- resolve_ip(Resolv::IPv4, host) || resolve_ip(Resolv::IPv6, host)
80
+ resolve_ip(Resolv::IPv4, host) || get_address(host) || resolve_ip(Resolv::IPv6, host)
81
81
  end
82
82
 
83
83
  def resolve_ip(klass, host)
@@ -86,6 +86,13 @@ module Celluloid
86
86
  rescue ArgumentError
87
87
  end
88
88
  end
89
+
90
+ private
91
+
92
+ def get_address(host)
93
+ Resolv::Hosts.new(host).get_address.
94
+ rescue
95
+ end
89
96
  end
90
97
  end
91
98
  end
@@ -142,7 +142,7 @@ module Celluloid
142
142
  ret
143
143
  end
144
144
 
145
- # Reads the next "line+ from the stream. Lines are separated by +eol+. If
145
+ # Reads the next line from the stream. Lines are separated by +eol+. If
146
146
  # +limit+ is provided the result will not be longer than the given number of
147
147
  # bytes.
148
148
  #
@@ -12,7 +12,17 @@ module Celluloid
12
12
  end
13
13
 
14
14
  def initialize(socket_path)
15
- @server = ::UNIXServer.new(socket_path)
15
+ begin
16
+ @server = ::UNIXServer.new(socket_path)
17
+ rescue => ex
18
+ # Translate the EADDRINUSE jRuby exception.
19
+ raise unless RUBY_PLATFORM == 'java'
20
+ if ex.class.name == "IOError" && # Won't agree to .is_a?(IOError)
21
+ ex.message.include?("in use")
22
+ raise Errno::EADDRINUSE.new(ex.message)
23
+ end
24
+ raise
25
+ end
16
26
  end
17
27
 
18
28
  def accept
@@ -1,5 +1,5 @@
1
1
  module Celluloid
2
2
  module IO
3
- VERSION = "0.16.5.pre0"
3
+ VERSION = "0.17.0"
4
4
  end
5
5
  end
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Celluloid::IO::Reactor do
4
4
  let(:payload) { "balls" }
5
+ let(:example_port) { assign_port }
5
6
 
6
7
  it "shouldn't crash" do
7
8
  server = ::TCPServer.new example_addr, example_port
@@ -21,8 +22,8 @@ describe Celluloid::IO::Reactor do
21
22
  socket.readpartial(2046)
22
23
  end
23
24
  end
24
- # rescuing timeout, ok. rescuing terminated error, is it ok? TODO: investigate
25
- rescue Celluloid::Task::TerminatedError, Timeout::Error
25
+ # rescuing timeout, ok. rescuing terminated exception, is it ok? TODO: investigate
26
+ rescue Celluloid::TaskTerminated, Celluloid::TaskTimeout, Timeout::Error
26
27
  ensure
27
28
  socket.readpartial(2046)
28
29
  handle = true
@@ -9,7 +9,8 @@ describe Celluloid::IO::SSLServer do
9
9
  context.key = client_key
10
10
  end
11
11
  end
12
-
12
+
13
+ let(:example_port) { assign_port }
13
14
  let(:server_cert) { OpenSSL::X509::Certificate.new fixture_dir.join("server.crt").read }
14
15
  let(:server_key) { OpenSSL::PKey::RSA.new fixture_dir.join("server.key").read }
15
16
  let(:server_context) do
@@ -24,15 +25,15 @@ describe Celluloid::IO::SSLServer do
24
25
 
25
26
  context "inside Celluloid::IO" do
26
27
  it "should be evented" do
27
- with_ssl_server do |subject|
28
+ with_ssl_server(example_port) do |subject|
28
29
  expect(within_io_actor { Celluloid::IO.evented? }).to be_truthy
29
30
  end
30
31
  end
31
32
 
32
33
  it "accepts a connection and returns a Celluloid::IO::SSLSocket" do
33
- with_ssl_server do |subject|
34
+ with_ssl_server(example_port) do |subject|
34
35
  thread = Thread.new do
35
- raw = TCPSocket.new(example_addr, example_ssl_port)
36
+ raw = TCPSocket.new(example_addr, example_port)
36
37
  OpenSSL::SSL::SSLSocket.new(raw, client_context).connect
37
38
  end
38
39
  peer = within_io_actor { subject.accept }
@@ -47,15 +48,15 @@ describe Celluloid::IO::SSLServer do
47
48
 
48
49
  context "outside Celluloid::IO" do
49
50
  it "should be blocking" do
50
- with_ssl_server do |subject|
51
+ with_ssl_server(example_port) do |subject|
51
52
  expect(Celluloid::IO).not_to be_evented
52
53
  end
53
54
  end
54
55
 
55
56
  it "accepts a connection and returns a Celluloid::IO::SSLSocket" do
56
- with_ssl_server do |subject|
57
+ with_ssl_server(example_port) do |subject|
57
58
  thread = Thread.new do
58
- raw = TCPSocket.new(example_addr, example_ssl_port)
59
+ raw = TCPSocket.new(example_addr, example_port)
59
60
  OpenSSL::SSL::SSLSocket.new(raw, client_context).connect
60
61
  end
61
62
  peer = subject.accept
@@ -71,15 +72,15 @@ describe Celluloid::IO::SSLServer do
71
72
 
72
73
  describe "#initialize" do
73
74
  it "should auto-wrap a raw ::TCPServer" do
74
- raw_server = ::TCPServer.new(example_addr, example_ssl_port)
75
- with_ssl_server(raw_server) do |ssl_server|
75
+ raw_server = ::TCPServer.new(example_addr, example_port)
76
+ with_ssl_server(example_port, raw_server) do |ssl_server|
76
77
  expect(ssl_server.tcp_server.class).to eq(Celluloid::IO::TCPServer)
77
78
  end
78
79
  end
79
80
  end
80
81
 
81
- def with_ssl_server(raw_server = nil)
82
- raw_server ||= Celluloid::IO::TCPServer.new(example_addr, example_ssl_port)
82
+ def with_ssl_server(port, raw_server = nil)
83
+ raw_server ||= Celluloid::IO::TCPServer.new(example_addr, port)
83
84
  server = Celluloid::IO::SSLServer.new(raw_server, server_context)
84
85
  begin
85
86
  yield server
@@ -5,6 +5,7 @@ describe Celluloid::IO::SSLSocket do
5
5
  let(:request) { 'ping' }
6
6
  let(:response) { 'pong' }
7
7
 
8
+ let(:example_port) { assign_port }
8
9
  let(:client_cert) { OpenSSL::X509::Certificate.new fixture_dir.join("client.crt").read }
9
10
  let(:client_key) { OpenSSL::PKey::RSA.new fixture_dir.join("client.key").read }
10
11
  let(:client_context) do
@@ -14,21 +15,33 @@ describe Celluloid::IO::SSLSocket do
14
15
  end
15
16
  end
16
17
 
17
- let(:client) do
18
- remaining_attempts = 3
19
-
20
- begin
21
- TCPSocket.new example_addr, example_ssl_port
22
- rescue Errno::ECONNREFUSED
23
- # HAX: sometimes this fails to connect? o_O
24
- # This is quite likely due to the Thread.pass style spinlocks for startup
25
- raise if remaining_attempts < 1
26
- remaining_attempts -= 1
18
+ after(:each) {
19
+ client.close rescue nil
20
+ server.close rescue nil
21
+ }
27
22
 
28
- # Seems gimpy, but sleep and retry
29
- sleep 0.1
30
- retry
23
+ let(:client) do
24
+ attempts = 0
25
+ socket = begin
26
+ Timeout.timeout(MAX_TIME) {
27
+ begin
28
+ TCPSocket.new example_addr, example_port
29
+ rescue Errno::ECONNREFUSED
30
+ raise if attempts >= MAX_ATTEMPTS
31
+ attempts += 1
32
+ # HAX: sometimes this fails to connect? o_O
33
+ # ... This can often fail 20 times in a row ... so yeah
34
+ # This is quite likely due to the Thread.pass style spinlocks for startup
35
+ # Seems gimpy, but sleep and retry
36
+ sleep 0.0126
37
+ retry
38
+ end
39
+ }
40
+ rescue => ex
41
+ attempted = "Tried #{attempts} times to instantiate socket."
42
+ raise ex.class.new(attempted)
31
43
  end
44
+ return socket
32
45
  end
33
46
 
34
47
  let(:ssl_client) { Celluloid::IO::SSLSocket.new client, client_context }
@@ -42,21 +55,23 @@ describe Celluloid::IO::SSLSocket do
42
55
  end
43
56
  end
44
57
 
45
- let(:server) { TCPServer.new example_addr, example_ssl_port }
46
- let(:ssl_server) { OpenSSL::SSL::SSLServer.new server, server_context }
58
+ let(:server) { TCPServer.new example_addr, example_port }
59
+ let(:ssl_server) { OpenSSL::SSL::SSLServer.new(server, server_context) }
47
60
  let(:server_thread) do
48
- Thread.new { ssl_server.accept }.tap do |thread|
61
+ server = Thread.new { ssl_server.accept }.tap do |thread|
49
62
  Thread.pass while thread.status && thread.status != "sleep"
50
63
  thread.join unless thread.status
51
64
  end
65
+ server
52
66
  end
53
67
 
54
- let(:celluloid_server) { Celluloid::IO::TCPServer.new example_addr, example_ssl_port }
68
+ let(:celluloid_server) { Celluloid::IO::TCPServer.new example_addr, example_port }
55
69
  let(:raw_server_thread) do
56
- Thread.new { celluloid_server.accept }.tap do |thread|
70
+ server = Thread.new { celluloid_server.accept }.tap do |thread|
57
71
  Thread.pass while thread.status && thread.status != "sleep"
58
72
  thread.join unless thread.status
59
73
  end
74
+ server
60
75
  end
61
76
 
62
77
  context "duck typing ::SSLSocket" do
@@ -195,6 +210,7 @@ describe Celluloid::IO::SSLSocket do
195
210
 
196
211
  def with_ssl_sockets
197
212
  server_thread
213
+ sleep 0.222 # Needs time to spin up, or will throw out Errno::ECONNECTREFUSED to client.
198
214
  ssl_client.connect
199
215
 
200
216
  begin
@@ -210,6 +226,7 @@ describe Celluloid::IO::SSLSocket do
210
226
 
211
227
  def with_raw_sockets
212
228
  raw_server_thread
229
+ sleep 0.222 # Needs time to spin up, or will throw out Errno::ECONNECTREFUSED to client.
213
230
  client
214
231
 
215
232
  begin
@@ -3,6 +3,7 @@ require 'spec_helper'
3
3
  describe Celluloid::IO::TCPServer do
4
4
  describe "#accept" do
5
5
  let(:payload) { 'ohai' }
6
+ let(:example_port) { assign_port }
6
7
 
7
8
  it "can be initialized without a host" do
8
9
  expect { Celluloid::IO::TCPServer.new(2000).close }.to_not raise_error
@@ -10,13 +11,13 @@ describe Celluloid::IO::TCPServer do
10
11
 
11
12
  context "inside Celluloid::IO" do
12
13
  it "should be evented" do
13
- with_tcp_server do |subject|
14
+ with_tcp_server(example_port) do |subject|
14
15
  expect(within_io_actor { Celluloid::IO.evented? }).to be_truthy
15
16
  end
16
17
  end
17
18
 
18
19
  it "accepts a connection and returns a Celluloid::IO::TCPSocket" do
19
- with_tcp_server do |subject|
20
+ with_tcp_server(example_port) do |subject|
20
21
  thread = Thread.new { TCPSocket.new(example_addr, example_port) }
21
22
  peer = within_io_actor { subject.accept }
22
23
  expect(peer).to be_a Celluloid::IO::TCPSocket
@@ -29,13 +30,13 @@ describe Celluloid::IO::TCPServer do
29
30
 
30
31
  context "outside Celluloid::IO" do
31
32
  it "should be blocking" do
32
- with_tcp_server do |subject|
33
+ with_tcp_server(example_port) do |subject|
33
34
  expect(Celluloid::IO).not_to be_evented
34
35
  end
35
36
  end
36
37
 
37
38
  it "accepts a connection and returns a Celluloid::IO::TCPSocket" do
38
- with_tcp_server do |subject|
39
+ with_tcp_server(example_port) do |subject|
39
40
  thread = Thread.new { TCPSocket.new(example_addr, example_port) }
40
41
  peer = subject.accept
41
42
  expect(peer).to be_a Celluloid::IO::TCPSocket
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Celluloid::IO::TCPSocket do
4
4
  let(:payload) { 'ohai' }
5
+ let(:example_port) { assign_port }
5
6
 
6
7
  context "inside Celluloid::IO" do
7
8
 
@@ -46,55 +47,55 @@ describe Celluloid::IO::TCPSocket do
46
47
  end
47
48
 
48
49
  it "should be evented" do
49
- with_connected_sockets do |subject|
50
+ with_connected_sockets(example_port) do |subject|
50
51
  expect(within_io_actor { Celluloid::IO.evented? }).to be_truthy
51
52
  end
52
53
  end
53
54
 
54
55
  it "read complete payload when nil size is given to #read" do
55
- with_connected_sockets do |subject, peer|
56
+ with_connected_sockets(example_port) do |subject, peer|
56
57
  peer << payload
57
58
  expect(within_io_actor { subject.read(nil) }).to eq payload
58
59
  end
59
60
  end
60
61
 
61
62
  it "read complete payload when no size is given to #read" do
62
- with_connected_sockets do |subject, peer|
63
+ with_connected_sockets(example_port) do |subject, peer|
63
64
  peer << payload
64
65
  expect(within_io_actor { subject.read }).to eq payload
65
66
  end
66
67
  end
67
68
 
68
69
  it "reads data" do
69
- with_connected_sockets do |subject, peer|
70
+ with_connected_sockets(example_port) do |subject, peer|
70
71
  peer << payload
71
72
  expect(within_io_actor { subject.read(payload.size) }).to eq payload
72
73
  end
73
74
  end
74
75
 
75
76
  it "reads data in binary encoding" do
76
- with_connected_sockets do |subject, peer|
77
+ with_connected_sockets(example_port) do |subject, peer|
77
78
  peer << payload
78
79
  expect(within_io_actor { subject.read(payload.size).encoding }).to eq Encoding::BINARY
79
80
  end
80
81
  end
81
82
 
82
83
  it "reads partial data" do
83
- with_connected_sockets do |subject, peer|
84
+ with_connected_sockets(example_port) do |subject, peer|
84
85
  peer << payload * 2
85
86
  expect(within_io_actor { subject.readpartial(payload.size) }).to eq payload
86
87
  end
87
88
  end
88
89
 
89
90
  it "reads partial data in binary encoding" do
90
- with_connected_sockets do |subject, peer|
91
+ with_connected_sockets(example_port) do |subject, peer|
91
92
  peer << payload * 2
92
93
  expect(within_io_actor { subject.readpartial(payload.size).encoding }).to eq Encoding::BINARY
93
94
  end
94
95
  end
95
96
 
96
97
  it "writes data" do
97
- with_connected_sockets do |subject, peer|
98
+ with_connected_sockets(example_port) do |subject, peer|
98
99
  within_io_actor { subject << payload }
99
100
  expect(peer.read(payload.size)).to eq payload
100
101
  end
@@ -108,7 +109,7 @@ describe Celluloid::IO::TCPSocket do
108
109
 
109
110
  context 'eof?' do
110
111
  it "blocks actor then returns by close" do
111
- with_connected_sockets do |subject, peer|
112
+ with_connected_sockets(example_port) do |subject, peer|
112
113
  started_at = Time.now
113
114
  Thread.new{ sleep 0.5; peer.close; }
114
115
  within_io_actor { subject.eof? }
@@ -117,7 +118,7 @@ describe Celluloid::IO::TCPSocket do
117
118
  end
118
119
 
119
120
  it "blocks until gets the next byte" do
120
- with_connected_sockets do |subject, peer|
121
+ with_connected_sockets(example_port) do |subject, peer|
121
122
  peer << 0x00
122
123
  peer.flush
123
124
  expect {
@@ -127,14 +128,14 @@ describe Celluloid::IO::TCPSocket do
127
128
  expect(subject.eof?).to be_falsey
128
129
  }
129
130
  }
130
- }.to raise_error(Celluloid::Task::TimeoutError)
131
+ }.to raise_error(Celluloid::TaskTimeout)
131
132
  end
132
133
  end
133
134
  end
134
135
 
135
136
  context "readpartial" do
136
137
  it "raises EOFError when reading from a closed socket" do
137
- with_connected_sockets do |subject, peer|
138
+ with_connected_sockets(example_port) do |subject, peer|
138
139
  peer.close
139
140
  expect {
140
141
  within_io_actor { subject.readpartial(payload.size) }
@@ -145,7 +146,7 @@ describe Celluloid::IO::TCPSocket do
145
146
  it "raises IOError when active sockets are closed across threads" do
146
147
  pending "not implemented"
147
148
 
148
- with_connected_sockets do |subject, peer|
149
+ with_connected_sockets(example_port) do |subject, peer|
149
150
  actor = ExampleActor.new
150
151
  begin
151
152
  read_future = actor.future.wrap do
@@ -162,7 +163,7 @@ describe Celluloid::IO::TCPSocket do
162
163
 
163
164
  it "raises IOError when partial reading from a socket the peer closed" do
164
165
  pending "async block running on receiver"
165
- with_connected_sockets do |subject, peer|
166
+ with_connected_sockets(example_port) do |subject, peer|
166
167
  actor = ExampleActor.new
167
168
  begin
168
169
  actor.async.wrap { sleep 0.01; peer.close }
@@ -193,27 +194,27 @@ describe Celluloid::IO::TCPSocket do
193
194
  end
194
195
 
195
196
  it "should be blocking" do
196
- with_connected_sockets do |subject|
197
+ with_connected_sockets(example_port) do |subject|
197
198
  expect(Celluloid::IO).not_to be_evented
198
199
  end
199
200
  end
200
201
 
201
202
  it "reads data" do
202
- with_connected_sockets do |subject, peer|
203
+ with_connected_sockets(example_port) do |subject, peer|
203
204
  peer << payload
204
205
  expect(subject.read(payload.size)).to eq payload
205
206
  end
206
207
  end
207
208
 
208
209
  it "reads partial data" do
209
- with_connected_sockets do |subject, peer|
210
+ with_connected_sockets(example_port) do |subject, peer|
210
211
  peer << payload * 2
211
212
  expect(subject.readpartial(payload.size)).to eq payload
212
213
  end
213
214
  end
214
215
 
215
216
  it "writes data" do
216
- with_connected_sockets do |subject, peer|
217
+ with_connected_sockets(example_port) do |subject, peer|
217
218
  subject << payload
218
219
  expect(peer.read(payload.size)).to eq payload
219
220
  end
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Celluloid::IO::UDPSocket do
4
4
  let(:payload) { 'ohai' }
5
+ let(:example_port) { assign_port }
5
6
  subject do
6
7
  Celluloid::IO::UDPSocket.new.tap do |sock|
7
8
  sock.bind example_addr, example_port
@@ -1,13 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Celluloid::IO::UNIXServer do
4
-
5
- if RUBY_PLATFORM == 'java'
6
- before(:each) do
7
- pending "jRuby support"
8
- fail "Avoid potential deadlock under jRuby"
9
- end
10
- end
4
+ let(:example_port) { assign_port }
11
5
 
12
6
  describe "#accept" do
13
7
 
@@ -21,6 +15,7 @@ describe Celluloid::IO::UNIXServer do
21
15
  end
22
16
 
23
17
  it "accepts a connection and returns a Celluloid::IO::UNIXSocket" do
18
+ pending if RUBY_PLATFORM == 'java'
24
19
  with_unix_server do |subject|
25
20
  thread = Thread.new { UNIXSocket.new(example_unix_sock) }
26
21
  peer = within_io_actor { subject.accept }
@@ -10,6 +10,7 @@ describe Celluloid::IO::UNIXSocket do
10
10
  end
11
11
 
12
12
  let(:payload) { 'ohai' }
13
+ let(:example_port) { assign_port }
13
14
 
14
15
  context "inside Celluloid::IO" do
15
16
  it "connects to UNIX servers" do
@@ -99,7 +100,7 @@ describe Celluloid::IO::UNIXSocket do
99
100
 
100
101
  context 'eof?' do
101
102
  it "blocks actor then returns by close" do
102
- with_connected_sockets do |subject, peer|
103
+ with_connected_sockets(example_port) do |subject, peer|
103
104
  started_at = Time.now
104
105
  Thread.new{ sleep 0.5; peer.close; }
105
106
  within_io_actor { subject.eof? }
@@ -108,7 +109,7 @@ describe Celluloid::IO::UNIXSocket do
108
109
  end
109
110
 
110
111
  it "blocks until gets the next byte" do
111
- with_connected_sockets do |subject, peer|
112
+ with_connected_sockets(example_port) do |subject, peer|
112
113
  peer << 0x00
113
114
  peer.flush
114
115
  expect {
@@ -118,7 +119,7 @@ describe Celluloid::IO::UNIXSocket do
118
119
  expect(subject.eof?).to be_falsey
119
120
  }
120
121
  }
121
- }.to raise_error(Celluloid::Task::TimeoutError)
122
+ }.to raise_error(Celluloid::TaskTimeout)
122
123
  end
123
124
  end
124
125
  end
data/spec/spec_helper.rb CHANGED
@@ -3,8 +3,12 @@ require 'bundler/setup'
3
3
  require 'celluloid/io'
4
4
  require 'celluloid/rspec'
5
5
  require 'coveralls'
6
+
6
7
  Coveralls.wear!
7
8
 
9
+ MAX_TIME = 7
10
+ MAX_ATTEMPTS = 20
11
+
8
12
  logfile = File.open(File.expand_path("../../log/test.log", __FILE__), 'a')
9
13
  logfile.sync = true
10
14
 
@@ -16,12 +20,16 @@ RSpec.configure do |config|
16
20
  config.filter_run :focus => true
17
21
  config.run_all_when_everything_filtered = true
18
22
 
23
+ config.around(:each) { |example|
24
+ Timeout.timeout(MAX_TIME) {
25
+ example.run
26
+ }
27
+ }
28
+
19
29
  config.before do
20
30
  Celluloid.logger = logger
21
31
  Celluloid.shutdown
22
-
23
32
  Celluloid.boot
24
-
25
33
  FileUtils.rm("/tmp/cell_sock") if File.exist?("/tmp/cell_sock")
26
34
  end
27
35
  end
@@ -35,12 +43,27 @@ class ExampleActor
35
43
  end
36
44
  end
37
45
 
38
- EXAMPLE_PORT = 12345 + Random.rand(1024)
46
+ # Would use Addrinfo(addr,0) but the class is missing/unstable on RBX.
47
+ def assign_port
48
+ port = 12000 + Random.rand(1024)
49
+ attempts = 0
50
+ begin
51
+ socket = ::TCPServer.new(example_addr, port)
52
+ rescue Errno::ECONNREFUSED, Errno::EADDRINUSE => ex
53
+ raise ex.class.new("Tried #{attempts} times to assign port.") unless attempts < MAX_ATTEMPTS
54
+ attempts += 1
55
+ port += 1
56
+ socket.close rescue nil
57
+ sleep 0.126
58
+ retry
59
+ end
60
+ return port
61
+ ensure
62
+ socket.close rescue nil
63
+ end
39
64
 
40
65
  def example_addr; '127.0.0.1'; end
41
- def example_port; EXAMPLE_PORT; end
42
66
  def example_unix_sock; '/tmp/cell_sock'; end
43
- def example_ssl_port; EXAMPLE_PORT + 1; end
44
67
 
45
68
  def fixture_dir; Pathname.new File.expand_path("../fixtures", __FILE__); end
46
69
 
@@ -51,8 +74,8 @@ ensure
51
74
  actor.terminate if actor.alive?
52
75
  end
53
76
 
54
- def with_tcp_server
55
- server = Celluloid::IO::TCPServer.new(example_addr, example_port)
77
+ def with_tcp_server(port)
78
+ server = Celluloid::IO::TCPServer.new(example_addr, port)
56
79
  begin
57
80
  yield server
58
81
  ensure
@@ -70,9 +93,9 @@ def with_unix_server
70
93
  end
71
94
  end
72
95
 
73
- def with_connected_sockets
74
- with_tcp_server do |server|
75
- client = Celluloid::IO::TCPSocket.new(example_addr, example_port)
96
+ def with_connected_sockets(port)
97
+ with_tcp_server(port) do |server|
98
+ client = Celluloid::IO::TCPSocket.new(example_addr, port)
76
99
  peer = server.accept
77
100
 
78
101
  begin
metadata CHANGED
@@ -1,295 +1,311 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celluloid-io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.5.pre0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
8
- autorequire:
8
+ - Donovan Keme
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-05-09 00:00:00.000000000 Z
12
+ date: 2015-08-09 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
15
+ name: bundler
14
16
  requirement: !ruby/object:Gem::Requirement
15
17
  requirements:
16
- - - '>='
18
+ - - ">="
17
19
  - !ruby/object:Gem::Version
18
20
  version: '0'
19
- name: bundler
20
- prerelease: false
21
21
  type: :runtime
22
+ prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - '>='
25
+ - - ">="
25
26
  - !ruby/object:Gem::Version
26
27
  version: '0'
27
28
  - !ruby/object:Gem::Dependency
29
+ name: nenv
28
30
  requirement: !ruby/object:Gem::Requirement
29
31
  requirements:
30
- - - '>='
32
+ - - ">="
31
33
  - !ruby/object:Gem::Version
32
34
  version: '0'
33
- name: nenv
34
- prerelease: false
35
35
  type: :runtime
36
+ prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
- - - '>='
39
+ - - ">="
39
40
  - !ruby/object:Gem::Version
40
41
  version: '0'
41
42
  - !ruby/object:Gem::Dependency
43
+ name: dotenv
42
44
  requirement: !ruby/object:Gem::Requirement
43
45
  requirements:
44
- - - '>='
46
+ - - ">="
45
47
  - !ruby/object:Gem::Version
46
48
  version: '0'
47
- name: dotenv
48
- prerelease: false
49
49
  type: :runtime
50
+ prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
- - - '>='
53
+ - - ">="
53
54
  - !ruby/object:Gem::Version
54
55
  version: '0'
55
56
  - !ruby/object:Gem::Dependency
57
+ name: benchmark_suite
56
58
  requirement: !ruby/object:Gem::Requirement
57
59
  requirements:
58
- - - '>='
60
+ - - ">="
59
61
  - !ruby/object:Gem::Version
60
62
  version: '0'
61
- name: benchmark_suite
62
- prerelease: false
63
63
  type: :development
64
+ prerelease: false
64
65
  version_requirements: !ruby/object:Gem::Requirement
65
66
  requirements:
66
- - - '>='
67
+ - - ">="
67
68
  - !ruby/object:Gem::Version
68
69
  version: '0'
69
70
  - !ruby/object:Gem::Dependency
71
+ name: rubocop
70
72
  requirement: !ruby/object:Gem::Requirement
71
73
  requirements:
72
- - - '>='
74
+ - - ">="
73
75
  - !ruby/object:Gem::Version
74
76
  version: '0'
75
- name: rubocop
76
- prerelease: false
77
77
  type: :development
78
+ prerelease: false
78
79
  version_requirements: !ruby/object:Gem::Requirement
79
80
  requirements:
80
- - - '>='
81
+ - - ">="
81
82
  - !ruby/object:Gem::Version
82
83
  version: '0'
83
84
  - !ruby/object:Gem::Dependency
85
+ name: transpec
84
86
  requirement: !ruby/object:Gem::Requirement
85
87
  requirements:
86
- - - '>='
88
+ - - ">="
87
89
  - !ruby/object:Gem::Version
88
90
  version: '0'
89
- name: pry
90
- prerelease: false
91
91
  type: :development
92
+ prerelease: false
92
93
  version_requirements: !ruby/object:Gem::Requirement
93
94
  requirements:
94
- - - '>='
95
+ - - ">="
95
96
  - !ruby/object:Gem::Version
96
97
  version: '0'
97
98
  - !ruby/object:Gem::Dependency
99
+ name: pry
98
100
  requirement: !ruby/object:Gem::Requirement
99
101
  requirements:
100
- - - '>='
102
+ - - ">="
101
103
  - !ruby/object:Gem::Version
102
104
  version: '0'
103
- name: rake
104
- prerelease: false
105
105
  type: :development
106
+ prerelease: false
106
107
  version_requirements: !ruby/object:Gem::Requirement
107
108
  requirements:
108
- - - '>='
109
+ - - ">="
109
110
  - !ruby/object:Gem::Version
110
111
  version: '0'
111
112
  - !ruby/object:Gem::Dependency
113
+ name: rake
112
114
  requirement: !ruby/object:Gem::Requirement
113
115
  requirements:
114
- - - '>='
116
+ - - ">="
115
117
  - !ruby/object:Gem::Version
116
118
  version: '0'
117
- name: rspec
118
- prerelease: false
119
119
  type: :development
120
+ prerelease: false
120
121
  version_requirements: !ruby/object:Gem::Requirement
121
122
  requirements:
122
- - - '>='
123
+ - - ">="
123
124
  - !ruby/object:Gem::Version
124
125
  version: '0'
125
126
  - !ruby/object:Gem::Dependency
127
+ name: rspec
126
128
  requirement: !ruby/object:Gem::Requirement
127
129
  requirements:
128
- - - '>='
130
+ - - ">="
129
131
  - !ruby/object:Gem::Version
130
132
  version: '0'
131
- name: coveralls
132
- prerelease: false
133
133
  type: :development
134
+ prerelease: false
134
135
  version_requirements: !ruby/object:Gem::Requirement
135
136
  requirements:
136
- - - '>='
137
+ - - ">="
137
138
  - !ruby/object:Gem::Version
138
139
  version: '0'
139
140
  - !ruby/object:Gem::Dependency
141
+ name: guard-rspec
140
142
  requirement: !ruby/object:Gem::Requirement
141
143
  requirements:
142
- - - '>='
144
+ - - ">="
143
145
  - !ruby/object:Gem::Version
144
- version: 0.17.0.pre12
145
- name: celluloid
146
+ version: '0'
147
+ type: :development
146
148
  prerelease: false
147
- type: :runtime
148
149
  version_requirements: !ruby/object:Gem::Requirement
149
150
  requirements:
150
- - - '>='
151
+ - - ">="
151
152
  - !ruby/object:Gem::Version
152
- version: 0.17.0.pre12
153
+ version: '0'
153
154
  - !ruby/object:Gem::Dependency
155
+ name: coveralls
154
156
  requirement: !ruby/object:Gem::Requirement
155
157
  requirements:
156
- - - '>='
158
+ - - ">="
157
159
  - !ruby/object:Gem::Version
158
160
  version: '0'
159
- name: celluloid-essentials
160
- prerelease: false
161
161
  type: :development
162
+ prerelease: false
162
163
  version_requirements: !ruby/object:Gem::Requirement
163
164
  requirements:
164
- - - '>='
165
+ - - ">="
165
166
  - !ruby/object:Gem::Version
166
167
  version: '0'
167
168
  - !ruby/object:Gem::Dependency
169
+ name: celluloid
168
170
  requirement: !ruby/object:Gem::Requirement
169
171
  requirements:
170
- - - '>='
172
+ - - "~>"
171
173
  - !ruby/object:Gem::Version
172
- version: '0'
173
- name: celluloid-supervision
174
+ version: '0.17'
175
+ type: :runtime
174
176
  prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - "~>"
180
+ - !ruby/object:Gem::Version
181
+ version: '0.17'
182
+ - !ruby/object:Gem::Dependency
183
+ name: celluloid-essentials
184
+ requirement: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
175
189
  type: :development
190
+ prerelease: false
176
191
  version_requirements: !ruby/object:Gem::Requirement
177
192
  requirements:
178
- - - '>='
193
+ - - ">="
179
194
  - !ruby/object:Gem::Version
180
195
  version: '0'
181
196
  - !ruby/object:Gem::Dependency
197
+ name: celluloid-supervision
182
198
  requirement: !ruby/object:Gem::Requirement
183
199
  requirements:
184
- - - '>='
200
+ - - ">="
185
201
  - !ruby/object:Gem::Version
186
202
  version: '0'
187
- name: celluloid-pool
188
- prerelease: false
189
203
  type: :development
204
+ prerelease: false
190
205
  version_requirements: !ruby/object:Gem::Requirement
191
206
  requirements:
192
- - - '>='
207
+ - - ">="
193
208
  - !ruby/object:Gem::Version
194
209
  version: '0'
195
210
  - !ruby/object:Gem::Dependency
211
+ name: celluloid-pool
196
212
  requirement: !ruby/object:Gem::Requirement
197
213
  requirements:
198
- - - '>='
214
+ - - ">="
199
215
  - !ruby/object:Gem::Version
200
216
  version: '0'
201
- name: celluloid-fsm
202
- prerelease: false
203
217
  type: :development
218
+ prerelease: false
204
219
  version_requirements: !ruby/object:Gem::Requirement
205
220
  requirements:
206
- - - '>='
221
+ - - ">="
207
222
  - !ruby/object:Gem::Version
208
223
  version: '0'
209
224
  - !ruby/object:Gem::Dependency
225
+ name: celluloid-fsm
210
226
  requirement: !ruby/object:Gem::Requirement
211
227
  requirements:
212
- - - '>='
228
+ - - ">="
213
229
  - !ruby/object:Gem::Version
214
230
  version: '0'
215
- name: celluloid-extras
216
- prerelease: false
217
231
  type: :development
232
+ prerelease: false
218
233
  version_requirements: !ruby/object:Gem::Requirement
219
234
  requirements:
220
- - - '>='
235
+ - - ">="
221
236
  - !ruby/object:Gem::Version
222
237
  version: '0'
223
238
  - !ruby/object:Gem::Dependency
239
+ name: celluloid-extras
224
240
  requirement: !ruby/object:Gem::Requirement
225
241
  requirements:
226
- - - ~>
242
+ - - ">="
227
243
  - !ruby/object:Gem::Version
228
- version: 4.0.0
229
- name: timers
244
+ version: '0'
245
+ type: :development
230
246
  prerelease: false
231
- type: :runtime
232
247
  version_requirements: !ruby/object:Gem::Requirement
233
248
  requirements:
234
- - - ~>
249
+ - - ">="
235
250
  - !ruby/object:Gem::Version
236
- version: 4.0.0
251
+ version: '0'
237
252
  - !ruby/object:Gem::Dependency
253
+ name: timers
238
254
  requirement: !ruby/object:Gem::Requirement
239
255
  requirements:
240
- - - '>='
256
+ - - "~>"
241
257
  - !ruby/object:Gem::Version
242
- version: 0.1.2
243
- name: rspec-logsplit
244
- prerelease: false
258
+ version: 4.0.0
245
259
  type: :runtime
260
+ prerelease: false
246
261
  version_requirements: !ruby/object:Gem::Requirement
247
262
  requirements:
248
- - - '>='
263
+ - - "~>"
249
264
  - !ruby/object:Gem::Version
250
- version: 0.1.2
265
+ version: 4.0.0
251
266
  - !ruby/object:Gem::Dependency
267
+ name: rspec-logsplit
252
268
  requirement: !ruby/object:Gem::Requirement
253
269
  requirements:
254
- - - '>='
270
+ - - ">="
255
271
  - !ruby/object:Gem::Version
256
- version: 1.1.0
257
- name: nio4r
258
- prerelease: false
272
+ version: 0.1.2
259
273
  type: :runtime
274
+ prerelease: false
260
275
  version_requirements: !ruby/object:Gem::Requirement
261
276
  requirements:
262
- - - '>='
277
+ - - ">="
263
278
  - !ruby/object:Gem::Version
264
- version: 1.1.0
279
+ version: 0.1.2
265
280
  - !ruby/object:Gem::Dependency
281
+ name: nio4r
266
282
  requirement: !ruby/object:Gem::Requirement
267
283
  requirements:
268
- - - '>='
284
+ - - ">="
269
285
  - !ruby/object:Gem::Version
270
- version: '0'
271
- name: guard-rspec
286
+ version: '1.1'
287
+ type: :runtime
272
288
  prerelease: false
273
- type: :development
274
289
  version_requirements: !ruby/object:Gem::Requirement
275
290
  requirements:
276
- - - '>='
291
+ - - ">="
277
292
  - !ruby/object:Gem::Version
278
- version: '0'
293
+ version: '1.1'
279
294
  description: Evented IO for Celluloid actors
280
295
  email:
281
296
  - tony.arcieri@gmail.com
297
+ - code@extremist.digital
282
298
  executables: []
283
299
  extensions: []
284
300
  extra_rdoc_files: []
285
301
  files:
286
- - .coveralls.yml
287
- - .env-ci
288
- - .env-dev
289
- - .gitignore
290
- - .gitmodules
291
- - .rspec
292
- - .travis.yml
302
+ - ".coveralls.yml"
303
+ - ".env-ci"
304
+ - ".env-dev"
305
+ - ".gitignore"
306
+ - ".gitmodules"
307
+ - ".rspec"
308
+ - ".travis.yml"
293
309
  - CHANGES.md
294
310
  - Gemfile
295
311
  - Guardfile
@@ -340,24 +356,25 @@ homepage: http://github.com/celluloid/celluloid-io
340
356
  licenses:
341
357
  - MIT
342
358
  metadata: {}
343
- post_install_message:
359
+ post_install_message:
344
360
  rdoc_options: []
345
361
  require_paths:
346
362
  - lib
347
363
  required_ruby_version: !ruby/object:Gem::Requirement
348
364
  requirements:
349
- - - '>='
365
+ - - ">="
350
366
  - !ruby/object:Gem::Version
351
367
  version: '0'
352
368
  required_rubygems_version: !ruby/object:Gem::Requirement
353
369
  requirements:
354
- - - '>'
370
+ - - ">="
355
371
  - !ruby/object:Gem::Version
356
- version: 1.3.1
372
+ version: '0'
357
373
  requirements: []
358
- rubyforge_project:
359
- rubygems_version: 2.4.6
360
- signing_key:
374
+ rubyforge_project:
375
+ rubygems_version: 2.4.8
376
+ signing_key:
361
377
  specification_version: 4
362
- summary: Celluloid::IO allows you to monitor multiple IO objects within a Celluloid actor
378
+ summary: Celluloid::IO allows you to monitor multiple IO objects within a Celluloid
379
+ actor
363
380
  test_files: []