kgio 1.2.1 → 1.3.0
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 +1 -1
- data/lib/kgio.rb +7 -7
- data/test/lib_read_write.rb +41 -0
- metadata +5 -5
data/GIT-VERSION-GEN
CHANGED
data/ext/kgio/read_write.c
CHANGED
data/lib/kgio.rb
CHANGED
@@ -6,15 +6,15 @@ module Kgio
|
|
6
6
|
# Rack (and CGI) servers that also serve HTTP traffic over
|
7
7
|
# UNIX domain sockets.
|
8
8
|
LOCALHOST = '127.0.0.1'
|
9
|
-
end
|
10
9
|
|
11
|
-
# Kgio::PipeMethods#kgio_tryread and Kgio::SocketMethods#kgio_tryread will
|
12
|
-
# return this constant when waiting for a read is required.
|
13
|
-
|
10
|
+
# Kgio::PipeMethods#kgio_tryread and Kgio::SocketMethods#kgio_tryread will
|
11
|
+
# return this constant when waiting for a read is required.
|
12
|
+
WaitReadable = :wait_readable
|
14
13
|
|
15
|
-
# PipeMethods#kgio_trywrite and SocketMethods#kgio_trywrite will
|
16
|
-
# return this constant when waiting for a read is required.
|
17
|
-
|
14
|
+
# PipeMethods#kgio_trywrite and SocketMethods#kgio_trywrite will
|
15
|
+
# return this constant when waiting for a read is required.
|
16
|
+
WaitWritable = :wait_writable
|
17
|
+
end
|
18
18
|
|
19
19
|
require 'kgio_ext'
|
20
20
|
|
data/test/lib_read_write.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# -*- encoding: binary -*-
|
1
2
|
require 'test/unit'
|
2
3
|
require 'io/nonblock'
|
4
|
+
require 'digest/sha1'
|
3
5
|
$-w = true
|
4
6
|
require 'kgio'
|
5
7
|
|
@@ -58,6 +60,43 @@ module LibReadWriteTest
|
|
58
60
|
assert false, "should never get here (line:#{__LINE__})"
|
59
61
|
end
|
60
62
|
|
63
|
+
def test_trywrite_full
|
64
|
+
buf = "\302\251" * 1024 * 1024
|
65
|
+
buf2 = ""
|
66
|
+
dig = Digest::SHA1.new
|
67
|
+
t = Thread.new do
|
68
|
+
sleep 1
|
69
|
+
nr = 0
|
70
|
+
begin
|
71
|
+
dig.update(@rd.readpartial(4096, buf2))
|
72
|
+
nr += buf2.size
|
73
|
+
rescue EOFError
|
74
|
+
break
|
75
|
+
rescue => e
|
76
|
+
end while true
|
77
|
+
dig.hexdigest
|
78
|
+
end
|
79
|
+
50.times do
|
80
|
+
wr = buf
|
81
|
+
begin
|
82
|
+
rv = @wr.kgio_trywrite(wr)
|
83
|
+
case rv
|
84
|
+
when String
|
85
|
+
wr = rv
|
86
|
+
when Kgio::WaitReadable
|
87
|
+
assert false, "should never get here line=#{__LINE__}"
|
88
|
+
when Kgio::WaitWritable
|
89
|
+
IO.select(nil, [ @wr ])
|
90
|
+
else
|
91
|
+
wr = false
|
92
|
+
end
|
93
|
+
end while wr
|
94
|
+
end
|
95
|
+
@wr.close
|
96
|
+
t.join
|
97
|
+
assert_equal '8ff79d8115f9fe38d18be858c66aa08a1cc27a66', t.value
|
98
|
+
end
|
99
|
+
|
61
100
|
def test_write_conv
|
62
101
|
assert_equal nil, @wr.kgio_write(10)
|
63
102
|
assert_equal "10", @rd.kgio_read(2)
|
@@ -107,6 +146,8 @@ module LibReadWriteTest
|
|
107
146
|
def test_trywrite_return_wait_writable
|
108
147
|
tmp = []
|
109
148
|
tmp << @wr.kgio_trywrite("HI") until tmp[-1] == Kgio::WaitWritable
|
149
|
+
assert Kgio::WaitWritable === tmp[-1]
|
150
|
+
assert(!(Kgio::WaitReadable === tmp[-1]))
|
110
151
|
assert_equal Kgio::WaitWritable, tmp.pop
|
111
152
|
assert tmp.size > 0
|
112
153
|
penultimate = tmp.pop
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kgio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 1.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- kgio hackers
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-08 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|