unicorn 5.6.0 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.manifest +3 -2
- data/.olddoc.yml +7 -4
- data/CONTRIBUTORS +6 -2
- data/GIT-VERSION-FILE +1 -1
- data/GIT-VERSION-GEN +1 -1
- data/GNUmakefile +104 -59
- data/HACKING +1 -8
- data/ISSUES +18 -17
- data/LATEST +23 -22
- data/NEWS +132 -0
- data/README +9 -3
- data/Sandbox +1 -1
- data/ext/unicorn_http/c_util.h +5 -13
- data/ext/unicorn_http/common_field_optimization.h +0 -1
- data/ext/unicorn_http/epollexclusive.h +124 -0
- data/ext/unicorn_http/ext_help.h +0 -24
- data/ext/unicorn_http/extconf.rb +2 -6
- data/ext/unicorn_http/global_variables.h +1 -1
- data/ext/unicorn_http/httpdate.c +1 -0
- data/ext/unicorn_http/unicorn_http.c +215 -223
- data/ext/unicorn_http/unicorn_http.rl +5 -13
- data/lib/unicorn/http_request.rb +0 -1
- data/lib/unicorn/http_server.rb +26 -27
- data/lib/unicorn/oob_gc.rb +3 -3
- data/lib/unicorn/select_waiter.rb +6 -0
- data/lib/unicorn/version.rb +1 -1
- data/lib/unicorn.rb +0 -2
- data/t/GNUmakefile +3 -72
- data/t/README +1 -1
- data/t/test-lib.sh +2 -1
- data/test/exec/test_exec.rb +5 -5
- data/test/test_helper.rb +38 -4
- data/test/unit/test_ccc.rb +4 -3
- data/test/unit/test_server.rb +52 -8
- data/test/unit/test_signals.rb +6 -6
- data/test/unit/test_socket_helper.rb +1 -1
- data/test/unit/test_upload.rb +5 -5
- data/test/unit/test_util.rb +4 -3
- data/test/unit/test_waiter.rb +34 -0
- data/unicorn.gemspec +6 -5
- metadata +8 -6
- data/t/hijack.ru +0 -55
- data/t/t0200-rack-hijack.sh +0 -51
data/test/unit/test_upload.rb
CHANGED
@@ -60,7 +60,7 @@ class UploadTest < Test::Unit::TestCase
|
|
60
60
|
|
61
61
|
def test_put
|
62
62
|
start_server(@sha1_app)
|
63
|
-
sock =
|
63
|
+
sock = tcp_socket(@addr, @port)
|
64
64
|
sock.syswrite("PUT / HTTP/1.0\r\nContent-Length: #{length}\r\n\r\n")
|
65
65
|
@count.times do |i|
|
66
66
|
buf = @random.sysread(@bs)
|
@@ -77,7 +77,7 @@ class UploadTest < Test::Unit::TestCase
|
|
77
77
|
def test_put_content_md5
|
78
78
|
md5 = Digest::MD5.new
|
79
79
|
start_server(@sha1_app)
|
80
|
-
sock =
|
80
|
+
sock = tcp_socket(@addr, @port)
|
81
81
|
sock.syswrite("PUT / HTTP/1.0\r\nTransfer-Encoding: chunked\r\n" \
|
82
82
|
"Trailer: Content-MD5\r\n\r\n")
|
83
83
|
@count.times do |i|
|
@@ -103,7 +103,7 @@ class UploadTest < Test::Unit::TestCase
|
|
103
103
|
@count, @bs = 2, 128
|
104
104
|
start_server(@sha1_app)
|
105
105
|
assert_equal 256, length
|
106
|
-
sock =
|
106
|
+
sock = tcp_socket(@addr, @port)
|
107
107
|
hdr = "PUT / HTTP/1.0\r\nContent-Length: #{length}\r\n\r\n"
|
108
108
|
@count.times do
|
109
109
|
buf = @random.sysread(@bs)
|
@@ -122,7 +122,7 @@ class UploadTest < Test::Unit::TestCase
|
|
122
122
|
|
123
123
|
def test_put_keepalive_truncates_small_overwrite
|
124
124
|
start_server(@sha1_app)
|
125
|
-
sock =
|
125
|
+
sock = tcp_socket(@addr, @port)
|
126
126
|
to_upload = length + 1
|
127
127
|
sock.syswrite("PUT / HTTP/1.0\r\nContent-Length: #{to_upload}\r\n\r\n")
|
128
128
|
@count.times do
|
@@ -155,7 +155,7 @@ class UploadTest < Test::Unit::TestCase
|
|
155
155
|
tmp.write(nr.to_s)
|
156
156
|
[ 200, @hdr, [] ]
|
157
157
|
})
|
158
|
-
sock =
|
158
|
+
sock = tcp_socket(@addr, @port)
|
159
159
|
buf = ' ' * @bs
|
160
160
|
sock.syswrite("PUT / HTTP/1.0\r\nContent-Length: #{length}\r\n\r\n")
|
161
161
|
|
data/test/unit/test_util.rb
CHANGED
@@ -51,7 +51,7 @@ class TestUtil < Test::Unit::TestCase
|
|
51
51
|
def test_reopen_logs_renamed_with_encoding
|
52
52
|
tmp = Tempfile.new('')
|
53
53
|
tmp_path = tmp.path.dup.freeze
|
54
|
-
Encoding.list.each { |encoding|
|
54
|
+
Encoding.list.sample(5).each { |encoding|
|
55
55
|
File.open(tmp_path, "a:#{encoding.to_s}") { |fp|
|
56
56
|
fp.sync = true
|
57
57
|
assert_equal encoding, fp.external_encoding
|
@@ -74,8 +74,9 @@ class TestUtil < Test::Unit::TestCase
|
|
74
74
|
def test_reopen_logs_renamed_with_internal_encoding
|
75
75
|
tmp = Tempfile.new('')
|
76
76
|
tmp_path = tmp.path.dup.freeze
|
77
|
-
Encoding.list
|
78
|
-
|
77
|
+
full = Encoding.list
|
78
|
+
full.sample(2).each { |ext|
|
79
|
+
full.sample(2).each { |int|
|
79
80
|
next if ext == int
|
80
81
|
File.open(tmp_path, "a:#{ext.to_s}:#{int.to_s}") { |fp|
|
81
82
|
fp.sync = true
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'unicorn'
|
3
|
+
require 'unicorn/select_waiter'
|
4
|
+
class TestSelectWaiter < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_select_timeout # n.b. this is level-triggered
|
7
|
+
sw = Unicorn::SelectWaiter.new
|
8
|
+
IO.pipe do |r,w|
|
9
|
+
sw.get_readers(ready = [], [r], 0)
|
10
|
+
assert_equal [], ready
|
11
|
+
w.syswrite '.'
|
12
|
+
sw.get_readers(ready, [r], 1000)
|
13
|
+
assert_equal [r], ready
|
14
|
+
sw.get_readers(ready, [r], 0)
|
15
|
+
assert_equal [r], ready
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_linux # ugh, also level-triggered, unlikely to change
|
20
|
+
IO.pipe do |r,w|
|
21
|
+
wtr = Unicorn::Waiter.prep_readers([r])
|
22
|
+
wtr.get_readers(ready = [], [r], 0)
|
23
|
+
assert_equal [], ready
|
24
|
+
w.syswrite '.'
|
25
|
+
wtr.get_readers(ready = [], [r], 1000)
|
26
|
+
assert_equal [r], ready
|
27
|
+
wtr.get_readers(ready = [], [r], 1000)
|
28
|
+
assert_equal [r], ready, 'still ready (level-triggered :<)'
|
29
|
+
assert_nil wtr.close
|
30
|
+
end
|
31
|
+
rescue SystemCallError => e
|
32
|
+
warn "#{e.message} (#{e.class})"
|
33
|
+
end if Unicorn.const_defined?(:Waiter)
|
34
|
+
end
|
data/unicorn.gemspec
CHANGED
@@ -11,7 +11,7 @@ end.compact
|
|
11
11
|
|
12
12
|
Gem::Specification.new do |s|
|
13
13
|
s.name = %q{unicorn}
|
14
|
-
s.version = (ENV['VERSION'] || '
|
14
|
+
s.version = (ENV['VERSION'] || '6.1.0').dup
|
15
15
|
s.authors = ['unicorn hackers']
|
16
16
|
s.summary = 'Rack HTTP server for fast clients and Unix'
|
17
17
|
s.description = File.read('README').split("\n\n")[1]
|
@@ -25,10 +25,11 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.homepage = 'https://yhbt.net/unicorn/'
|
26
26
|
s.test_files = test_files
|
27
27
|
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
|
28
|
+
# 2.0.0 is the minimum supported version. We don't specify
|
29
|
+
# a maximum version to make it easier to test pre-releases,
|
30
|
+
# but we do warn users if they install unicorn on an untested
|
31
|
+
# version in extconf.rb
|
32
|
+
s.required_ruby_version = ">= 2.0.0"
|
32
33
|
|
33
34
|
# We do not have a hard dependency on rack, it's possible to load
|
34
35
|
# things which respond to #call. HTTP status lines in responses
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unicorn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- unicorn hackers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- ext/unicorn_http/CFLAGS
|
158
158
|
- ext/unicorn_http/c_util.h
|
159
159
|
- ext/unicorn_http/common_field_optimization.h
|
160
|
+
- ext/unicorn_http/epollexclusive.h
|
160
161
|
- ext/unicorn_http/ext_help.h
|
161
162
|
- ext/unicorn_http/extconf.rb
|
162
163
|
- ext/unicorn_http/global_variables.h
|
@@ -176,6 +177,7 @@ files:
|
|
176
177
|
- lib/unicorn/launcher.rb
|
177
178
|
- lib/unicorn/oob_gc.rb
|
178
179
|
- lib/unicorn/preread_input.rb
|
180
|
+
- lib/unicorn/select_waiter.rb
|
179
181
|
- lib/unicorn/socket_helper.rb
|
180
182
|
- lib/unicorn/stream_input.rb
|
181
183
|
- lib/unicorn/tee_input.rb
|
@@ -197,7 +199,6 @@ files:
|
|
197
199
|
- t/env.ru
|
198
200
|
- t/fails-rack-lint.ru
|
199
201
|
- t/heartbeat-timeout.ru
|
200
|
-
- t/hijack.ru
|
201
202
|
- t/listener_names.ru
|
202
203
|
- t/my-tap-lib.sh
|
203
204
|
- t/oob_gc.ru
|
@@ -235,7 +236,6 @@ files:
|
|
235
236
|
- t/t0100-rack-input-tests.sh
|
236
237
|
- t/t0116-client_body_buffer_size.sh
|
237
238
|
- t/t0116.ru
|
238
|
-
- t/t0200-rack-hijack.sh
|
239
239
|
- t/t0300-no-default-middleware.sh
|
240
240
|
- t/t0301-no-default-middleware-ignored-in-config.sh
|
241
241
|
- t/t0301.ru
|
@@ -268,6 +268,7 @@ files:
|
|
268
268
|
- test/unit/test_tee_input.rb
|
269
269
|
- test/unit/test_upload.rb
|
270
270
|
- test/unit/test_util.rb
|
271
|
+
- test/unit/test_waiter.rb
|
271
272
|
- unicorn.gemspec
|
272
273
|
- unicorn_1
|
273
274
|
- unicorn_rails_1
|
@@ -282,9 +283,9 @@ require_paths:
|
|
282
283
|
- lib
|
283
284
|
required_ruby_version: !ruby/object:Gem::Requirement
|
284
285
|
requirements:
|
285
|
-
- - "
|
286
|
+
- - ">="
|
286
287
|
- !ruby/object:Gem::Version
|
287
|
-
version:
|
288
|
+
version: 2.0.0
|
288
289
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
289
290
|
requirements:
|
290
291
|
- - ">="
|
@@ -303,3 +304,4 @@ test_files:
|
|
303
304
|
- test/unit/test_server.rb
|
304
305
|
- test/unit/test_upload.rb
|
305
306
|
- test/unit/test_util.rb
|
307
|
+
- test/unit/test_waiter.rb
|
data/t/hijack.ru
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
use Rack::Lint
|
2
|
-
use Rack::ContentLength
|
3
|
-
use Rack::ContentType, "text/plain"
|
4
|
-
class DieIfUsed
|
5
|
-
@@n = 0
|
6
|
-
def each
|
7
|
-
abort "body.each called after response hijack\n"
|
8
|
-
end
|
9
|
-
|
10
|
-
def close
|
11
|
-
warn "closed DieIfUsed #{@@n += 1}\n"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
envs = []
|
16
|
-
|
17
|
-
run lambda { |env|
|
18
|
-
case env["PATH_INFO"]
|
19
|
-
when "/hijack_req"
|
20
|
-
if env["rack.hijack?"]
|
21
|
-
io = env["rack.hijack"].call
|
22
|
-
envs << env
|
23
|
-
if io.respond_to?(:read_nonblock) &&
|
24
|
-
env["rack.hijack_io"].respond_to?(:read_nonblock)
|
25
|
-
|
26
|
-
# exercise both, since we Rack::Lint may use different objects
|
27
|
-
env["rack.hijack_io"].write("HTTP/1.0 200 OK\r\n\r\n")
|
28
|
-
io.write("request.hijacked")
|
29
|
-
io.close
|
30
|
-
return [ 500, {}, DieIfUsed.new ]
|
31
|
-
end
|
32
|
-
end
|
33
|
-
[ 500, {}, [ "hijack BAD\n" ] ]
|
34
|
-
when "/hijack_res"
|
35
|
-
r = "response.hijacked"
|
36
|
-
[ 200,
|
37
|
-
{
|
38
|
-
"Content-Length" => r.bytesize.to_s,
|
39
|
-
"rack.hijack" => proc do |io|
|
40
|
-
envs << env
|
41
|
-
io.write(r)
|
42
|
-
io.close
|
43
|
-
end
|
44
|
-
},
|
45
|
-
DieIfUsed.new
|
46
|
-
]
|
47
|
-
when "/normal_env_id"
|
48
|
-
b = "#{env.object_id}\n"
|
49
|
-
h = {
|
50
|
-
'Content-Type' => 'text/plain',
|
51
|
-
'Content-Length' => b.bytesize.to_s,
|
52
|
-
}
|
53
|
-
[ 200, h, [ b ] ]
|
54
|
-
end
|
55
|
-
}
|
data/t/t0200-rack-hijack.sh
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
. ./test-lib.sh
|
3
|
-
t_plan 9 "rack.hijack tests (Rack 1.5+ (Rack::VERSION >= [ 1,2]))"
|
4
|
-
|
5
|
-
t_begin "setup and start" && {
|
6
|
-
unicorn_setup
|
7
|
-
unicorn -D -c $unicorn_config hijack.ru
|
8
|
-
unicorn_wait_start
|
9
|
-
}
|
10
|
-
|
11
|
-
t_begin "normal env reused between requests" && {
|
12
|
-
env_a="$(curl -sSf http://$listen/normal_env_id)"
|
13
|
-
b="$(curl -sSf http://$listen/normal_env_id)"
|
14
|
-
test x"$env_a" = x"$b"
|
15
|
-
}
|
16
|
-
|
17
|
-
t_begin "check request hijack" && {
|
18
|
-
test "xrequest.hijacked" = x"$(curl -sSfv http://$listen/hijack_req)"
|
19
|
-
}
|
20
|
-
|
21
|
-
t_begin "env changed after request hijack" && {
|
22
|
-
env_b="$(curl -sSf http://$listen/normal_env_id)"
|
23
|
-
test x"$env_a" != x"$env_b"
|
24
|
-
}
|
25
|
-
|
26
|
-
t_begin "check response hijack" && {
|
27
|
-
test "xresponse.hijacked" = x"$(curl -sSfv http://$listen/hijack_res)"
|
28
|
-
}
|
29
|
-
|
30
|
-
t_begin "env changed after response hijack" && {
|
31
|
-
env_c="$(curl -sSf http://$listen/normal_env_id)"
|
32
|
-
test x"$env_b" != x"$env_c"
|
33
|
-
}
|
34
|
-
|
35
|
-
t_begin "env continues to be reused between requests" && {
|
36
|
-
b="$(curl -sSf http://$listen/normal_env_id)"
|
37
|
-
test x"$env_c" = x"$b"
|
38
|
-
}
|
39
|
-
|
40
|
-
t_begin "killing succeeds after hijack" && {
|
41
|
-
kill $unicorn_pid
|
42
|
-
}
|
43
|
-
|
44
|
-
t_begin "check stderr for hijacked body close" && {
|
45
|
-
check_stderr
|
46
|
-
grep 'closed DieIfUsed 1\>' $r_err
|
47
|
-
grep 'closed DieIfUsed 2\>' $r_err
|
48
|
-
! grep 'closed DieIfUsed 3\>' $r_err
|
49
|
-
}
|
50
|
-
|
51
|
-
t_done
|