kgio 2.7.3 → 2.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/GIT-VERSION-GEN +1 -1
- data/ext/kgio/read_write.c +0 -3
- data/test/lib_read_write.rb +14 -13
- data/test/test_accept_class.rb +5 -5
- data/test/test_autopush.rb +9 -13
- data/test/test_connect_fd_leak.rb +4 -6
- data/test/test_poll.rb +1 -3
- data/test/test_singleton_read_write.rb +1 -1
- data/test/test_tcp_connect.rb +1 -0
- data/test/test_tryopen.rb +3 -3
- metadata +26 -40
data/GIT-VERSION-GEN
CHANGED
data/ext/kgio/read_write.c
CHANGED
@@ -20,11 +20,8 @@ static inline void kgio_autopush_write(VALUE io) { }
|
|
20
20
|
|
21
21
|
#else
|
22
22
|
static const int peek_flags = MSG_PEEK;
|
23
|
-
# include <netinet/tcp.h>
|
24
|
-
# if defined(TCP_NOPUSH)
|
25
23
|
static inline void kgio_autopush_read(VALUE io) { kgio_autopush_recv(io); }
|
26
24
|
static inline void kgio_autopush_write(VALUE io) { kgio_autopush_send(io); }
|
27
|
-
# endif
|
28
25
|
#endif
|
29
26
|
|
30
27
|
NORETURN(static void raise_empty_bt(VALUE, const char *));
|
data/test/lib_read_write.rb
CHANGED
@@ -9,10 +9,8 @@ module LibReadWriteTest
|
|
9
9
|
RANDOM_BLOB = File.open("/dev/urandom") { |fp| fp.read(10 * 1024 * 1024) }
|
10
10
|
|
11
11
|
def teardown
|
12
|
-
|
13
|
-
|
14
|
-
@wr.close if defined?(@wr) && ! @wr.closed?
|
15
|
-
end
|
12
|
+
@rd.close if defined?(@rd) && ! @rd.closed?
|
13
|
+
@wr.close if defined?(@wr) && ! @wr.closed?
|
16
14
|
end
|
17
15
|
|
18
16
|
def test_write_empty
|
@@ -59,6 +57,7 @@ module LibReadWriteTest
|
|
59
57
|
a = "." * 0x1000
|
60
58
|
b = a.dup
|
61
59
|
@wr.syswrite("a")
|
60
|
+
IO.select([@rd]) # this seems needed on FreeBSD 9.0
|
62
61
|
assert_equal "a", @rd.kgio_tryread(0x1000, b)
|
63
62
|
assert_equal "a", b
|
64
63
|
assert_equal "." * 0x1000, a
|
@@ -68,6 +67,7 @@ module LibReadWriteTest
|
|
68
67
|
a = "." * 0x1000
|
69
68
|
b = a.dup
|
70
69
|
@wr.syswrite("a")
|
70
|
+
IO.select([@rd]) # this seems needed on FreeBSD 9.0
|
71
71
|
assert_equal "a", @rd.kgio_tryread(0x1000, a)
|
72
72
|
assert_equal "a", a
|
73
73
|
assert_equal "." * 0x1000, b
|
@@ -90,6 +90,7 @@ module LibReadWriteTest
|
|
90
90
|
|
91
91
|
def test_tryread_eof
|
92
92
|
@wr.close
|
93
|
+
IO.select([@rd]) # this seems needed on FreeBSD 9.0
|
93
94
|
assert_nil @rd.kgio_tryread(5)
|
94
95
|
end
|
95
96
|
|
@@ -159,6 +160,7 @@ module LibReadWriteTest
|
|
159
160
|
|
160
161
|
def test_trywrite_conv
|
161
162
|
assert_equal nil, @wr.kgio_trywrite(10)
|
163
|
+
IO.select([@rd]) # this seems needed on FreeBSD 9.0
|
162
164
|
assert_equal "10", @rd.kgio_tryread(2)
|
163
165
|
end
|
164
166
|
|
@@ -184,6 +186,7 @@ module LibReadWriteTest
|
|
184
186
|
|
185
187
|
def test_tryread_short
|
186
188
|
assert_equal nil, @wr.kgio_trywrite("hi")
|
189
|
+
IO.select([@rd]) # this seems needed on FreeBSD 9.0
|
187
190
|
assert_equal "h", @rd.kgio_tryread(1)
|
188
191
|
assert_equal "i", @rd.kgio_tryread(1)
|
189
192
|
end
|
@@ -221,6 +224,7 @@ module LibReadWriteTest
|
|
221
224
|
def test_tryread_extra_buf_eof_clears_buffer
|
222
225
|
tmp = "hello world"
|
223
226
|
@wr.close
|
227
|
+
IO.select([@rd]) # this seems needed on FreeBSD 9.0
|
224
228
|
assert_nil @rd.kgio_tryread(2, tmp)
|
225
229
|
assert_equal "", tmp
|
226
230
|
end
|
@@ -264,10 +268,8 @@ module LibReadWriteTest
|
|
264
268
|
foo = nil
|
265
269
|
t0 = Time.now
|
266
270
|
thr = Thread.new { sleep 1; @wr.write "HELLO" }
|
267
|
-
|
268
|
-
|
269
|
-
elapsed = Time.now - t0
|
270
|
-
end
|
271
|
+
foo = @rd.kgio_read(5)
|
272
|
+
elapsed = Time.now - t0
|
271
273
|
assert elapsed >= 1.0, "elapsed: #{elapsed}"
|
272
274
|
assert_equal "HELLO", foo
|
273
275
|
thr.join
|
@@ -285,11 +287,10 @@ module LibReadWriteTest
|
|
285
287
|
elapsed = 0
|
286
288
|
foo = nil
|
287
289
|
t0 = Time.now
|
288
|
-
thr = Thread.new { sleep 1; @rd.
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
end
|
290
|
+
thr = Thread.new { sleep 1; @rd.read(nr) }
|
291
|
+
foo = @wr.kgio_write("HELLO")
|
292
|
+
elapsed = Time.now - t0
|
293
|
+
|
293
294
|
assert_nil foo
|
294
295
|
if @wr.stat.pipe?
|
295
296
|
assert elapsed >= 1.0, "elapsed: #{elapsed}"
|
data/test/test_accept_class.rb
CHANGED
@@ -12,12 +12,12 @@ class TestAcceptClass < Test::Unit::TestCase
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def teardown
|
15
|
-
|
15
|
+
Kgio.accept_class = nil
|
16
16
|
assert_equal Kgio::Socket, Kgio.accept_class
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_tcp_socket
|
20
|
-
|
20
|
+
Kgio.accept_class = Kgio::TCPSocket
|
21
21
|
assert_equal Kgio::TCPSocket, Kgio.accept_class
|
22
22
|
end
|
23
23
|
|
@@ -31,21 +31,21 @@ class TestAcceptClass < Test::Unit::TestCase
|
|
31
31
|
@srv = Kgio::TCPServer.new(@host, 0)
|
32
32
|
@port = @srv.addr[1]
|
33
33
|
|
34
|
-
|
34
|
+
Kgio.accept_class = Kgio::TCPSocket
|
35
35
|
client = TCPSocket.new(@host, @port)
|
36
36
|
assert_instance_of Kgio::TCPSocket, @srv.kgio_accept
|
37
37
|
client = TCPSocket.new(@host, @port)
|
38
38
|
IO.select([@srv])
|
39
39
|
assert_instance_of Kgio::TCPSocket, @srv.kgio_tryaccept
|
40
40
|
|
41
|
-
|
41
|
+
Kgio.accept_class = nil
|
42
42
|
client = TCPSocket.new(@host, @port)
|
43
43
|
assert_instance_of Kgio::Socket, @srv.kgio_accept
|
44
44
|
client = TCPSocket.new(@host, @port)
|
45
45
|
IO.select([@srv])
|
46
46
|
assert_instance_of Kgio::Socket, @srv.kgio_tryaccept
|
47
47
|
|
48
|
-
|
48
|
+
Kgio.accept_class = Kgio::UNIXSocket
|
49
49
|
client = TCPSocket.new(@host, @port)
|
50
50
|
assert_instance_of Kgio::UNIXSocket, @srv.kgio_accept
|
51
51
|
client = TCPSocket.new(@host, @port)
|
data/test/test_autopush.rb
CHANGED
@@ -18,12 +18,10 @@ class TestAutopush < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
@host = ENV["TEST_HOST"] || '127.0.0.1'
|
20
20
|
@srv = Kgio::TCPServer.new(@host, 0)
|
21
|
-
|
21
|
+
RUBY_PLATFORM =~ /linux/ and
|
22
22
|
@srv.setsockopt(Socket::IPPROTO_TCP, TCP_CORK, 1)
|
23
|
-
|
24
|
-
assert_nothing_raised {
|
23
|
+
RUBY_PLATFORM =~ /freebsd/ and
|
25
24
|
@srv.setsockopt(Socket::IPPROTO_TCP, TCP_NOPUSH, 1)
|
26
|
-
} if RUBY_PLATFORM =~ /freebsd/
|
27
25
|
@port = @srv.addr[1]
|
28
26
|
end
|
29
27
|
|
@@ -35,7 +33,7 @@ class TestAutopush < Test::Unit::TestCase
|
|
35
33
|
assert ! s.kgio_autopush?
|
36
34
|
s.kgio_autopush = true
|
37
35
|
assert s.kgio_autopush?
|
38
|
-
|
36
|
+
s.kgio_write 'asdf'
|
39
37
|
assert_equal :wait_readable, s.kgio_tryread(1)
|
40
38
|
assert s.kgio_autopush?
|
41
39
|
val = s.getsockopt(Socket::IPPROTO_TCP, opt).unpack('i')[0]
|
@@ -64,12 +62,10 @@ class TestAutopush < Test::Unit::TestCase
|
|
64
62
|
lines = io.readlines
|
65
63
|
assert lines.grep(/TCP_CORK/).empty?, lines.inspect
|
66
64
|
else
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
rc = @wr.kgio_tryread 666
|
72
|
-
end
|
65
|
+
@wr = @srv.kgio_accept
|
66
|
+
t0 = Time.now
|
67
|
+
@wr.kgio_write "HI\n"
|
68
|
+
rc = @wr.kgio_tryread 666
|
73
69
|
end
|
74
70
|
assert_equal "HI\n", @rd.kgio_read(3)
|
75
71
|
diff = Time.now - t0
|
@@ -151,8 +147,8 @@ class TestAutopush < Test::Unit::TestCase
|
|
151
147
|
lines = io.readlines
|
152
148
|
assert_equal 2, lines.grep(/TCP_CORK/).size, lines.inspect
|
153
149
|
end
|
154
|
-
|
155
|
-
|
150
|
+
@wr.close
|
151
|
+
@rd.close
|
156
152
|
|
157
153
|
@wr = Kgio::TCPSocket.new(@host, @port)
|
158
154
|
if defined?(Strace)
|
@@ -9,11 +9,9 @@ class TestConnectFDLeak < Test::Unit::TestCase
|
|
9
9
|
nr = 0
|
10
10
|
path = "/non/existent/path"
|
11
11
|
assert(! File.exist?(path), "#{path} should not exist")
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end while (nr += 1) < 10000
|
17
|
-
end
|
12
|
+
begin
|
13
|
+
sock = Kgio::UNIXSocket.new(path)
|
14
|
+
rescue Errno::ENOENT
|
15
|
+
end while (nr += 1) < 10000
|
18
16
|
end
|
19
17
|
end
|
data/test/test_poll.rb
CHANGED
@@ -122,9 +122,7 @@ class TestPoll < Test::Unit::TestCase
|
|
122
122
|
exit!(0)
|
123
123
|
end
|
124
124
|
|
125
|
-
|
126
|
-
empty += 1 until Kgio.poll(set.dup, 100)
|
127
|
-
end
|
125
|
+
empty += 1 until Kgio.poll(set.dup, 100)
|
128
126
|
_, status = Process.waitpid2(pid)
|
129
127
|
assert status.success?, status.inspect
|
130
128
|
assert usr1 > 0, "usr1: #{usr1}"
|
@@ -6,7 +6,7 @@ class TestSingletonReadWrite < Test::Unit::TestCase
|
|
6
6
|
|
7
7
|
def test_unix_socketpair
|
8
8
|
a, b = UNIXSocket.pair
|
9
|
-
|
9
|
+
Kgio.trywrite(a, "HELLO")
|
10
10
|
buf = ""
|
11
11
|
assert_equal "HELLO", Kgio.tryread(b, 5, buf)
|
12
12
|
assert_equal "HELLO", buf
|
data/test/test_tcp_connect.rb
CHANGED
@@ -78,6 +78,7 @@ class TestKgioTcpConnect < Test::Unit::TestCase
|
|
78
78
|
def test_wait_writable_set
|
79
79
|
sock = SubSocket.new(@addr)
|
80
80
|
assert_equal "waited", sock.foo if RUBY_PLATFORM =~ /linux/
|
81
|
+
IO.select(nil, [sock]) if RUBY_PLATFORM !~ /linux/
|
81
82
|
assert_equal nil, sock.kgio_write("HELLO")
|
82
83
|
end
|
83
84
|
end
|
data/test/test_tryopen.rb
CHANGED
@@ -15,7 +15,7 @@ class TestTryopen < Test::Unit::TestCase
|
|
15
15
|
assert_equal File.read(__FILE__), tmp.read
|
16
16
|
assert_equal __FILE__, tmp.path
|
17
17
|
assert_equal __FILE__, tmp.to_path
|
18
|
-
|
18
|
+
tmp.close
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_tryopen_ENOENT
|
@@ -26,11 +26,11 @@ class TestTryopen < Test::Unit::TestCase
|
|
26
26
|
assert_equal :ENOENT, tmp
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def test_tryopen_EACCES
|
30
30
|
tmp = Tempfile.new "tryopen"
|
31
31
|
File.chmod 0000, tmp.path
|
32
32
|
tmp = Kgio::File.tryopen(tmp.path)
|
33
|
-
assert_equal
|
33
|
+
assert_equal(:EACCES, tmp)
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_tryopen_readwrite
|
metadata
CHANGED
@@ -1,34 +1,28 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: kgio
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.7.4
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 7
|
9
|
-
- 3
|
10
|
-
version: 2.7.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- kgio hackers
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2012-03-15 00:00:00 Z
|
12
|
+
date: 2012-03-24 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
14
|
+
description: ! 'kgio provides non-blocking I/O methods for Ruby without raising
|
20
15
|
|
21
|
-
description: |-
|
22
|
-
kgio provides non-blocking I/O methods for Ruby without raising
|
23
16
|
exceptions on EAGAIN and EINPROGRESS. It is intended for use with the
|
17
|
+
|
24
18
|
Unicorn and Rainbows! Rack servers, but may be used by other
|
25
|
-
|
19
|
+
|
20
|
+
applications (that run on Unix-like platforms).'
|
26
21
|
email: kgio@librelist.org
|
27
22
|
executables: []
|
28
|
-
|
29
|
-
extensions:
|
23
|
+
extensions:
|
30
24
|
- ext/kgio/extconf.rb
|
31
|
-
extra_rdoc_files:
|
25
|
+
extra_rdoc_files:
|
32
26
|
- LICENSE
|
33
27
|
- README
|
34
28
|
- TODO
|
@@ -46,7 +40,7 @@ extra_rdoc_files:
|
|
46
40
|
- ext/kgio/read_write.c
|
47
41
|
- ext/kgio/wait.c
|
48
42
|
- ext/kgio/tryopen.c
|
49
|
-
files:
|
43
|
+
files:
|
50
44
|
- .document
|
51
45
|
- .gitignore
|
52
46
|
- .manifest
|
@@ -114,41 +108,33 @@ files:
|
|
114
108
|
- test/test_unix_server_read_client_write.rb
|
115
109
|
homepage: http://bogomips.org/kgio/
|
116
110
|
licenses: []
|
117
|
-
|
118
111
|
post_install_message:
|
119
|
-
rdoc_options:
|
112
|
+
rdoc_options:
|
120
113
|
- -t
|
121
114
|
- kgio - kinder, gentler I/O for Ruby
|
122
115
|
- -W
|
123
116
|
- http://bogomips.org/kgio.git/tree/%s
|
124
|
-
require_paths:
|
117
|
+
require_paths:
|
125
118
|
- lib
|
126
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
120
|
none: false
|
128
|
-
requirements:
|
129
|
-
- -
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
|
132
|
-
|
133
|
-
- 0
|
134
|
-
version: "0"
|
135
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
126
|
none: false
|
137
|
-
requirements:
|
138
|
-
- -
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
|
141
|
-
segments:
|
142
|
-
- 0
|
143
|
-
version: "0"
|
127
|
+
requirements:
|
128
|
+
- - ! '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
144
131
|
requirements: []
|
145
|
-
|
146
132
|
rubyforge_project: rainbows
|
147
|
-
rubygems_version: 1.8.
|
133
|
+
rubygems_version: 1.8.21
|
148
134
|
signing_key:
|
149
135
|
specification_version: 3
|
150
136
|
summary: kinder, gentler I/O for Ruby
|
151
|
-
test_files:
|
137
|
+
test_files:
|
152
138
|
- test/test_poll.rb
|
153
139
|
- test/test_peek.rb
|
154
140
|
- test/test_default_wait.rb
|