kgio 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  GVF=GIT-VERSION-FILE
4
- DEF_VER=v1.2.1.GIT
4
+ DEF_VER=v1.3.0.GIT
5
5
 
6
6
  LF='
7
7
  '
@@ -233,7 +233,7 @@ done:
233
233
  a->ptr = RSTRING_PTR(a->buf) + written;
234
234
  return -1;
235
235
  } else if (written > 0) {
236
- a->buf = rb_str_new(a->ptr + n, a->len - n);
236
+ a->buf = rb_str_new(a->ptr, a->len);
237
237
  } else {
238
238
  a->buf = mKgio_WaitWritable;
239
239
  }
@@ -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
- module Kgio::WaitReadable; end
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
- module Kgio::WaitWritable; end
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
 
@@ -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: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 2
9
- - 1
10
- version: 1.2.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-07 00:00:00 +00:00
18
+ date: 2010-10-08 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies: []
21
21