async-io 1.18.4 → 1.18.5

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
  SHA256:
3
- metadata.gz: d9b90003500ec4d5f02d1f8ff39fd03ddd75c05988002ed38518e3f41b310e19
4
- data.tar.gz: 6f2963634feaa4adb76146cf69ef981e3d5d184e53afe75026041f9ff0bebe8b
3
+ metadata.gz: 4521c94506778f0d7e6f5dec2fe76bf6b6f0374ae3c327e29775063bd3393aaa
4
+ data.tar.gz: 56d1f0388b1d1a64a87dbb5086bcbd209602933ab805fae44ea6e699cc3eba8b
5
5
  SHA512:
6
- metadata.gz: 476989a61aaf04cbde81d7b470e536670ac1a86e5309355dc2712915ee2977999bb8ae2618f34d5d9ef6679dfcc7f0c7ec4b480b671e7129472d3e66075a57a5
7
- data.tar.gz: 2ad64389173a06b27db796bf61c2310348c8c79b9c09e2146cd5ed63ffd9c3bd2d3d12a058f41c531bcfb5918764a92e91077a28a7ec572c3869b45a65aaf793
6
+ metadata.gz: 7c84cb8f453e9b7c7f80af18443d04eaeca38e46172afbc1ec4f6c219123449a5b8744d72db0c282e2d3da8826f29aa64f331698608a589c9c35a761bc6531f4
7
+ data.tar.gz: 027bf4fc6e910b3e1fdf883f7aa6a98045131f43318a014f77bb6e1734d9e932f95bd54fb23b9237e9ef78bccb1f70fc52c424ece21020e31663ea3a6b151ffe
@@ -49,6 +49,7 @@ module Async
49
49
  Addrinfo.foreach(*@specification) do |address|
50
50
  begin
51
51
  return Socket.connect(address, **@options, &block)
52
+ # This is a little bit risky. In theory, what it is supposed to do is catch the failed connection, and try the next address. In practice, it can catch other kinds of failures. Ideally, it only applies to `#connect`, but it also applies to what's executed in `&block`.
52
53
  rescue
53
54
  last_error = $!
54
55
  end
@@ -92,8 +92,14 @@ module Async
92
92
  super
93
93
  end
94
94
 
95
- def read(size)
96
- @buffer.read_partial(size)
95
+ def read(size, outbuf = nil)
96
+ buffer = @buffer.read_partial(size)
97
+
98
+ if outbuf
99
+ outbuf.replace(buffer)
100
+ end
101
+
102
+ return buffer
97
103
  end
98
104
  end
99
105
 
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module IO
23
- VERSION = "1.18.4"
23
+ VERSION = "1.18.5"
24
24
  end
25
25
  end
@@ -33,10 +33,11 @@ RSpec.describe Async::IO::TCPSocket do
33
33
 
34
34
  describe Async::IO::TCPServer do
35
35
  it_should_behave_like Async::IO::Generic
36
-
37
- it "should start server and send data" do
38
- # Accept a single incoming connection and then finish.
39
- server_task = reactor.async do |task|
36
+ end
37
+
38
+ describe Async::IO::TCPServer do
39
+ let!(:server_task) do
40
+ reactor.async do |task|
40
41
  server = Async::IO::TCPServer.new("localhost", 6788)
41
42
 
42
43
  peer, address = server.accept
@@ -47,9 +48,26 @@ RSpec.describe Async::IO::TCPSocket do
47
48
  peer.close
48
49
  server.close
49
50
  end
51
+ end
52
+
53
+ let(:client) {Async::IO::TCPSocket.new("localhost", 6788)}
54
+
55
+ it "can read into outbuf" do
56
+ client.puts("Hello World")
57
+
58
+ outbuf = String.new
59
+ # 20 is bigger than echo response...
60
+ data = client.read(20, outbuf)
50
61
 
51
- client = Async::IO::TCPSocket.new("localhost", 6788)
62
+ expect(outbuf).to_not be_empty
63
+ expect(outbuf).to be == data
52
64
 
65
+ client.close
66
+ server_task.wait
67
+ end
68
+
69
+ it "should start server and send data" do
70
+ # Accept a single incoming connection and then finish.
53
71
  client.puts(data)
54
72
  expect(client.gets).to be == data
55
73
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-io
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.4
4
+ version: 1.18.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-21 00:00:00.000000000 Z
11
+ date: 2019-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async