puma 5.5.1-java → 5.6.2-java

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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +67 -0
  3. data/LICENSE +0 -0
  4. data/README.md +5 -0
  5. data/bin/puma-wild +0 -0
  6. data/docs/architecture.md +4 -4
  7. data/docs/compile_options.md +0 -0
  8. data/docs/deployment.md +0 -0
  9. data/docs/fork_worker.md +0 -0
  10. data/docs/images/puma-connection-flow-no-reactor.png +0 -0
  11. data/docs/images/puma-connection-flow.png +0 -0
  12. data/docs/images/puma-general-arch.png +0 -0
  13. data/docs/jungle/README.md +0 -0
  14. data/docs/jungle/rc.d/README.md +0 -0
  15. data/docs/jungle/rc.d/puma.conf +0 -0
  16. data/docs/kubernetes.md +0 -0
  17. data/docs/nginx.md +0 -0
  18. data/docs/plugins.md +0 -0
  19. data/docs/rails_dev_mode.md +0 -0
  20. data/docs/restart.md +0 -0
  21. data/docs/signals.md +1 -0
  22. data/docs/stats.md +0 -0
  23. data/docs/systemd.md +0 -0
  24. data/ext/puma_http11/PumaHttp11Service.java +0 -0
  25. data/ext/puma_http11/ext_help.h +0 -0
  26. data/ext/puma_http11/extconf.rb +12 -6
  27. data/ext/puma_http11/http11_parser.c +22 -16
  28. data/ext/puma_http11/http11_parser.h +0 -0
  29. data/ext/puma_http11/http11_parser.java.rl +0 -0
  30. data/ext/puma_http11/http11_parser.rl +0 -0
  31. data/ext/puma_http11/http11_parser_common.rl +1 -1
  32. data/ext/puma_http11/mini_ssl.c +54 -9
  33. data/ext/puma_http11/no_ssl/PumaHttp11Service.java +0 -0
  34. data/ext/puma_http11/org/jruby/puma/Http11.java +0 -0
  35. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +49 -47
  36. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +28 -43
  37. data/ext/puma_http11/puma_http11.c +1 -1
  38. data/lib/puma/app/status.rb +0 -0
  39. data/lib/puma/binder.rb +19 -5
  40. data/lib/puma/cli.rb +9 -4
  41. data/lib/puma/client.rb +1 -1
  42. data/lib/puma/cluster/worker.rb +5 -5
  43. data/lib/puma/cluster/worker_handle.rb +4 -0
  44. data/lib/puma/cluster.rb +29 -11
  45. data/lib/puma/commonlogger.rb +0 -0
  46. data/lib/puma/configuration.rb +3 -0
  47. data/lib/puma/const.rb +2 -5
  48. data/lib/puma/control_cli.rb +0 -0
  49. data/lib/puma/detect.rb +8 -2
  50. data/lib/puma/dsl.rb +85 -8
  51. data/lib/puma/error_logger.rb +0 -0
  52. data/lib/puma/events.rb +0 -0
  53. data/lib/puma/io_buffer.rb +0 -0
  54. data/lib/puma/jruby_restart.rb +0 -0
  55. data/lib/puma/json_serialization.rb +0 -0
  56. data/lib/puma/launcher.rb +2 -1
  57. data/lib/puma/minissl/context_builder.rb +8 -6
  58. data/lib/puma/minissl.rb +18 -2
  59. data/lib/puma/null_io.rb +0 -0
  60. data/lib/puma/plugin/tmp_restart.rb +0 -0
  61. data/lib/puma/plugin.rb +1 -1
  62. data/lib/puma/puma_http11.jar +0 -0
  63. data/lib/puma/queue_close.rb +0 -0
  64. data/lib/puma/rack/builder.rb +0 -0
  65. data/lib/puma/rack/urlmap.rb +0 -0
  66. data/lib/puma/rack_default.rb +0 -0
  67. data/lib/puma/reactor.rb +0 -0
  68. data/lib/puma/request.rb +10 -5
  69. data/lib/puma/runner.rb +3 -2
  70. data/lib/puma/server.rb +18 -24
  71. data/lib/puma/single.rb +0 -0
  72. data/lib/puma/state_file.rb +41 -7
  73. data/lib/puma/systemd.rb +0 -0
  74. data/lib/puma/thread_pool.rb +2 -2
  75. data/lib/puma/util.rb +0 -0
  76. data/lib/puma.rb +0 -0
  77. data/lib/rack/handler/puma.rb +0 -0
  78. data/tools/Dockerfile +1 -1
  79. data/tools/trickletest.rb +0 -0
  80. metadata +3 -3
data/lib/puma/minissl.rb CHANGED
@@ -208,6 +208,10 @@ module Puma
208
208
  def initialize
209
209
  @no_tlsv1 = false
210
210
  @no_tlsv1_1 = false
211
+ @key = nil
212
+ @cert = nil
213
+ @key_pem = nil
214
+ @cert_pem = nil
211
215
  end
212
216
 
213
217
  if IS_JRUBY
@@ -230,6 +234,8 @@ module Puma
230
234
  attr_reader :key
231
235
  attr_reader :cert
232
236
  attr_reader :ca
237
+ attr_reader :cert_pem
238
+ attr_reader :key_pem
233
239
  attr_accessor :ssl_cipher_filter
234
240
  attr_accessor :verification_flags
235
241
 
@@ -248,9 +254,19 @@ module Puma
248
254
  @ca = ca
249
255
  end
250
256
 
257
+ def cert_pem=(cert_pem)
258
+ raise ArgumentError, "'cert_pem' is not a String" unless cert_pem.is_a? String
259
+ @cert_pem = cert_pem
260
+ end
261
+
262
+ def key_pem=(key_pem)
263
+ raise ArgumentError, "'key_pem' is not a String" unless key_pem.is_a? String
264
+ @key_pem = key_pem
265
+ end
266
+
251
267
  def check
252
- raise "Key not configured" unless @key
253
- raise "Cert not configured" unless @cert
268
+ raise "Key not configured" if @key.nil? && @key_pem.nil?
269
+ raise "Cert not configured" if @cert.nil? && @cert_pem.nil?
254
270
  end
255
271
  end
256
272
 
data/lib/puma/null_io.rb CHANGED
File without changes
File without changes
data/lib/puma/plugin.rb CHANGED
@@ -64,7 +64,7 @@ module Puma
64
64
  def fire_background
65
65
  @background.each_with_index do |b, i|
66
66
  Thread.new do
67
- Puma.set_thread_name "plugin background #{i}"
67
+ Puma.set_thread_name "plgn bg #{i}"
68
68
  b.call
69
69
  end
70
70
  end
Binary file
File without changes
File without changes
File without changes
File without changes
data/lib/puma/reactor.rb CHANGED
File without changes
data/lib/puma/request.rb CHANGED
@@ -167,11 +167,16 @@ module Puma
167
167
  end
168
168
 
169
169
  ensure
170
- uncork_socket io
171
-
172
- body.close
173
- client.tempfile.unlink if client.tempfile
174
- res_body.close if res_body.respond_to? :close
170
+ begin
171
+ uncork_socket io
172
+
173
+ body.close
174
+ client.tempfile.unlink if client.tempfile
175
+ ensure
176
+ # Whatever happens, we MUST call `close` on the response body.
177
+ # Otherwise Rack::BodyProxy callbacks may not fire and lead to various state leaks
178
+ res_body.close if res_body.respond_to? :close
179
+ end
175
180
 
176
181
  after_reply.each { |o| o.call }
177
182
  end
data/lib/puma/runner.rb CHANGED
@@ -69,7 +69,7 @@ module Puma
69
69
 
70
70
  control.binder.parse [str], self, 'Starting control server'
71
71
 
72
- control.run thread_name: 'control'
72
+ control.run thread_name: 'ctl'
73
73
  @control = control
74
74
  end
75
75
 
@@ -94,12 +94,13 @@ module Puma
94
94
  def output_header(mode)
95
95
  min_t = @options[:min_threads]
96
96
  max_t = @options[:max_threads]
97
+ environment = @options[:environment]
97
98
 
98
99
  log "Puma starting in #{mode} mode..."
99
100
  log "* Puma version: #{Puma::Const::PUMA_VERSION} (#{ruby_engine}) (\"#{Puma::Const::CODE_NAME}\")"
100
101
  log "* Min threads: #{min_t}"
101
102
  log "* Max threads: #{max_t}"
102
- log "* Environment: #{ENV['RACK_ENV']}"
103
+ log "* Environment: #{environment}"
103
104
 
104
105
  if mode == "cluster"
105
106
  log "* Master PID: #{Process.pid}"
data/lib/puma/server.rb CHANGED
@@ -220,7 +220,7 @@ module Puma
220
220
  # up in the background to handle requests. Otherwise requests
221
221
  # are handled synchronously.
222
222
  #
223
- def run(background=true, thread_name: 'server')
223
+ def run(background=true, thread_name: 'srv')
224
224
  BasicSocket.do_not_reverse_lookup = true
225
225
 
226
226
  @events.fire :state, :booting
@@ -315,16 +315,15 @@ module Puma
315
315
  queue_requests = @queue_requests
316
316
  drain = @options[:drain_on_shutdown] ? 0 : nil
317
317
 
318
- remote_addr_value = nil
319
- remote_addr_header = nil
320
-
321
- case @options[:remote_address]
318
+ addr_send_name, addr_value = case @options[:remote_address]
322
319
  when :value
323
- remote_addr_value = @options[:remote_address_value]
320
+ [:peerip=, @options[:remote_address_value]]
324
321
  when :header
325
- remote_addr_header = @options[:remote_address_header]
322
+ [:remote_addr_header=, @options[:remote_address_header]]
326
323
  when :proxy_protocol
327
- remote_addr_proxy_protocol = @options[:remote_address_proxy_protocol]
324
+ [:expect_proxy_proto=, @options[:remote_address_proxy_protocol]]
325
+ else
326
+ [nil, nil]
328
327
  end
329
328
 
330
329
  while @status == :run || (drain && shutting_down?)
@@ -344,16 +343,10 @@ module Puma
344
343
  next
345
344
  end
346
345
  drain += 1 if shutting_down?
347
- client = Client.new io, @binder.env(sock)
348
- client.listener = sock
349
- if remote_addr_value
350
- client.peerip = remote_addr_value
351
- elsif remote_addr_header
352
- client.remote_addr_header = remote_addr_header
353
- elsif remote_addr_proxy_protocol
354
- client.expect_proxy_proto = remote_addr_proxy_protocol
355
- end
356
- pool << client
346
+ pool << Client.new(io, @binder.env(sock)).tap { |c|
347
+ c.listener = sock
348
+ c.send(addr_send_name, addr_value) if addr_value
349
+ }
357
350
  end
358
351
  end
359
352
  rescue IOError, Errno::EBADF
@@ -375,13 +368,14 @@ module Puma
375
368
  rescue Exception => e
376
369
  @events.unknown_error e, nil, "Exception handling servers"
377
370
  ensure
378
- begin
379
- @check.close unless @check.closed?
380
- rescue Errno::EBADF, RuntimeError
381
- # RuntimeError is Ruby 2.2 issue, can't modify frozen IOError
382
- # Errno::EBADF is infrequently raised
371
+ # RuntimeError is Ruby 2.2 issue, can't modify frozen IOError
372
+ # Errno::EBADF is infrequently raised
373
+ [@check, @notify].each do |io|
374
+ begin
375
+ io.close unless io.closed?
376
+ rescue Errno::EBADF, RuntimeError
377
+ end
383
378
  end
384
- @notify.close
385
379
  @notify = nil
386
380
  @check = nil
387
381
  end
data/lib/puma/single.rb CHANGED
File without changes
@@ -1,15 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'yaml'
4
-
5
3
  module Puma
4
+
5
+ # Puma::Launcher uses StateFile to write a yaml file for use with Puma::ControlCLI.
6
+ #
7
+ # In previous versions of Puma, YAML was used to read/write the state file.
8
+ # Since Puma is similar to Bundler/RubyGems in that it may load before one's app
9
+ # does, minimizing the dependencies that may be shared with the app is desired.
10
+ #
11
+ # At present, it only works with numeric and string values. It is still a valid
12
+ # yaml file, and the CI tests parse it with Psych.
13
+ #
6
14
  class StateFile
15
+
16
+ ALLOWED_FIELDS = %w!control_url control_auth_token pid running_from!
17
+
18
+ # @deprecated 6.0.0
19
+ FIELDS = ALLOWED_FIELDS
20
+
7
21
  def initialize
8
22
  @options = {}
9
23
  end
10
24
 
11
25
  def save(path, permission = nil)
12
- contents =YAML.dump @options
26
+ contents = "---\n".dup
27
+ @options.each do |k,v|
28
+ next unless ALLOWED_FIELDS.include? k
29
+ case v
30
+ when Numeric
31
+ contents << "#{k}: #{v}\n"
32
+ when String
33
+ next if v.strip.empty?
34
+ contents << (k == 'running_from' || v.to_s.include?(' ') ?
35
+ "#{k}: \"#{v}\"\n" : "#{k}: #{v}\n")
36
+ end
37
+ end
13
38
  if permission
14
39
  File.write path, contents, mode: 'wb:UTF-8'
15
40
  else
@@ -18,12 +43,21 @@ module Puma
18
43
  end
19
44
 
20
45
  def load(path)
21
- @options = YAML.load File.read(path)
46
+ File.read(path).lines.each do |line|
47
+ next if line.start_with? '#'
48
+ k,v = line.split ':', 2
49
+ next unless v && ALLOWED_FIELDS.include?(k)
50
+ v = v.strip
51
+ @options[k] =
52
+ case v
53
+ when /\A\d+\z/ then v.to_i
54
+ when /\A\d+\.\d+\z/ then v.to_f
55
+ else v.gsub(/\A"|"\z/, '')
56
+ end
57
+ end
22
58
  end
23
59
 
24
- FIELDS = %w!control_url control_auth_token pid running_from!
25
-
26
- FIELDS.each do |f|
60
+ ALLOWED_FIELDS.each do |f|
27
61
  define_method f do
28
62
  @options[f]
29
63
  end
data/lib/puma/systemd.rb CHANGED
File without changes
@@ -72,7 +72,7 @@ module Puma
72
72
  attr_accessor :out_of_band_hook # @version 5.0.0
73
73
 
74
74
  def self.clean_thread_locals
75
- Thread.current.keys.each do |key| # rubocop: disable Performance/HashEachMethods
75
+ Thread.current.keys.each do |key| # rubocop: disable Style/HashEachMethods
76
76
  Thread.current[key] = nil unless key == :__recursive_key__
77
77
  end
78
78
  end
@@ -102,7 +102,7 @@ module Puma
102
102
  @spawned += 1
103
103
 
104
104
  th = Thread.new(@spawned) do |spawned|
105
- Puma.set_thread_name '%s threadpool %03i' % [@name, spawned]
105
+ Puma.set_thread_name '%s tp %03i' % [@name, spawned]
106
106
  todo = @todo
107
107
  block = @block
108
108
  mutex = @mutex
data/lib/puma/util.rb CHANGED
File without changes
data/lib/puma.rb CHANGED
File without changes
File without changes
data/tools/Dockerfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # Use this Dockerfile to create minimal reproductions of issues
2
2
 
3
- FROM ruby:2.6
3
+ FROM ruby:3.1
4
4
 
5
5
  # throw errors if Gemfile has been modified since Gemfile.lock
6
6
  RUN bundle config --global frozen 1
data/tools/trickletest.rb CHANGED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.1
4
+ version: 5.6.2
5
5
  platform: java
6
6
  authors:
7
7
  - Evan Phoenix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-12 00:00:00.000000000 Z
11
+ date: 1980-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
- rubygems_version: 3.1.6
143
+ rubygems_version: 3.2.29
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Puma is a simple, fast, threaded, and highly parallel HTTP 1.1 server for