yahns 1.12.5 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/Documentation/yahns-rackup.pod +0 -10
  3. data/Documentation/yahns_config.pod +3 -0
  4. data/GIT-VERSION-FILE +1 -1
  5. data/GIT-VERSION-GEN +1 -1
  6. data/NEWS +80 -0
  7. data/examples/init.sh +34 -9
  8. data/examples/logrotate.conf +5 -0
  9. data/examples/yahns.socket +17 -0
  10. data/examples/yahns@.service +50 -0
  11. data/examples/yahns_rack_basic.conf.rb +0 -6
  12. data/extras/autoindex.rb +3 -2
  13. data/extras/exec_cgi.rb +1 -0
  14. data/extras/try_gzip_static.rb +19 -5
  15. data/lib/yahns/chunk_body.rb +27 -0
  16. data/lib/yahns/fdmap.rb +7 -4
  17. data/lib/yahns/http_client.rb +39 -10
  18. data/lib/yahns/http_response.rb +41 -22
  19. data/lib/yahns/openssl_client.rb +7 -3
  20. data/lib/yahns/proxy_http_response.rb +132 -159
  21. data/lib/yahns/proxy_pass.rb +6 -170
  22. data/lib/yahns/queue_epoll.rb +1 -0
  23. data/lib/yahns/queue_kqueue.rb +1 -0
  24. data/lib/yahns/req_res.rb +164 -0
  25. data/lib/yahns/server.rb +2 -1
  26. data/lib/yahns/server_mp.rb +1 -1
  27. data/lib/yahns/version.rb +1 -1
  28. data/lib/yahns/wbuf.rb +5 -6
  29. data/lib/yahns/wbuf_common.rb +5 -10
  30. data/lib/yahns/wbuf_lite.rb +111 -0
  31. data/man/yahns-rackup.1 +29 -29
  32. data/man/yahns_config.5 +47 -35
  33. data/test/helper.rb +12 -0
  34. data/test/test_auto_chunk.rb +56 -0
  35. data/test/test_extras_exec_cgi.rb +1 -3
  36. data/test/test_extras_try_gzip_static.rb +30 -16
  37. data/test/test_output_buffering.rb +5 -1
  38. data/test/test_proxy_pass.rb +2 -2
  39. data/test/test_proxy_pass_no_buffering.rb +170 -0
  40. data/test/test_reopen_logs.rb +5 -1
  41. data/test/test_response.rb +42 -0
  42. data/test/test_server.rb +35 -0
  43. data/test/test_ssl.rb +0 -6
  44. data/test/test_tmpio.rb +4 -0
  45. data/test/test_wbuf.rb +11 -4
  46. metadata +10 -4
  47. data/lib/yahns/sendfile_compat.rb +0 -24
data/test/test_server.rb CHANGED
@@ -725,6 +725,41 @@ class TestServer < Testcase
725
725
  assert_nil c.read(666)
726
726
  end
727
727
 
728
+ def test_slow_shutdown_timeout; _slow_shutdown(nil); end
729
+ def test_slow_shutdown_timeout_mp; _slow_shutdown(1); end
730
+
731
+ def _slow_shutdown(nr_workers)
732
+ err, cfg, host, port = @err, Yahns::Config.new, @srv.addr[3], @srv.addr[1]
733
+ pid = mkserver(cfg) do
734
+ ru = lambda { |e| [ 200, {'Content-Length'=>'2'}, %w(OK) ] }
735
+ cfg.instance_eval do
736
+ app(:rack, ru) { listen "#{host}:#{port}" }
737
+ stderr_path err.path
738
+ worker_processes(nr_workers) if nr_workers
739
+ end
740
+ end
741
+ c = get_tcp_client(host, port)
742
+ c.write 'G'
743
+ 100000.times { Thread.pass }
744
+ Process.kill(:QUIT, pid)
745
+ "ET / HTTP/1.1\r\nHost: example.com\r\n\r\n".each_byte do |x|
746
+ Thread.pass
747
+ c.write(x.chr)
748
+ Thread.pass
749
+ end
750
+ assert_equal c, c.wait(30)
751
+ buf = ''.dup
752
+ re = /\r\n\r\nOK\z/
753
+ Timeout.timeout(30) do
754
+ begin
755
+ buf << c.readpartial(666)
756
+ end until re =~ buf
757
+ end
758
+ c.close
759
+ _, status = Timeout.timeout(5) { Process.waitpid2(pid) }
760
+ assert status.success?, status.inspect
761
+ end
762
+
728
763
  def test_before_exec
729
764
  err, cfg, host, port = @err, Yahns::Config.new, @srv.addr[3], @srv.addr[1]
730
765
  ru = lambda { |e| [ 200, {'Content-Length'=>'2' }, %w(OK) ] }
data/test/test_ssl.rb CHANGED
@@ -26,12 +26,6 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC
26
26
  -----END DH PARAMETERS-----
27
27
  _end_of_pem_
28
28
 
29
- TEST_KEY_DH1024.priv_key = OpenSSL::BN.new("48561834C67E65FFD2A9B47F41" \
30
- "E5E78FDC95C387428FDB1E4B0188B64D1643C3A8D3455B945B7E8C4D166010C7C2" \
31
- "CE23BFB9BEF43D0348FE7FA5284B0225E7FE1537546D114E3D8A4411B9B9351AB4" \
32
- "51E1A358F50ED61B1F00DA29336EEBBD649980AC86D76AF8BBB065298C2052672E" \
33
- "EF3EF13AB47A15275FC2836F3AC74CEA", 16)
34
-
35
29
  def setup
36
30
  unless FAST_NB
37
31
  skip "missing exception-free non-blocking IO in " \
data/test/test_tmpio.rb CHANGED
@@ -5,6 +5,10 @@
5
5
  require_relative 'helper'
6
6
 
7
7
  class TestTmpIO < Testcase
8
+ def setup
9
+ skip 'sendfile missing' unless IO.instance_methods.include?(:sendfile)
10
+ end
11
+
8
12
  def test_writev
9
13
  a, b = UNIXSocket.pair
10
14
  a.extend Kgio::PipeMethods
data/test/test_wbuf.rb CHANGED
@@ -7,8 +7,15 @@ require 'timeout'
7
7
  class TestWbuf < Testcase
8
8
  ENV["N"].to_i > 1 and parallelize_me!
9
9
 
10
+ def setup
11
+ skip 'sendfile missing' unless IO.instance_methods.include?(:sendfile)
12
+ end
13
+
10
14
  class KgioUS < UNIXSocket
11
15
  include Kgio::SocketMethods
16
+ def self.output_buffer_tmpdir
17
+ Dir.tmpdir
18
+ end
12
19
  end
13
20
 
14
21
  def socketpair
@@ -20,8 +27,8 @@ class TestWbuf < Testcase
20
27
  buf = "*" * (16384 * 2)
21
28
  nr = 1000
22
29
  [ true, false ].each do |persist|
23
- wbuf = Yahns::Wbuf.new([], persist, Dir.tmpdir, :wait_writable)
24
- assert_equal :wait_writable, wbuf.busy
30
+ wbuf = Yahns::Wbuf.new([], persist)
31
+ assert_equal false, wbuf.busy
25
32
  a, b = socketpair
26
33
  assert_nil wbuf.wbuf_write(a, "HIHI")
27
34
  assert_equal "HIHI", b.read(4)
@@ -71,7 +78,7 @@ class TestWbuf < Testcase
71
78
  break
72
79
  end while true
73
80
  end
74
- wbuf = Yahns::Wbuf.new([], true, Dir.tmpdir, :wait_writable)
81
+ wbuf = Yahns::Wbuf.new([], true)
75
82
 
76
83
  rv1 = wbuf.wbuf_write(a, buf)
77
84
  rv2 = wbuf.wbuf_flush(a)
@@ -104,7 +111,7 @@ class TestWbuf < Testcase
104
111
  def test_wbuf_flush_close
105
112
  pipe = cloexec_pipe
106
113
  persist = true
107
- wbuf = Yahns::Wbuf.new(pipe[0], persist, Dir.tmpdir, :wait_writable)
114
+ wbuf = Yahns::Wbuf.new(pipe[0], persist)
108
115
  refute wbuf.respond_to?(:close) # we don't want this for HttpResponse body
109
116
  sp = socketpair
110
117
  rv = nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yahns
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.5
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yahns hackers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-05 00:00:00.000000000 Z
11
+ date: 2016-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kgio
@@ -130,6 +130,8 @@ files:
130
130
  - examples/init.sh
131
131
  - examples/logger_mp_safe.rb
132
132
  - examples/logrotate.conf
133
+ - examples/yahns.socket
134
+ - examples/yahns@.service
133
135
  - examples/yahns_multi.conf.rb
134
136
  - examples/yahns_rack_basic.conf.rb
135
137
  - extras/README
@@ -140,6 +142,7 @@ files:
140
142
  - lib/yahns.rb
141
143
  - lib/yahns/acceptor.rb
142
144
  - lib/yahns/cap_input.rb
145
+ - lib/yahns/chunk_body.rb
143
146
  - lib/yahns/client_expire_generic.rb
144
147
  - lib/yahns/client_expire_tcpi.rb
145
148
  - lib/yahns/config.rb
@@ -164,7 +167,7 @@ files:
164
167
  - lib/yahns/queue_quitter_pipe.rb
165
168
  - lib/yahns/rack.rb
166
169
  - lib/yahns/rackup_handler.rb
167
- - lib/yahns/sendfile_compat.rb
170
+ - lib/yahns/req_res.rb
168
171
  - lib/yahns/server.rb
169
172
  - lib/yahns/server_mp.rb
170
173
  - lib/yahns/sigevent.rb
@@ -180,6 +183,7 @@ files:
180
183
  - lib/yahns/version.rb
181
184
  - lib/yahns/wbuf.rb
182
185
  - lib/yahns/wbuf_common.rb
186
+ - lib/yahns/wbuf_lite.rb
183
187
  - lib/yahns/wbuf_str.rb
184
188
  - lib/yahns/worker.rb
185
189
  - man/yahns-rackup.1
@@ -188,6 +192,7 @@ files:
188
192
  - test/covshow.rb
189
193
  - test/helper.rb
190
194
  - test/server_helper.rb
195
+ - test/test_auto_chunk.rb
191
196
  - test/test_bin.rb
192
197
  - test/test_buffer_tmpdir.rb
193
198
  - test/test_client_expire.rb
@@ -204,6 +209,7 @@ files:
204
209
  - test/test_mt_accept.rb
205
210
  - test/test_output_buffering.rb
206
211
  - test/test_proxy_pass.rb
212
+ - test/test_proxy_pass_no_buffering.rb
207
213
  - test/test_rack.rb
208
214
  - test/test_rack_hijack.rb
209
215
  - test/test_reopen_logs.rb
@@ -236,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
242
  version: '0'
237
243
  requirements: []
238
244
  rubyforge_project:
239
- rubygems_version: 2.6.4
245
+ rubygems_version: 2.6.6
240
246
  signing_key:
241
247
  specification_version: 4
242
248
  summary: sleepy, multi-threaded, non-blocking application server
@@ -1,24 +0,0 @@
1
- # -*- encoding: binary -*-
2
- # Copyright (C) 2013-2016 all contributors <yahns-public@yhbt.net>
3
- # License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt)
4
- # frozen_string_literal: true
5
-
6
- module Yahns::SendfileCompat # :nodoc:
7
- def trysendfile(io, offset, count)
8
- return 0 if count == 0
9
- count = 0x4000 if count > 0x4000
10
- buf = Thread.current[:yahns_sfbuf] ||= ''.dup
11
- io.pos = offset
12
- str = io.read(count, buf) or return # nil for EOF
13
- n = 0
14
- case rv = kgio_trywrite(str)
15
- when String # partial write, keep trying
16
- n += (str.size - rv.size)
17
- str = rv
18
- when :wait_writable, :wait_readable
19
- return n > 0 ? n : rv
20
- when nil
21
- return n + str.size # yay!
22
- end while true
23
- end
24
- end