uv-rays 2.4.6 → 2.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/uv-rays/http_endpoint.rb +36 -10
- data/lib/uv-rays/version.rb +1 -1
- metadata +3 -5
- data/spec/zen_spec.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 47a75f7ad78665269e270dc125d92b9c72c57375a3c6cb2c706d8c03b2b80748
|
4
|
+
data.tar.gz: df2eef272ef2b7778eb24440f6b1526881eb361fd4f0118ae63995c0d0c54ad7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de3157500008ced5a6a5e2a980033acadb4243a9aa78243947e0227024df65123e0abbb6fef36d9c30fadb397cc609207dc511a61b12f17c142fb327c6be798c
|
7
|
+
data.tar.gz: 432b658361131fa76d68e445ad91a84aef4db530d428874b9a2ba326a6e85ba14db59562b8b1464438049a4f6a19865a562a766a918114595bf484a47233f8ec
|
@@ -163,6 +163,9 @@ module UV
|
|
163
163
|
@tls = @scheme == 'https'
|
164
164
|
@cookiejar = CookieJar.new
|
165
165
|
@middleware = []
|
166
|
+
|
167
|
+
@closing = false
|
168
|
+
@connecting = false
|
166
169
|
end
|
167
170
|
|
168
171
|
|
@@ -190,15 +193,18 @@ module UV
|
|
190
193
|
if response.keep_alive
|
191
194
|
restart_timer
|
192
195
|
else
|
193
|
-
|
196
|
+
# We might have already started processing the next request
|
197
|
+
# at this point. So don't want to disconnect if already
|
198
|
+
# disconnected.
|
199
|
+
close_connection unless @connecting
|
194
200
|
end
|
195
201
|
|
196
202
|
next_request
|
197
203
|
|
198
204
|
response
|
199
205
|
}, proc { |err|
|
200
|
-
@parser.eof
|
201
|
-
close_connection
|
206
|
+
# @parser.eof
|
207
|
+
close_connection unless @connecting
|
202
208
|
next_request
|
203
209
|
::Libuv::Q.reject(@thread, err)
|
204
210
|
})
|
@@ -211,6 +217,10 @@ module UV
|
|
211
217
|
|
212
218
|
# Callbacks
|
213
219
|
def connection_ready
|
220
|
+
# A connection can be closed while still connecting
|
221
|
+
return if @closing
|
222
|
+
|
223
|
+
@connecting = false
|
214
224
|
if @queue.length > 0
|
215
225
|
restart_timer
|
216
226
|
next_request
|
@@ -220,16 +230,23 @@ module UV
|
|
220
230
|
end
|
221
231
|
|
222
232
|
def connection_closed(request, reason)
|
233
|
+
# A connection might close due to a connection failure
|
234
|
+
awaiting_close = @closing
|
235
|
+
awaiting_connect = @connecting
|
236
|
+
@closing = false
|
237
|
+
@connecting = false
|
238
|
+
@connection = nil
|
239
|
+
|
223
240
|
# We may have closed a previous connection
|
224
241
|
if @parser.request && (request.nil? || request == @parser.request)
|
225
|
-
@connection = nil
|
226
242
|
stop_timer
|
227
|
-
|
228
243
|
@parser.eof
|
229
244
|
elsif request.nil? && @parser.request.nil? && @queue.length > 0
|
230
245
|
req = @queue.pop
|
231
246
|
req.reject(reason || :connection_failure)
|
232
247
|
end
|
248
|
+
|
249
|
+
next_request if awaiting_close || awaiting_connect
|
233
250
|
end
|
234
251
|
|
235
252
|
def data_received(data)
|
@@ -258,6 +275,8 @@ module UV
|
|
258
275
|
|
259
276
|
|
260
277
|
def next_request
|
278
|
+
# Don't start a request while transitioning state
|
279
|
+
return if @closing || @connecting
|
261
280
|
return if @parser.request || @queue.length == 0
|
262
281
|
|
263
282
|
if @connection
|
@@ -272,7 +291,10 @@ module UV
|
|
272
291
|
end
|
273
292
|
|
274
293
|
def new_connection
|
294
|
+
# no new connections while transitioning state
|
295
|
+
return if @closing || @connecting
|
275
296
|
if @queue.length > 0 && @connection.nil?
|
297
|
+
@connecting = true
|
276
298
|
@connection = Connection.new(@host, @port, @tls, @proxy, self)
|
277
299
|
start_timer
|
278
300
|
end
|
@@ -280,14 +302,17 @@ module UV
|
|
280
302
|
end
|
281
303
|
|
282
304
|
def close_connection
|
283
|
-
|
284
|
-
@connection.
|
305
|
+
# Close connection can be called while connecting
|
306
|
+
return if @closing || @connection.nil?
|
307
|
+
@closing = true
|
308
|
+
@connection.close_connection
|
285
309
|
stop_timer
|
286
310
|
@connection = nil
|
287
311
|
end
|
288
312
|
|
289
|
-
|
290
313
|
def start_timer
|
314
|
+
# Only start the timer if there is a connection starting or in place
|
315
|
+
return if @closing || @connection.nil?
|
291
316
|
@timer.cancel if @timer
|
292
317
|
@timer = @thread.scheduler.in(@inactivity_timeout) do
|
293
318
|
@timer = nil
|
@@ -302,9 +327,10 @@ module UV
|
|
302
327
|
end
|
303
328
|
|
304
329
|
def idle_timeout
|
305
|
-
|
306
|
-
@connection.reason = :timeout
|
330
|
+
connection = @connection
|
307
331
|
close_connection
|
332
|
+
@parser.reason = :timeout if @parser.request
|
333
|
+
connection.reason = :timeout if connection
|
308
334
|
end
|
309
335
|
end
|
310
336
|
end
|
data/lib/uv-rays/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uv-rays
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen von Takach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libuv
|
@@ -266,7 +266,6 @@ files:
|
|
266
266
|
- spec/ping_spec.rb
|
267
267
|
- spec/scheduler_spec.rb
|
268
268
|
- spec/scheduler_time_spec.rb
|
269
|
-
- spec/zen_spec.rb
|
270
269
|
- uv-rays.gemspec
|
271
270
|
homepage: https://github.com/cotag/uv-rays
|
272
271
|
licenses:
|
@@ -288,13 +287,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
288
287
|
version: '0'
|
289
288
|
requirements: []
|
290
289
|
rubyforge_project:
|
291
|
-
rubygems_version: 2.
|
290
|
+
rubygems_version: 2.7.7
|
292
291
|
signing_key:
|
293
292
|
specification_version: 4
|
294
293
|
summary: Abstractions for working with Libuv
|
295
294
|
test_files:
|
296
295
|
- spec/scheduler_time_spec.rb
|
297
|
-
- spec/zen_spec.rb
|
298
296
|
- spec/ping_spec.rb
|
299
297
|
- spec/http_endpoint_spec.rb
|
300
298
|
- spec/connection_spec.rb
|
data/spec/zen_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'libuv'
|
2
|
-
require 'set'
|
3
|
-
|
4
|
-
|
5
|
-
describe Libuv::Listener do
|
6
|
-
it "should ensure there are no remaining object references in callbacks", network: true do
|
7
|
-
require 'objspace'
|
8
|
-
|
9
|
-
checked = Set.new
|
10
|
-
|
11
|
-
# These are created by loop objects and are never cleaned up
|
12
|
-
# This is OK as the loops are expected to execute for the life of the application
|
13
|
-
except = []
|
14
|
-
|
15
|
-
ObjectSpace.each_object(Class) do |cls|
|
16
|
-
next unless cls.ancestors.include? ::UV::Connection
|
17
|
-
next if checked.include? cls
|
18
|
-
checked << cls
|
19
|
-
end
|
20
|
-
|
21
|
-
if checked.length > 0
|
22
|
-
puts "\nMemory Leak in #{checked.inspect}"
|
23
|
-
end
|
24
|
-
|
25
|
-
expect(checked.length).to be(0)
|
26
|
-
end
|
27
|
-
end
|