libuv 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +1 -2
- data/Rakefile +2 -2
- data/lib/libuv/ext/ext.rb +26 -4
- data/lib/libuv/ext/tasks/mac.rb +11 -2
- data/lib/libuv/ext/tasks/unix.rb +7 -2
- data/lib/libuv/ext/tasks/win.rb +3 -2
- data/lib/libuv/mixins/assertions.rb +1 -1
- data/lib/libuv/mixins/stream.rb +1 -0
- data/lib/libuv/pipe.rb +25 -23
- data/lib/libuv/q.rb +1 -1
- data/lib/libuv/tcp.rb +23 -21
- data/lib/libuv/version.rb +1 -1
- data/spec/filesystem_spec.rb +62 -40
- data/spec/pipe_spec.rb +5 -7
- data/spec/tcp_spec.rb +28 -36
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2411dd2877c9256b66f5efc5d875d967f8a64cf
|
4
|
+
data.tar.gz: 0d255d823975c43add1a2a660bee42cb973fbbff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9afbe0baf2d31528086aa9122badfbc1fb0e13e91cb08d61a7c889ef47e18efca8959ede4d792a35869f3dca526332a97fb70828f4d7f556df0e6019a2a6bd8
|
7
|
+
data.tar.gz: 59bf41d7c9badb7b4ed3b88c6ea30cb0e2c2d7e1c5a54ef373da9019f07d5b42564e1077efbd3a20d376bd5b2506f6bf96a3df9d94c8c6f648e611bfa2dd4944
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/cotag/libuv.svg?branch=master)](https://travis-ci.org/cotag/libuv)
|
4
4
|
|
5
|
-
[Libuv](https://github.com/
|
5
|
+
[Libuv](https://github.com/libuv/libuv) is a cross platform asynchronous IO implementation that powers NodeJS. It supports sockets, both UDP and TCP, filesystem watch, TTY, Pipes and other asynchronous primitives like timer, check, prepare and idle.
|
6
6
|
|
7
7
|
The Libuv gem contains Libuv and a Ruby wrapper that implements [pipelined promises](http://en.wikipedia.org/wiki/Futures_and_promises#Promise_pipelining) for asynchronous flow control and [coroutines](http://en.wikipedia.org/wiki/Coroutine) for untangling evented code
|
8
8
|
|
@@ -77,7 +77,6 @@ or
|
|
77
77
|
|
78
78
|
### Prerequisites
|
79
79
|
|
80
|
-
* The installation requires [subversion](http://subversion.apache.org/packages.html) to be installed on your system and available on the PATH
|
81
80
|
* The installation also requires [python 2.x](http://www.python.org/getit/) to be installed and available on the PATH
|
82
81
|
* setting the environmental variable `USE_GLOBAL_LIBUV` will prevent compiling the packaged version.
|
83
82
|
* if you have a compatible `libuv.(so | dylib | dll)` on the PATH already
|
data/Rakefile
CHANGED
@@ -26,6 +26,6 @@ end
|
|
26
26
|
|
27
27
|
|
28
28
|
desc "Compile libuv from submodule"
|
29
|
-
task :compile => ["ext/libuv.#{FFI::Platform::LIBSUFFIX}"]
|
29
|
+
task :compile => ["ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}"]
|
30
30
|
|
31
|
-
CLOBBER.include("ext/libuv.#{FFI::Platform::LIBSUFFIX}")
|
31
|
+
CLOBBER.include("ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}")
|
data/lib/libuv/ext/ext.rb
CHANGED
@@ -23,10 +23,27 @@ module Libuv
|
|
23
23
|
begin
|
24
24
|
# bias the library discovery to a path inside the gem first, then
|
25
25
|
# to the usual system paths
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
|
27
|
+
path_to_internal_libuv = ::File.dirname(__FILE__) + '/../../../ext/libuv/lib'
|
28
|
+
|
29
|
+
paths = [
|
30
|
+
path_to_internal_libuv,
|
31
|
+
'/usr/local/lib',
|
32
|
+
'/opt/local/lib',
|
33
|
+
'/usr/lib64'
|
34
|
+
]
|
35
|
+
|
36
|
+
if FFI::Platform.mac?
|
37
|
+
# Using home/user/lib is the best we can do on OSX
|
38
|
+
# Primarily a dev platform so that is OK
|
39
|
+
paths.unshift "#{ENV['HOME']}/lib"
|
40
|
+
elsif FFI::Platform.windows?
|
41
|
+
# TODO:: AddDllDirectory function to point to path_to_internal_libuv
|
42
|
+
else # UNIX
|
43
|
+
# TODO:: ??
|
44
|
+
end
|
45
|
+
|
46
|
+
LIBUV_PATHS = paths.map{|path| "#{path}/libuv.#{FFI::Platform::LIBSUFFIX}"}
|
30
47
|
libuv = ffi_lib(LIBUV_PATHS + %w{libuv}).first
|
31
48
|
rescue LoadError
|
32
49
|
warn <<-WARNING
|
@@ -39,6 +56,11 @@ module Libuv
|
|
39
56
|
end
|
40
57
|
|
41
58
|
|
59
|
+
def self.path_to_internal_libuv
|
60
|
+
@path_to_internal_libuv ||= ::File.expand_path("../../../../ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}", __FILE__)
|
61
|
+
end
|
62
|
+
|
63
|
+
|
42
64
|
require 'libuv/ext/types'
|
43
65
|
|
44
66
|
|
data/lib/libuv/ext/tasks/mac.rb
CHANGED
@@ -15,8 +15,17 @@ file "ext/libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}" => 'ext/libuv/u
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
file "ext/libuv.#{FFI::Platform::LIBSUFFIX}" => "ext/libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}" do
|
19
|
-
|
18
|
+
file "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}" => "ext/libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}" do
|
19
|
+
FileUtils.mkdir('ext/libuv/lib') unless File.directory?('ext/libuv/lib')
|
20
|
+
|
21
|
+
user_lib = "#{ENV['HOME']}/lib"
|
22
|
+
FileUtils.mkdir(user_lib) unless File.directory?(user_lib)
|
23
|
+
|
24
|
+
# Useful for building other libraries that wish to use Libuv
|
25
|
+
FileUtils.cp("ext/libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}", "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}")
|
26
|
+
|
27
|
+
# Primrary load location - falls back to above if not available
|
28
|
+
FileUtils.cp("ext/libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}", "#{user_lib}/libuv.#{FFI::Platform::LIBSUFFIX}")
|
20
29
|
end
|
21
30
|
|
22
31
|
CLEAN.include('ext/libuv/uv.xcodeproj')
|
data/lib/libuv/ext/tasks/unix.rb
CHANGED
@@ -15,8 +15,13 @@ file "ext/libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}" => 'ex
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
file "ext/libuv.#{FFI::Platform::LIBSUFFIX}" => "ext/libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}" do
|
19
|
-
|
18
|
+
file "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}" => "ext/libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}" do
|
19
|
+
FileUtils.mkdir('ext/libuv/lib') unless File.directory?('ext/libuv/lib')
|
20
|
+
begin
|
21
|
+
FileUtils.cp("ext/libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}", "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}")
|
22
|
+
rescue => e
|
23
|
+
FileUtils.cp("ext/libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}.1", "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}")
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
22
27
|
CLEAN.include('ext/libuv/out')
|
data/lib/libuv/ext/tasks/win.rb
CHANGED
@@ -8,8 +8,9 @@ file "ext/libuv/Release/libuv.#{FFI::Platform::LIBSUFFIX}" do
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
file "ext/libuv.#{FFI::Platform::LIBSUFFIX}" => "ext/libuv/Release/libuv.#{FFI::Platform::LIBSUFFIX}" do
|
12
|
-
FileUtils.
|
11
|
+
file "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}" => "ext/libuv/Release/libuv.#{FFI::Platform::LIBSUFFIX}" do
|
12
|
+
FileUtils.mkdir('ext/libuv/lib') unless File.directory?('ext/libuv/lib')
|
13
|
+
FileUtils.cp("ext/libuv/Release/libuv.#{FFI::Platform::LIBSUFFIX}", "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}")
|
13
14
|
end
|
14
15
|
|
15
16
|
CLOBBER.include("ext/libuv/Release/libuv.#{FFI::Platform::LIBSUFFIX}")
|
data/lib/libuv/mixins/stream.rb
CHANGED
data/lib/libuv/pipe.rb
CHANGED
@@ -22,7 +22,9 @@ module Libuv
|
|
22
22
|
|
23
23
|
def bind(name, callback = nil, &blk)
|
24
24
|
return if @closed
|
25
|
-
@
|
25
|
+
@on_accept = callback || blk
|
26
|
+
@on_listen = method(:accept)
|
27
|
+
|
26
28
|
assert_type(String, name, "name must be a String")
|
27
29
|
name = windows_path name if FFI::Platform.windows?
|
28
30
|
|
@@ -30,34 +32,17 @@ module Libuv
|
|
30
32
|
reject(error) if error
|
31
33
|
end
|
32
34
|
|
33
|
-
def accept(callback = nil, &blk)
|
34
|
-
pipe = nil
|
35
|
-
begin
|
36
|
-
raise RuntimeError, CLOSED_HANDLE_ERROR if @closed
|
37
|
-
pipe = Pipe.new(loop, @ipc, handle)
|
38
|
-
rescue Exception => e
|
39
|
-
@loop.log :info, :pipe_accept_failed, e
|
40
|
-
end
|
41
|
-
if pipe
|
42
|
-
begin
|
43
|
-
(callback || blk).call(pipe)
|
44
|
-
rescue Exception => e
|
45
|
-
@loop.log :error, :pipe_accept_cb, e
|
46
|
-
end
|
47
|
-
end
|
48
|
-
nil
|
49
|
-
end
|
50
|
-
|
51
35
|
def open(fileno, callback = nil, &blk)
|
52
36
|
@callback = callback || blk
|
53
|
-
assert_type(Integer, fileno,
|
37
|
+
assert_type(Integer, fileno, 'fileno must be an integer file descriptor'.freeze)
|
38
|
+
|
54
39
|
begin
|
55
40
|
raise RuntimeError, CLOSED_HANDLE_ERROR if @closed
|
56
41
|
check_result! ::Libuv::Ext.pipe_open(handle, fileno)
|
57
42
|
|
58
43
|
# Emulate on_connect behavior
|
59
44
|
begin
|
60
|
-
@callback.call(self)
|
45
|
+
@callback.call(self) if @callback
|
61
46
|
rescue Exception => e
|
62
47
|
@loop.log :error, :pipe_connect_cb, e
|
63
48
|
end
|
@@ -121,8 +106,8 @@ module Libuv
|
|
121
106
|
def check_pending(expecting = nil)
|
122
107
|
return nil if ::Libuv::Ext.pipe_pending_count(handle) <= 0
|
123
108
|
|
124
|
-
pending = ::Libuv::Ext.pipe_pending_type(handle)
|
125
|
-
raise TypeError, "IPC expecting #{expecting} and received #{pending}" if expecting && expecting != pending
|
109
|
+
pending = ::Libuv::Ext.pipe_pending_type(handle).to_sym
|
110
|
+
raise TypeError, "IPC expecting #{expecting} and received #{pending}" if expecting && expecting.to_sym != pending
|
126
111
|
|
127
112
|
# Hide the accept logic
|
128
113
|
remote = nil
|
@@ -148,7 +133,24 @@ module Libuv
|
|
148
133
|
|
149
134
|
|
150
135
|
private
|
136
|
+
|
151
137
|
|
138
|
+
def accept(_)
|
139
|
+
pipe = nil
|
140
|
+
begin
|
141
|
+
raise RuntimeError, CLOSED_HANDLE_ERROR if @closed
|
142
|
+
pipe = Pipe.new(loop, @ipc, handle)
|
143
|
+
rescue Exception => e
|
144
|
+
@loop.log :info, :pipe_accept_failed, e
|
145
|
+
end
|
146
|
+
if pipe
|
147
|
+
begin
|
148
|
+
@on_accept.call(pipe)
|
149
|
+
rescue Exception => e
|
150
|
+
@loop.log :error, :pipe_accept_cb, e
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
152
154
|
|
153
155
|
def on_connect(req, status)
|
154
156
|
cleanup_callbacks req.address
|
data/lib/libuv/q.rb
CHANGED
@@ -425,7 +425,7 @@ module Libuv
|
|
425
425
|
promises.each_index do |index|
|
426
426
|
ref(loop, promises[index]).then(proc {|result|
|
427
427
|
if results[index].nil?
|
428
|
-
results[index] = [result,
|
428
|
+
results[index] = [result, true]
|
429
429
|
counter -= 1
|
430
430
|
deferred.resolve(results) if counter <= 0
|
431
431
|
end
|
data/lib/libuv/tcp.rb
CHANGED
@@ -152,12 +152,10 @@ module Libuv
|
|
152
152
|
|
153
153
|
alias_method :direct_write, :write
|
154
154
|
def write(data)
|
155
|
-
if @tls
|
156
|
-
direct_write(data)
|
157
|
-
else
|
155
|
+
if @tls
|
158
156
|
deferred = @loop.defer
|
159
157
|
|
160
|
-
if @handshake
|
158
|
+
if @handshake
|
161
159
|
@pending_write = deferred
|
162
160
|
@tls.encrypt(data)
|
163
161
|
else
|
@@ -165,6 +163,8 @@ module Libuv
|
|
165
163
|
end
|
166
164
|
|
167
165
|
deferred.promise
|
166
|
+
else
|
167
|
+
direct_write(data)
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
@@ -183,7 +183,9 @@ module Libuv
|
|
183
183
|
|
184
184
|
def bind(ip, port, callback = nil, &blk)
|
185
185
|
return if @closed
|
186
|
-
@
|
186
|
+
@on_accept = callback || blk
|
187
|
+
@on_listen = method(:accept)
|
188
|
+
|
187
189
|
assert_type(String, ip, IP_ARGUMENT_ERROR)
|
188
190
|
assert_type(Integer, port, PORT_ARGUMENT_ERROR)
|
189
191
|
|
@@ -198,7 +200,8 @@ module Libuv
|
|
198
200
|
def open(fd, binding = true, callback = nil, &blk)
|
199
201
|
return if @closed
|
200
202
|
if binding
|
201
|
-
@on_listen =
|
203
|
+
@on_listen = method(:accept)
|
204
|
+
@on_accept = callback || blk
|
202
205
|
else
|
203
206
|
@callback = callback || blk
|
204
207
|
end
|
@@ -206,21 +209,6 @@ module Libuv
|
|
206
209
|
reject(error) if error
|
207
210
|
end
|
208
211
|
|
209
|
-
def accept(callback = nil, &blk)
|
210
|
-
begin
|
211
|
-
raise RuntimeError, CLOSED_HANDLE_ERROR if @closed
|
212
|
-
tcp = TCP.new(loop, handle)
|
213
|
-
begin
|
214
|
-
(callback || blk).call(tcp)
|
215
|
-
rescue Exception => e
|
216
|
-
@loop.log :error, :tcp_accept_cb, e
|
217
|
-
end
|
218
|
-
rescue Exception => e
|
219
|
-
@loop.log :info, :tcp_accept_failed, e
|
220
|
-
end
|
221
|
-
nil
|
222
|
-
end
|
223
|
-
|
224
212
|
def connect(ip, port, callback = nil, &blk)
|
225
213
|
return if @closed
|
226
214
|
@callback = callback || blk
|
@@ -309,6 +297,20 @@ module Libuv
|
|
309
297
|
end
|
310
298
|
end
|
311
299
|
|
300
|
+
def accept(_)
|
301
|
+
begin
|
302
|
+
raise RuntimeError, CLOSED_HANDLE_ERROR if @closed
|
303
|
+
tcp = TCP.new(loop, handle)
|
304
|
+
begin
|
305
|
+
@on_accept.call(tcp)
|
306
|
+
rescue Exception => e
|
307
|
+
@loop.log :error, :tcp_accept_cb, e
|
308
|
+
end
|
309
|
+
rescue Exception => e
|
310
|
+
@loop.log :info, :tcp_accept_failed, e
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
312
314
|
|
313
315
|
class SocketBase
|
314
316
|
include Resource
|
data/lib/libuv/version.rb
CHANGED
data/spec/filesystem_spec.rb
CHANGED
@@ -82,6 +82,32 @@ describe Libuv::Filesystem do
|
|
82
82
|
expect(@log).to eq(:success)
|
83
83
|
end
|
84
84
|
|
85
|
+
it "should return stats on the file" do
|
86
|
+
@loop.run { |logger|
|
87
|
+
logger.progress &@logger
|
88
|
+
|
89
|
+
file = @loop.file(@thefile, File::RDONLY)
|
90
|
+
file.progress do
|
91
|
+
file.stat.then do |stats|
|
92
|
+
file.close
|
93
|
+
@timeout.close
|
94
|
+
@loop.stop
|
95
|
+
@log << stats[:st_mtim][:tv_sec]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
file.catch do |error|
|
99
|
+
@general_failure << error
|
100
|
+
@timeout.close
|
101
|
+
file.close
|
102
|
+
@loop.stop
|
103
|
+
end
|
104
|
+
}
|
105
|
+
|
106
|
+
expect(@general_failure).to eq([])
|
107
|
+
expect(@log[0]).to be_kind_of(Integer)
|
108
|
+
expect(@log.length).to eql(1)
|
109
|
+
end
|
110
|
+
|
85
111
|
it "should read from a file" do
|
86
112
|
@loop.run { |logger|
|
87
113
|
logger.progress &@logger
|
@@ -137,31 +163,29 @@ describe Libuv::Filesystem do
|
|
137
163
|
@server = @loop.tcp
|
138
164
|
@client = @loop.tcp
|
139
165
|
|
140
|
-
@server.bind('127.0.0.1', 34570) do |
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
file.
|
145
|
-
file.send_file(client).then(proc {
|
146
|
-
file.close
|
147
|
-
client.close
|
148
|
-
}, proc { |error|
|
149
|
-
@general_failure << error
|
150
|
-
})
|
151
|
-
end
|
152
|
-
file.catch do |error|
|
153
|
-
@general_failure << error.inspect
|
166
|
+
@server.bind('127.0.0.1', 34570) do |client|
|
167
|
+
client.progress do |data|
|
168
|
+
file = @loop.file('.rspec', File::RDONLY)
|
169
|
+
file.progress do
|
170
|
+
file.send_file(client).then(proc {
|
154
171
|
file.close
|
155
172
|
client.close
|
156
|
-
|
173
|
+
}, proc { |error|
|
174
|
+
@general_failure << error
|
175
|
+
})
|
157
176
|
end
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
@loop.stop
|
177
|
+
file.catch do |error|
|
178
|
+
@general_failure << error.inspect
|
179
|
+
file.close
|
180
|
+
client.close
|
163
181
|
end
|
164
182
|
end
|
183
|
+
client.start_read
|
184
|
+
client.finally do
|
185
|
+
@timeout.close
|
186
|
+
@server.close
|
187
|
+
@loop.stop
|
188
|
+
end
|
165
189
|
end
|
166
190
|
# catch errors
|
167
191
|
@server.catch do |reason|
|
@@ -205,31 +229,29 @@ describe Libuv::Filesystem do
|
|
205
229
|
@server = @loop.tcp
|
206
230
|
@client = @loop.tcp
|
207
231
|
|
208
|
-
@server.bind('127.0.0.1', 34568) do |
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
file.
|
213
|
-
file.send_file(client, :http).then(proc {
|
214
|
-
file.close
|
215
|
-
client.close
|
216
|
-
}, proc { |error|
|
217
|
-
@general_failure << error
|
218
|
-
})
|
219
|
-
end
|
220
|
-
file.catch do |error|
|
221
|
-
@general_failure << error.inspect
|
232
|
+
@server.bind('127.0.0.1', 34568) do |client|
|
233
|
+
client.progress do |data|
|
234
|
+
file = @loop.file('.rspec', File::RDONLY)
|
235
|
+
file.progress do
|
236
|
+
file.send_file(client, :http).then(proc {
|
222
237
|
file.close
|
223
238
|
client.close
|
224
|
-
|
239
|
+
}, proc { |error|
|
240
|
+
@general_failure << error
|
241
|
+
})
|
225
242
|
end
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
@loop.stop
|
243
|
+
file.catch do |error|
|
244
|
+
@general_failure << error.inspect
|
245
|
+
file.close
|
246
|
+
client.close
|
231
247
|
end
|
232
248
|
end
|
249
|
+
client.start_read
|
250
|
+
client.finally do
|
251
|
+
@timeout.close
|
252
|
+
@server.close
|
253
|
+
@loop.stop
|
254
|
+
end
|
233
255
|
end
|
234
256
|
# catch errors
|
235
257
|
@server.catch do |reason|
|
data/spec/pipe_spec.rb
CHANGED
@@ -47,14 +47,12 @@ describe Libuv::Pipe do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
@server.bind(@pipefile) do |
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
client.write('pong')
|
55
|
-
end
|
56
|
-
client.start_read
|
50
|
+
@server.bind(@pipefile) do |client|
|
51
|
+
client.progress do |data|
|
52
|
+
@log << data
|
53
|
+
client.write('pong')
|
57
54
|
end
|
55
|
+
client.start_read
|
58
56
|
end
|
59
57
|
|
60
58
|
# catch server errors
|
data/spec/tcp_spec.rb
CHANGED
@@ -42,15 +42,13 @@ describe Libuv::TCP do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
|
45
|
-
@server.bind('127.0.0.1', 34567) do |
|
46
|
-
|
47
|
-
|
48
|
-
@log << data
|
45
|
+
@server.bind('127.0.0.1', 34567) do |client|
|
46
|
+
client.progress do |data|
|
47
|
+
@log << data
|
49
48
|
|
50
|
-
|
51
|
-
end
|
52
|
-
client.start_read
|
49
|
+
client.write('pong')
|
53
50
|
end
|
51
|
+
client.start_read
|
54
52
|
end
|
55
53
|
|
56
54
|
# catch errors
|
@@ -106,10 +104,8 @@ describe Libuv::TCP do
|
|
106
104
|
|
107
105
|
|
108
106
|
@remote = nil
|
109
|
-
@server.bind('127.0.0.1', 45678) do |
|
110
|
-
|
111
|
-
@remote.write2(client)
|
112
|
-
end
|
107
|
+
@server.bind('127.0.0.1', 45678) do |client|
|
108
|
+
@remote.write2(client)
|
113
109
|
end
|
114
110
|
|
115
111
|
# catch errors
|
@@ -119,25 +115,23 @@ describe Libuv::TCP do
|
|
119
115
|
|
120
116
|
|
121
117
|
@pipeserve = @loop.pipe(true)
|
122
|
-
@pipeserve.bind(@pipefile) do |
|
123
|
-
|
124
|
-
@remote = client
|
125
|
-
|
126
|
-
# start listening on TCP server
|
127
|
-
@server.listen(1024)
|
118
|
+
@pipeserve.bind(@pipefile) do |client|
|
119
|
+
@remote = client
|
128
120
|
|
129
|
-
|
130
|
-
|
131
|
-
client.progress do |data|
|
132
|
-
@sync.synchronize {
|
133
|
-
@log << data
|
134
|
-
}
|
135
|
-
@client.shutdown
|
136
|
-
end
|
121
|
+
# start listening on TCP server
|
122
|
+
@server.listen(1024)
|
137
123
|
|
138
|
-
|
139
|
-
|
124
|
+
# connect client to server
|
125
|
+
@client.connect('127.0.0.1', 45678) do |client|
|
126
|
+
client.progress do |data|
|
127
|
+
@sync.synchronize {
|
128
|
+
@log << data
|
129
|
+
}
|
130
|
+
@client.shutdown
|
140
131
|
end
|
132
|
+
|
133
|
+
@client.start_read
|
134
|
+
@client.write('ping')
|
141
135
|
end
|
142
136
|
|
143
137
|
@pipeserve.getsockname
|
@@ -216,16 +210,14 @@ describe Libuv::TCP do
|
|
216
210
|
end
|
217
211
|
|
218
212
|
|
219
|
-
@server.bind('127.0.0.1',
|
220
|
-
server
|
221
|
-
|
222
|
-
|
223
|
-
@log << data
|
213
|
+
@server.bind('127.0.0.1', 56789) do |client|
|
214
|
+
client.start_tls(server: true)
|
215
|
+
client.progress do |data|
|
216
|
+
@log << data
|
224
217
|
|
225
|
-
|
226
|
-
end
|
227
|
-
client.start_read
|
218
|
+
client.write('pong')
|
228
219
|
end
|
220
|
+
client.start_read
|
229
221
|
end
|
230
222
|
|
231
223
|
# catch errors
|
@@ -239,7 +231,7 @@ describe Libuv::TCP do
|
|
239
231
|
|
240
232
|
|
241
233
|
# connect client to server
|
242
|
-
@client.connect('127.0.0.1',
|
234
|
+
@client.connect('127.0.0.1', 56789) do |client|
|
243
235
|
client.start_tls
|
244
236
|
client.progress do |data|
|
245
237
|
@log << data
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libuv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bulat Shakirzyanov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-08-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
@@ -120,10 +120,12 @@ files:
|
|
120
120
|
- ext/libuv/CONTRIBUTING.md
|
121
121
|
- ext/libuv/ChangeLog
|
122
122
|
- ext/libuv/LICENSE
|
123
|
+
- ext/libuv/MAINTAINERS.md
|
123
124
|
- ext/libuv/Makefile.am
|
124
125
|
- ext/libuv/Makefile.mingw
|
125
126
|
- ext/libuv/README.md
|
126
127
|
- ext/libuv/android-configure
|
128
|
+
- ext/libuv/appveyor.yml
|
127
129
|
- ext/libuv/autogen.sh
|
128
130
|
- ext/libuv/checksparse.sh
|
129
131
|
- ext/libuv/common.gypi
|
@@ -173,6 +175,7 @@ files:
|
|
173
175
|
- ext/libuv/docs/src/timer.rst
|
174
176
|
- ext/libuv/docs/src/tty.rst
|
175
177
|
- ext/libuv/docs/src/udp.rst
|
178
|
+
- ext/libuv/docs/src/version.rst
|
176
179
|
- ext/libuv/gyp_uv.py
|
177
180
|
- ext/libuv/img/banner.png
|
178
181
|
- ext/libuv/img/logos.svg
|
@@ -191,6 +194,7 @@ files:
|
|
191
194
|
- ext/libuv/include/uv-version.h
|
192
195
|
- ext/libuv/include/uv-win.h
|
193
196
|
- ext/libuv/include/uv.h
|
197
|
+
- ext/libuv/libuv.nsi
|
194
198
|
- ext/libuv/libuv.pc.in
|
195
199
|
- ext/libuv/m4/.gitignore
|
196
200
|
- ext/libuv/m4/as_case.m4
|
@@ -344,6 +348,7 @@ files:
|
|
344
348
|
- ext/libuv/test/test-getnameinfo.c
|
345
349
|
- ext/libuv/test/test-getsockname.c
|
346
350
|
- ext/libuv/test/test-handle-fileno.c
|
351
|
+
- ext/libuv/test/test-homedir.c
|
347
352
|
- ext/libuv/test/test-hrtime.c
|
348
353
|
- ext/libuv/test/test-idle.c
|
349
354
|
- ext/libuv/test/test-ip4-addr.c
|
@@ -365,6 +370,7 @@ files:
|
|
365
370
|
- ext/libuv/test/test-pipe-bind-error.c
|
366
371
|
- ext/libuv/test/test-pipe-close-stdout-read-stdin.c
|
367
372
|
- ext/libuv/test/test-pipe-connect-error.c
|
373
|
+
- ext/libuv/test/test-pipe-connect-prepare.c
|
368
374
|
- ext/libuv/test/test-pipe-getsockname.c
|
369
375
|
- ext/libuv/test/test-pipe-sendmsg.c
|
370
376
|
- ext/libuv/test/test-pipe-server-close.c
|
@@ -396,6 +402,7 @@ files:
|
|
396
402
|
- ext/libuv/test/test-tcp-connect-error.c
|
397
403
|
- ext/libuv/test/test-tcp-connect-timeout.c
|
398
404
|
- ext/libuv/test/test-tcp-connect6-error.c
|
405
|
+
- ext/libuv/test/test-tcp-create-socket-early.c
|
399
406
|
- ext/libuv/test/test-tcp-flags.c
|
400
407
|
- ext/libuv/test/test-tcp-oob.c
|
401
408
|
- ext/libuv/test/test-tcp-open.c
|
@@ -404,6 +411,7 @@ files:
|
|
404
411
|
- ext/libuv/test/test-tcp-try-write.c
|
405
412
|
- ext/libuv/test/test-tcp-unexpected-read.c
|
406
413
|
- ext/libuv/test/test-tcp-write-after-connect.c
|
414
|
+
- ext/libuv/test/test-tcp-write-fail.c
|
407
415
|
- ext/libuv/test/test-tcp-write-queue-order.c
|
408
416
|
- ext/libuv/test/test-tcp-write-to-half-open-connection.c
|
409
417
|
- ext/libuv/test/test-tcp-writealot.c
|
@@ -416,6 +424,7 @@ files:
|
|
416
424
|
- ext/libuv/test/test-timer.c
|
417
425
|
- ext/libuv/test/test-tty.c
|
418
426
|
- ext/libuv/test/test-udp-bind.c
|
427
|
+
- ext/libuv/test/test-udp-create-socket-early.c
|
419
428
|
- ext/libuv/test/test-udp-dgram-too-big.c
|
420
429
|
- ext/libuv/test/test-udp-ipv6.c
|
421
430
|
- ext/libuv/test/test-udp-multicast-interface.c
|