nio4r 1.1.0-java → 1.1.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +58 -0
- data/.rubocop_todo.yml +35 -0
- data/.travis.yml +8 -1
- data/CHANGES.md +7 -0
- data/Gemfile +2 -2
- data/Rakefile +1 -1
- data/examples/echo_server.rb +6 -7
- data/ext/libev/Changes +6 -1
- data/ext/libev/ev.c +179 -114
- data/ext/libev/ev.h +14 -7
- data/ext/nio4r/extconf.rb +23 -34
- data/ext/nio4r/selector.c +6 -0
- data/lib/nio.rb +15 -13
- data/lib/nio/monitor.rb +8 -4
- data/lib/nio/selector.rb +11 -11
- data/lib/nio/version.rb +1 -1
- data/nio4r.gemspec +4 -3
- data/spec/nio/acceptables_spec.rb +3 -3
- data/spec/nio/monitor_spec.rb +4 -3
- data/spec/nio/selectables/pipe_spec.rb +5 -5
- data/spec/nio/selectables/ssl_socket_spec.rb +12 -12
- data/spec/nio/selectables/tcp_socket_spec.rb +7 -7
- data/spec/nio/selectables/udp_socket_spec.rb +6 -6
- data/spec/nio/selector_spec.rb +4 -4
- data/spec/spec_helper.rb +7 -5
- data/spec/support/selectable_examples.rb +5 -5
- data/tasks/extension.rake +7 -7
- data/tasks/rspec.rake +2 -2
- data/tasks/rubocop.rake +3 -0
- metadata +23 -6
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
describe TCPSocket do
|
3
|
+
RSpec.describe TCPSocket do
|
4
4
|
port_offset = 0
|
5
|
-
let(:tcp_port) {
|
5
|
+
let(:tcp_port) { 12_345 + (port_offset += 1) }
|
6
6
|
|
7
7
|
let :readable_subject do
|
8
8
|
server = TCPServer.new("localhost", tcp_port)
|
@@ -37,7 +37,7 @@ describe TCPSocket do
|
|
37
37
|
begin
|
38
38
|
sock.write_nonblock "X" * 1024
|
39
39
|
_, writers = select [], [sock], [], 0
|
40
|
-
end while writers
|
40
|
+
end while writers && writers.include?(sock)
|
41
41
|
|
42
42
|
# I think the kernel might manage to drain its buffer a bit even after
|
43
43
|
# the socket first goes unwritable. Attempt to sleep past this and then
|
@@ -71,18 +71,18 @@ describe TCPSocket do
|
|
71
71
|
context :connect do
|
72
72
|
it "selects writable when connected" do
|
73
73
|
selector = NIO::Selector.new
|
74
|
-
server = TCPServer.new(
|
74
|
+
server = TCPServer.new("127.0.0.1", tcp_port)
|
75
75
|
|
76
76
|
client = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
|
77
77
|
monitor = selector.register(client, :w)
|
78
78
|
|
79
79
|
expect do
|
80
|
-
client.connect_nonblock Socket.sockaddr_in(tcp_port,
|
80
|
+
client.connect_nonblock Socket.sockaddr_in(tcp_port, "127.0.0.1")
|
81
81
|
end.to raise_exception Errno::EINPROGRESS
|
82
82
|
|
83
83
|
expect(selector.select(0)).to include monitor
|
84
84
|
result = client.getsockopt(::Socket::SOL_SOCKET, ::Socket::SO_ERROR)
|
85
|
-
expect(result.unpack(
|
85
|
+
expect(result.unpack("i").first).to be_zero
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
@@ -1,21 +1,21 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
describe UDPSocket do
|
4
|
-
let(:udp_port) {
|
3
|
+
RSpec.describe UDPSocket do
|
4
|
+
let(:udp_port) { 23_456 }
|
5
5
|
|
6
6
|
let :readable_subject do
|
7
7
|
sock = UDPSocket.new
|
8
|
-
sock.bind(
|
8
|
+
sock.bind("localhost", udp_port)
|
9
9
|
|
10
10
|
peer = UDPSocket.new
|
11
|
-
peer.send("hi there", 0,
|
11
|
+
peer.send("hi there", 0, "localhost", udp_port)
|
12
12
|
|
13
13
|
sock
|
14
14
|
end
|
15
15
|
|
16
16
|
let :unreadable_subject do
|
17
17
|
sock = UDPSocket.new
|
18
|
-
sock.bind(
|
18
|
+
sock.bind("localhost", udp_port + 1)
|
19
19
|
sock
|
20
20
|
end
|
21
21
|
|
data/spec/nio/selector_spec.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
# Timeouts should be at least this precise (in seconds) to pass the tests
|
4
4
|
# Typical precision should be better than this, but if it's worse it will fail
|
5
5
|
# the tests
|
6
6
|
TIMEOUT_PRECISION = 0.1
|
7
7
|
|
8
|
-
describe NIO::Selector do
|
8
|
+
RSpec.describe NIO::Selector do
|
9
9
|
let(:pair) { IO.pipe }
|
10
10
|
let(:reader) { pair.first }
|
11
11
|
let(:writer) { pair.last }
|
@@ -117,7 +117,7 @@ describe NIO::Selector do
|
|
117
117
|
context "select" do
|
118
118
|
it "selects IO objects" do
|
119
119
|
writer << "ohai"
|
120
|
-
unready
|
120
|
+
unready = IO.pipe.first
|
121
121
|
|
122
122
|
reader_monitor = subject.register(reader, :r)
|
123
123
|
unready_monitor = subject.register(unready, :r)
|
@@ -147,7 +147,7 @@ describe NIO::Selector do
|
|
147
147
|
readable2, writer = IO.pipe
|
148
148
|
writer << "ohai"
|
149
149
|
|
150
|
-
unreadable
|
150
|
+
unreadable = IO.pipe.first
|
151
151
|
|
152
152
|
monitor1 = subject.register(readable1, :r)
|
153
153
|
monitor2 = subject.register(readable2, :r)
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require "coveralls"
|
2
2
|
Coveralls.wear!
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
4
|
+
require "rubygems"
|
5
|
+
require "bundler/setup"
|
6
|
+
require "nio"
|
7
|
+
require "support/selectable_examples"
|
8
|
+
|
9
|
+
RSpec.configure(&:disable_monkey_patching!)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
shared_context "an NIO selectable" do
|
1
|
+
RSpec.shared_context "an NIO selectable" do
|
2
2
|
let(:selector) { NIO::Selector.new }
|
3
3
|
|
4
4
|
it "selects readable objects" do
|
@@ -26,25 +26,25 @@ shared_context "an NIO selectable" do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
shared_context "an NIO selectable stream" do
|
29
|
+
RSpec.shared_context "an NIO selectable stream" do
|
30
30
|
let(:selector) { NIO::Selector.new }
|
31
31
|
let(:stream) { pair.first }
|
32
32
|
let(:peer) { pair.last }
|
33
33
|
|
34
34
|
it "selects readable when the other end closes" do
|
35
35
|
# hax: this test is broken for OpenSSL sockets
|
36
|
-
skip
|
36
|
+
skip "broken for SSL ;_;" if peer.is_a? OpenSSL::SSL::SSLSocket
|
37
37
|
|
38
38
|
monitor = selector.register(stream, :r)
|
39
39
|
expect(selector.select(0)).to be_nil
|
40
40
|
|
41
41
|
peer.close
|
42
|
-
#Wait and give the TCP session time to close
|
42
|
+
# Wait and give the TCP session time to close
|
43
43
|
expect(selector.select(0.1)).to include monitor
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
shared_context "an NIO bidirectional stream" do
|
47
|
+
RSpec.shared_context "an NIO bidirectional stream" do
|
48
48
|
let(:selector) { NIO::Selector.new }
|
49
49
|
let(:stream) { pair.first }
|
50
50
|
let(:peer) { pair.last }
|
data/tasks/extension.rake
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
if defined? JRUBY_VERSION
|
2
|
-
require
|
3
|
-
Rake::JavaExtensionTask.new(
|
4
|
-
ext.ext_dir =
|
2
|
+
require "rake/javaextensiontask"
|
3
|
+
Rake::JavaExtensionTask.new("nio4r_ext") do |ext|
|
4
|
+
ext.ext_dir = "ext/nio4r"
|
5
5
|
end
|
6
6
|
else
|
7
|
-
require
|
8
|
-
Rake::ExtensionTask.new(
|
9
|
-
ext.ext_dir =
|
7
|
+
require "rake/extensiontask"
|
8
|
+
Rake::ExtensionTask.new("nio4r_ext") do |ext|
|
9
|
+
ext.ext_dir = "ext/nio4r"
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
data/tasks/rspec.rake
CHANGED
data/tasks/rubocop.rake
ADDED
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: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Tony Arcieri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -44,12 +44,26 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.0
|
47
|
+
version: '3.0'
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
50
|
- - ~>
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 3.0
|
52
|
+
version: '3.0'
|
53
|
+
prerelease: false
|
54
|
+
type: :development
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
53
67
|
prerelease: false
|
54
68
|
type: :development
|
55
69
|
description: New IO for Ruby
|
@@ -61,6 +75,8 @@ extra_rdoc_files: []
|
|
61
75
|
files:
|
62
76
|
- .gitignore
|
63
77
|
- .rspec
|
78
|
+
- .rubocop.yml
|
79
|
+
- .rubocop_todo.yml
|
64
80
|
- .travis.yml
|
65
81
|
- CHANGES.md
|
66
82
|
- Gemfile
|
@@ -94,6 +110,7 @@ files:
|
|
94
110
|
- lib/nio/monitor.rb
|
95
111
|
- lib/nio/selector.rb
|
96
112
|
- lib/nio/version.rb
|
113
|
+
- lib/nio4r_ext.jar
|
97
114
|
- logo.png
|
98
115
|
- nio4r.gemspec
|
99
116
|
- spec/nio/acceptables_spec.rb
|
@@ -107,7 +124,7 @@ files:
|
|
107
124
|
- spec/support/selectable_examples.rb
|
108
125
|
- tasks/extension.rake
|
109
126
|
- tasks/rspec.rake
|
110
|
-
-
|
127
|
+
- tasks/rubocop.rake
|
111
128
|
homepage: https://github.com/celluloid/nio4r
|
112
129
|
licenses:
|
113
130
|
- MIT
|
@@ -128,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
145
|
version: '0'
|
129
146
|
requirements: []
|
130
147
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
148
|
+
rubygems_version: 2.4.5
|
132
149
|
signing_key:
|
133
150
|
specification_version: 4
|
134
151
|
summary: NIO provides a high performance selector API for monitoring IO objects
|