puma 8.1.3 → 8.2.0.pre1
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.
- checksums.yaml +4 -4
- data/History.md +120 -0
- data/README.md +4 -3
- data/docs/GLOSSARY.md +160 -0
- data/docs/architecture.md +41 -42
- data/docs/binding.md +3 -0
- data/docs/cluster_mode.md +21 -21
- data/docs/control_server.md +4 -4
- data/docs/deployment/nginx.md +2 -0
- data/docs/deployment/systemd.md +15 -0
- data/docs/puma_support.md +12 -0
- data/docs/restart.md +2 -2
- data/docs/signals.md +3 -3
- data/docs/ssl.md +65 -0
- data/docs/upgrading/5.0-Upgrade.md +1 -1
- data/docs/upgrading/6.0-Upgrade.md +1 -1
- data/docs/upgrading/7.0-Upgrade.md +1 -1
- data/docs/upgrading/8.0-Upgrade.md +1 -1
- data/ext/puma_http11/extconf.rb +7 -5
- data/ext/puma_http11/http11_parser.c +66 -84
- data/ext/puma_http11/http11_parser.h +0 -5
- data/ext/puma_http11/mini_ssl.c +31 -68
- data/ext/puma_http11/puma_http11.c +125 -7
- data/lib/puma/app/status.rb +22 -7
- data/lib/puma/binder.rb +0 -1
- data/lib/puma/cli.rb +1 -3
- data/lib/puma/client.rb +133 -57
- data/lib/puma/client_env.rb +9 -11
- data/lib/puma/cluster/worker.rb +0 -6
- data/lib/puma/cluster.rb +3 -14
- data/lib/puma/cluster_accept_loop_delay.rb +18 -7
- data/lib/puma/commonlogger.rb +3 -4
- data/lib/puma/configuration.rb +4 -1
- data/lib/puma/const.rb +5 -5
- data/lib/puma/control_cli.rb +5 -7
- data/lib/puma/detect.rb +1 -1
- data/lib/puma/dsl.rb +70 -14
- data/lib/puma/http_parser_error.rb +8 -0
- data/lib/puma/launcher/bundle_pruner.rb +3 -21
- data/lib/puma/launcher.rb +55 -25
- data/lib/puma/minissl/context_builder.rb +3 -2
- data/lib/puma/minissl.rb +12 -16
- data/lib/puma/plugin/systemd.rb +69 -3
- data/lib/puma/rack/urlmap.rb +2 -2
- data/lib/puma/reactor.rb +138 -25
- data/lib/puma/response.rb +65 -38
- data/lib/puma/runner.rb +4 -1
- data/lib/puma/sd_notify.rb +21 -0
- data/lib/puma/server.rb +14 -14
- data/lib/puma/server_plugin_control.rb +2 -1
- data/lib/puma/single.rb +0 -1
- data/lib/puma/thread_pool.rb +87 -14
- data/lib/puma/util.rb +5 -16
- data/lib/puma.rb +22 -5
- data/lib/rack/handler/puma.rb +1 -5
- metadata +5 -2
data/lib/puma/thread_pool.rb
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'thread'
|
|
4
|
-
|
|
5
|
-
require_relative 'io_buffer'
|
|
6
3
|
require_relative 'server_plugin_control'
|
|
7
4
|
|
|
8
5
|
module Puma
|
|
@@ -210,21 +207,25 @@ module Puma
|
|
|
210
207
|
processor.marked_as_io_thread = false
|
|
211
208
|
else
|
|
212
209
|
# We're already at max threads, so we exit the extra io thread.
|
|
213
|
-
|
|
214
|
-
@processors.delete(processor)
|
|
215
|
-
trigger_before_thread_exit_hooks
|
|
216
|
-
Thread.exit
|
|
210
|
+
trim_thread(processor)
|
|
217
211
|
end
|
|
218
212
|
end
|
|
219
213
|
|
|
214
|
+
trim_thread_if_requested(processor)
|
|
215
|
+
|
|
220
216
|
while todo.empty?
|
|
217
|
+
# Thread trimming could be requested when process is idle, when
|
|
218
|
+
# max was lowered, or during shutdown, hence we need to trim when
|
|
219
|
+
# todo is empty.
|
|
221
220
|
if @trim_requested > 0
|
|
222
221
|
@trim_requested -= 1
|
|
223
|
-
@spawned
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
222
|
+
if @shutdown || @spawned > @min
|
|
223
|
+
trim_thread(processor)
|
|
224
|
+
else
|
|
225
|
+
@trim_requested = 0
|
|
226
|
+
end
|
|
227
|
+
elsif !@shutdown && @spawned > @min && over_max_processors?
|
|
228
|
+
trim_thread(processor)
|
|
228
229
|
end
|
|
229
230
|
|
|
230
231
|
@waiting += 1
|
|
@@ -257,6 +258,40 @@ module Puma
|
|
|
257
258
|
|
|
258
259
|
private :spawn_thread
|
|
259
260
|
|
|
261
|
+
# :nodoc:
|
|
262
|
+
#
|
|
263
|
+
# Must be called with @mutex held, on a pool thread, between work items.
|
|
264
|
+
#
|
|
265
|
+
def trim_thread_if_requested(processor)
|
|
266
|
+
return if @shutdown || @spawned <= @min || @spawned <= 1
|
|
267
|
+
|
|
268
|
+
if @trim_requested > 0
|
|
269
|
+
@trim_requested -= 1
|
|
270
|
+
trim_thread(processor)
|
|
271
|
+
elsif over_max_processors?
|
|
272
|
+
trim_thread(processor)
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
private :trim_thread_if_requested
|
|
277
|
+
|
|
278
|
+
# :nodoc:
|
|
279
|
+
#
|
|
280
|
+
# Must be called with @mutex held, on the pool thread being trimmed.
|
|
281
|
+
# Performs the trim bookkeeping and exits the current thread. Signals
|
|
282
|
+
# not_full because the exit lowers busy_threads, which may unblock
|
|
283
|
+
# threads waiting in wait_until_not_full.
|
|
284
|
+
#
|
|
285
|
+
def trim_thread(processor)
|
|
286
|
+
@spawned -= 1
|
|
287
|
+
@processors.delete(processor)
|
|
288
|
+
@not_full.signal
|
|
289
|
+
trigger_before_thread_exit_hooks
|
|
290
|
+
Thread.exit
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
private :trim_thread
|
|
294
|
+
|
|
260
295
|
def trigger_before_thread_start_hooks
|
|
261
296
|
return unless @before_thread_start&.any?
|
|
262
297
|
|
|
@@ -318,7 +353,8 @@ module Puma
|
|
|
318
353
|
with_mutex do
|
|
319
354
|
while true
|
|
320
355
|
return if @shutdown
|
|
321
|
-
|
|
356
|
+
io_threads = [@processors.count(&:marked_as_io_thread?), @max_io_threads].min
|
|
357
|
+
return if (@spawned - @waiting + @todo.size) < @max + io_threads
|
|
322
358
|
|
|
323
359
|
@not_full.wait @mutex
|
|
324
360
|
end
|
|
@@ -337,9 +373,45 @@ module Puma
|
|
|
337
373
|
# Must be called with @mutex held!
|
|
338
374
|
#
|
|
339
375
|
def can_spawn_processor?
|
|
376
|
+
normal_processors_delta < 0
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
# :nodoc:
|
|
380
|
+
#
|
|
381
|
+
# Must be called with @mutex held!
|
|
382
|
+
#
|
|
383
|
+
def over_max_processors?
|
|
384
|
+
normal_processors_delta > 0
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
private :over_max_processors?
|
|
388
|
+
|
|
389
|
+
def normal_processors_delta
|
|
340
390
|
io_processors_count = @processors.count(&:marked_as_io_thread?)
|
|
341
391
|
extra_io_processors_count = io_processors_count > @max_io_threads ? io_processors_count - @max_io_threads : 0
|
|
342
|
-
(@spawned - io_processors_count)
|
|
392
|
+
(@spawned - io_processors_count) - (@max - extra_io_processors_count)
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
private :normal_processors_delta
|
|
396
|
+
|
|
397
|
+
# Update the minimum and maximum number of threads in the pool.
|
|
398
|
+
#
|
|
399
|
+
# When +max+ is lowered below the current thread count, idle threads are
|
|
400
|
+
# woken to exit immediately and busy threads exit between work items.
|
|
401
|
+
# When +max+ is raised, threads waiting in +wait_until_not_full+ are woken.
|
|
402
|
+
#
|
|
403
|
+
def update_min_max(min, max)
|
|
404
|
+
with_mutex do
|
|
405
|
+
@min = min
|
|
406
|
+
@max = max
|
|
407
|
+
return if @shutdown
|
|
408
|
+
|
|
409
|
+
max_trims = [@spawned - @min, 0].max
|
|
410
|
+
@trim_requested = max_trims if @trim_requested > max_trims
|
|
411
|
+
|
|
412
|
+
@not_empty.broadcast if over_max_processors?
|
|
413
|
+
@not_full.broadcast if (@spawned - @waiting + @todo.size) < @max
|
|
414
|
+
end
|
|
343
415
|
end
|
|
344
416
|
|
|
345
417
|
# Add +work+ to the todo list for a Thread to pickup and process.
|
|
@@ -367,6 +439,7 @@ module Puma
|
|
|
367
439
|
if @waiting < @todo.size and can_spawn_processor?
|
|
368
440
|
spawn_thread
|
|
369
441
|
end
|
|
442
|
+
@not_full.signal
|
|
370
443
|
end
|
|
371
444
|
end
|
|
372
445
|
|
data/lib/puma/util.rb
CHANGED
|
@@ -17,24 +17,13 @@ module Puma
|
|
|
17
17
|
# Unlike form encoding, escape writes a space as '%20' and unescape
|
|
18
18
|
# keeps a literal '+', so values such as OpenSSL cipher strings
|
|
19
19
|
# ("AES+SHA") survive.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def unescape(s, encoding = Encoding::UTF_8)
|
|
26
|
-
URI.decode_www_form_component(s.gsub('+', '%2B'), encoding)
|
|
27
|
-
end
|
|
28
|
-
else
|
|
29
|
-
def escape(s, encoding = nil)
|
|
30
|
-
URI.encode_www_form_component(s, encoding).gsub('+', '%20')
|
|
31
|
-
end
|
|
20
|
+
def escape(s, encoding = Encoding::UTF_8)
|
|
21
|
+
URI.encode_www_form_component(s, encoding).gsub('+', '%20')
|
|
22
|
+
end
|
|
32
23
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
end
|
|
24
|
+
def unescape(s, encoding = Encoding::UTF_8)
|
|
25
|
+
URI.decode_www_form_component(s.gsub('+', '%2B'), encoding)
|
|
36
26
|
end
|
|
37
|
-
module_function :unescape, :escape
|
|
38
27
|
|
|
39
28
|
DEFAULT_SEP = /[&;] */n
|
|
40
29
|
|
data/lib/puma.rb
CHANGED
|
@@ -6,15 +6,32 @@ require 'tempfile'
|
|
|
6
6
|
require 'uri'
|
|
7
7
|
require 'stringio'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# use require, see https://github.com/puma/puma/pull/2381
|
|
12
|
-
require 'puma/puma_http11'
|
|
13
|
-
|
|
9
|
+
require_relative 'puma/http_parser_error'
|
|
14
10
|
require_relative 'puma/detect'
|
|
15
11
|
require_relative 'puma/json_serialization'
|
|
16
12
|
|
|
17
13
|
module Puma
|
|
14
|
+
# The puma_http11 extension provides `Puma::HttpParser` and `MiniSSL::Engine`.
|
|
15
|
+
# Puma loads without it, and a server then needs a parser class or factory
|
|
16
|
+
# from the `http_parser` option.
|
|
17
|
+
@http11_load_error = begin
|
|
18
|
+
# use require, see https://github.com/puma/puma/pull/2381
|
|
19
|
+
require 'puma/puma_http11'
|
|
20
|
+
nil
|
|
21
|
+
rescue LoadError => e
|
|
22
|
+
e
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Returns the default HTTP parser class from the `puma_http11` extension,
|
|
26
|
+
# or raises `LoadError` (preserving the original cause) if it could not be loaded.
|
|
27
|
+
def self.default_http_parser
|
|
28
|
+
return HttpParser if const_defined?(:HttpParser, false)
|
|
29
|
+
|
|
30
|
+
message = "Puma's puma_http11 extension could not be loaded, so there is no default HTTP parser. " \
|
|
31
|
+
"Reinstall Puma with a compiler, or set the http_parser option."
|
|
32
|
+
message = "#{message} (#{@http11_load_error.message})" if @http11_load_error
|
|
33
|
+
raise LoadError, message, cause: @http11_load_error
|
|
34
|
+
end
|
|
18
35
|
# when Puma is loaded via `Puma::CLI`, all files are loaded via
|
|
19
36
|
# `require_relative`. The below are for non-standard loading
|
|
20
37
|
autoload :Const, "#{__dir__}/puma/const"
|
data/lib/rack/handler/puma.rb
CHANGED
|
@@ -34,11 +34,7 @@ module Puma
|
|
|
34
34
|
|
|
35
35
|
conf = ::Puma::Configuration.new(options, default_options.merge({ events: @events })) do |user_config, file_config, default_config|
|
|
36
36
|
if options.delete(:Verbose)
|
|
37
|
-
|
|
38
|
-
require 'rack/commonlogger' # Rack 1.x
|
|
39
|
-
rescue LoadError
|
|
40
|
-
require 'rack/common_logger' # Rack 2 and later
|
|
41
|
-
end
|
|
37
|
+
require 'rack/common_logger'
|
|
42
38
|
app = ::Rack::CommonLogger.new(app, STDOUT)
|
|
43
39
|
end
|
|
44
40
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: puma
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 8.
|
|
4
|
+
version: 8.2.0.pre1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Evan Phoenix
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-12-01 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: nio4r
|
|
@@ -43,6 +43,7 @@ files:
|
|
|
43
43
|
- bin/puma
|
|
44
44
|
- bin/puma-wild
|
|
45
45
|
- bin/pumactl
|
|
46
|
+
- docs/GLOSSARY.md
|
|
46
47
|
- docs/architecture.md
|
|
47
48
|
- docs/binding.md
|
|
48
49
|
- docs/cluster_mode.md
|
|
@@ -68,6 +69,7 @@ files:
|
|
|
68
69
|
- docs/rails_dev_mode.md
|
|
69
70
|
- docs/restart.md
|
|
70
71
|
- docs/signals.md
|
|
72
|
+
- docs/ssl.md
|
|
71
73
|
- docs/upgrading/5.0-Upgrade.md
|
|
72
74
|
- docs/upgrading/6.0-Upgrade.md
|
|
73
75
|
- docs/upgrading/7.0-Upgrade.md
|
|
@@ -95,6 +97,7 @@ files:
|
|
|
95
97
|
- lib/puma/dsl.rb
|
|
96
98
|
- lib/puma/error_logger.rb
|
|
97
99
|
- lib/puma/events.rb
|
|
100
|
+
- lib/puma/http_parser_error.rb
|
|
98
101
|
- lib/puma/io_buffer.rb
|
|
99
102
|
- lib/puma/jruby_restart.rb
|
|
100
103
|
- lib/puma/json_serialization.rb
|