celluloid-io 0.16.1 → 0.16.2

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: 2a14112c061df1e593c0c40f73f6bbafbb937419
4
- data.tar.gz: 2fc0714e1b2064a425105db7779ce83bbdb85508
3
+ metadata.gz: 478d600640a4868162a199bc7db4ac8926be40f2
4
+ data.tar.gz: d0cc206f1aeb05290be388ba6fc0e66375bd179f
5
5
  SHA512:
6
- metadata.gz: 0853eb2f8d75efb7287a95ae81d74a2c619d7a7f79cce162110faafda75f4e41049bbf1134615b6abba5c14361a3e9dff69847ae199a9fa3f1898cd024033661
7
- data.tar.gz: a195890888ace5714d9781c4683a6b23c4a6f3208cedaf9619c92520cf34a0ef1ee57c9bd2457a36d018ae3f433c83b23e69e5105579208570906d9167edf081
6
+ metadata.gz: 244c3a718d4e0237682640dd2e4005fbf254893f0c12441efc7cab19de65585ac4e14a8b99e7e11cf796c4c8cf1e18dc60cab259787b0fabffaa306fa73d240c
7
+ data.tar.gz: 09a0bbc5a409bde43ada45ac692467a9702d98d79f45e27d63ddcc6586e682cb3ff0d067e1e764e1b06a839de37d849d35efb05db9b0c6304a18aee63c02c994
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.16.2 (2014-01-30)
2
+ -------------------
3
+ * More TCPSocket compatibility fixes
4
+ * Ensure monitors are closed when tasks resume
5
+ * Fix Errno::EAGAIN handling in Stream#syswrite
6
+
1
7
  0.16.1 (2014-10-08)
2
8
  -------------------
3
9
  * Revert read/write interest patch as it caused file descriptor leaks
data/celluloid-io.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ["lib"]
18
18
 
19
19
  gem.add_dependency 'celluloid', '>= 0.16.0'
20
- gem.add_dependency 'nio4r', '>= 1.0.0'
20
+ gem.add_dependency 'nio4r', '>= 1.1.0'
21
21
 
22
22
  gem.add_development_dependency 'rake'
23
23
  gem.add_development_dependency 'rspec', '~> 2.14.0'
@@ -41,14 +41,22 @@ module Celluloid
41
41
 
42
42
  monitor = @selector.register(io, set)
43
43
  monitor.value = Task.current
44
- Task.suspend :iowait
44
+
45
+ begin
46
+ Task.suspend :iowait
47
+ ensure
48
+ # In all cases we want to ensure that the monitor is closed once we
49
+ # have woken up. However, in some cases, the monitor is already
50
+ # invalid, e.g. in the case that we are terminating. We catch this
51
+ # case explicitly.
52
+ monitor.close
53
+ end
45
54
  end
46
55
 
47
56
  # Run the reactor, waiting for events or wakeup signal
48
57
  def run_once(timeout = nil)
49
58
  @selector.select(timeout) do |monitor|
50
59
  task = monitor.value
51
- monitor.close
52
60
 
53
61
  if task.running?
54
62
  task.resume
@@ -64,6 +64,9 @@ module Celluloid
64
64
  retry
65
65
  rescue EOFError
66
66
  return total_written
67
+ rescue Errno::EAGAIN
68
+ wait_writable
69
+ retry
67
70
  end
68
71
 
69
72
  total_written += written
@@ -14,16 +14,13 @@ module Celluloid
14
14
  # automatically when done (if a block is given)
15
15
  def self.open(*args, &block)
16
16
  sock = new(*args)
17
+ return sock unless block_given?
17
18
 
18
- if block_given?
19
- begin
20
- yield sock
21
- ensure
22
- sock.close
23
- end
19
+ begin
20
+ yield(sock)
21
+ ensure
22
+ sock.close
24
23
  end
25
-
26
- sock
27
24
  end
28
25
 
29
26
  # Convert a Ruby TCPSocket into a Celluloid::IO::TCPSocket
@@ -1,5 +1,5 @@
1
1
  module Celluloid
2
2
  module IO
3
- VERSION = "0.16.1"
3
+ VERSION = "0.16.2"
4
4
  end
5
5
  end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Celluloid::IO::Reactor do
4
+ let(:payload) { "balls" }
5
+
6
+ it "shouldn't crash" do
7
+ server = ::TCPServer.new example_addr, example_port
8
+
9
+ thread = Thread.new { server.accept }
10
+
11
+ socket = within_io_actor { Celluloid::IO::TCPSocket.new example_addr, example_port }
12
+ peer = thread.value
13
+ peer_thread = Thread.new { loop { peer << payload } }
14
+ handle = false
15
+
16
+ # Main server body:
17
+ within_io_actor do
18
+ begin
19
+ timeout(2) do
20
+ loop do
21
+ socket.readpartial(2046)
22
+ end
23
+ end
24
+ # rescuing timeout, ok. rescuing terminated error, is it ok? TODO: investigate
25
+ rescue Celluloid::Task::TerminatedError, Timeout::Error
26
+ ensure
27
+ socket.readpartial(2046)
28
+ handle = true
29
+ end
30
+ end
31
+
32
+ expect(handle).to be_true
33
+
34
+ server.close
35
+ peer.close
36
+ socket.close
37
+ end
38
+ end
@@ -4,6 +4,33 @@ describe Celluloid::IO::TCPSocket do
4
4
  let(:payload) { 'ohai' }
5
5
 
6
6
  context "inside Celluloid::IO" do
7
+
8
+ describe ".open" do
9
+ it "returns the open socket" do
10
+ server = ::TCPServer.new example_addr, example_port
11
+ thread = Thread.new { server.accept }
12
+
13
+ socket = within_io_actor { Celluloid::IO::TCPSocket.open(example_addr, example_port) }
14
+ socket.should be_a(Celluloid::IO::TCPSocket)
15
+
16
+ server.close
17
+ thread.terminate
18
+ socket.close
19
+ end
20
+ context "when passed a block" do
21
+ it "returns the block evaluation" do
22
+ server = ::TCPServer.new example_addr, example_port
23
+ thread = Thread.new { server.accept }
24
+
25
+ value = within_io_actor { Celluloid::IO::TCPSocket.open(example_addr, example_port) { true } }
26
+ value.should be_true
27
+
28
+ server.close
29
+ thread.terminate
30
+ end
31
+ end
32
+ end
33
+
7
34
  it "connects to TCP servers" do
8
35
  server = ::TCPServer.new example_addr, example_port
9
36
  thread = Thread.new { server.accept }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celluloid-io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.1
4
+ version: 0.16.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-08 00:00:00.000000000 Z
11
+ date: 2015-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.0
33
+ version: 1.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 1.0.0
40
+ version: 1.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -146,10 +146,10 @@ files:
146
146
  - lib/celluloid/io/version.rb
147
147
  - log/.gitignore
148
148
  - logo.png
149
- - spec/celluloid/io/.dns_resolver_spec.rb.swp
150
149
  - spec/celluloid/io/actor_spec.rb
151
150
  - spec/celluloid/io/dns_resolver_spec.rb
152
151
  - spec/celluloid/io/mailbox_spec.rb
152
+ - spec/celluloid/io/reactor_spec.rb
153
153
  - spec/celluloid/io/ssl_server_spec.rb
154
154
  - spec/celluloid/io/ssl_socket_spec.rb
155
155
  - spec/celluloid/io/tcp_server_spec.rb
@@ -185,16 +185,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  version: '0'
186
186
  requirements: []
187
187
  rubyforge_project:
188
- rubygems_version: 2.2.2
188
+ rubygems_version: 2.4.5
189
189
  signing_key:
190
190
  specification_version: 4
191
191
  summary: Celluloid::IO allows you to monitor multiple IO objects within a Celluloid
192
192
  actor
193
193
  test_files:
194
- - spec/celluloid/io/.dns_resolver_spec.rb.swp
195
194
  - spec/celluloid/io/actor_spec.rb
196
195
  - spec/celluloid/io/dns_resolver_spec.rb
197
196
  - spec/celluloid/io/mailbox_spec.rb
197
+ - spec/celluloid/io/reactor_spec.rb
198
198
  - spec/celluloid/io/ssl_server_spec.rb
199
199
  - spec/celluloid/io/ssl_socket_spec.rb
200
200
  - spec/celluloid/io/tcp_server_spec.rb