puma 5.3.1 → 5.3.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puma might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bcabc9a852bfbed380445b6649ee9e27a2e4741994a27b579e5c4fe94ab6e282
4
- data.tar.gz: 00ae9ffe82807c9419afaaf955af384f2c87b07914ab36e32c060a83df4075e9
3
+ metadata.gz: 2f0d0f5c0a10e36659888cae94e428c91dbe06ba8e3842853b4d6cfd0b103603
4
+ data.tar.gz: 7b375f89a704b081fba4eb08c52aec94563f0c6a888b9544ce0afcefc443b8fa
5
5
  SHA512:
6
- metadata.gz: 6a6d4ca8d9ffeea284756f5cc6418b0d6649e360ab5b76bec8db8a6bd6d5cf059957725f3ac50949fd15bc1e54f31c6f50b1b5073cef6814dfca042d84cc04e6
7
- data.tar.gz: f5ad303fd4d4d3256fa0b20a0d608c2cfdea87901c8c56407420078cac5cd69591a686d12153865855532d0702122d34c80bf60ae4aed1f5ec081d20d3414f7e
6
+ metadata.gz: 14a0bde86f109197089905694c259d2382d86000ab877cb8eaf44c593866afdedad173d1c7c9eb1efe48a714ee33f6b5e4c3c32fe420d3298ab3511c9fae0a7a
7
+ data.tar.gz: a31d4feee8e6a36c27d1037ad91cc279c294505ecbb143c3a005f7d0817031c9b80cef465b5800c6c6075f16f587e43fa98de8dd2b99fe92996c9c9fba36ea70
data/History.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 5.3.2 / 2021-05-21
2
+
3
+ * Bugfixes
4
+ * Gracefully handle Rack not accepting CLI options (#2630, #2626)
5
+ * Fix sigterm misbehavior (#2629)
6
+ * Improvements to keepalive-connection shedding (#2628)
7
+
1
8
  ## 5.3.1 / 2021-05-11
2
9
 
3
10
  * Security
data/lib/puma/binder.rb CHANGED
@@ -163,7 +163,7 @@ module Puma
163
163
  ios_len = @ios.length
164
164
  params = Util.parse_query uri.query
165
165
 
166
- opt = params.key?('low_latency')
166
+ opt = params.key?('low_latency') && params['low_latency'] != 'false'
167
167
  bak = params.fetch('backlog', 1024).to_i
168
168
 
169
169
  io = add_tcp_listener uri.host, uri.port, opt, bak
data/lib/puma/client.rb CHANGED
@@ -69,6 +69,7 @@ module Puma
69
69
  @hijacked = false
70
70
 
71
71
  @peerip = nil
72
+ @listener = nil
72
73
  @remote_addr_header = nil
73
74
 
74
75
  @body_remain = 0
@@ -81,7 +82,7 @@ module Puma
81
82
 
82
83
  attr_writer :peerip
83
84
 
84
- attr_accessor :remote_addr_header
85
+ attr_accessor :remote_addr_header, :listener
85
86
 
86
87
  def_delegators :@io, :closed?
87
88
 
@@ -33,7 +33,7 @@ module Puma
33
33
  Signal.trap "SIGINT", "IGNORE"
34
34
  Signal.trap "SIGCHLD", "DEFAULT"
35
35
 
36
- Thread.new do
36
+ Thread.new do
37
37
  Puma.set_thread_name "worker check pipe"
38
38
  IO.select [@check_pipe]
39
39
  log "! Detected parent died, dying"
@@ -54,7 +54,14 @@ module Puma
54
54
  # things in shape before booting the app.
55
55
  @launcher.config.run_hooks :before_worker_boot, index, @launcher.events
56
56
 
57
+ begin
57
58
  server = @server ||= start_server
59
+ rescue Exception => e
60
+ log "! Unable to start worker"
61
+ log e.backtrace[0]
62
+ exit 1
63
+ end
64
+
58
65
  restart_server = Queue.new << true << false
59
66
 
60
67
  fork_worker = @options[:fork_worker] && index == 0
@@ -343,6 +343,8 @@ module Puma
343
343
  raise "Missing rackup file '#{rackup}'" unless File.exist?(rackup)
344
344
 
345
345
  rack_app, rack_options = rack_builder.parse_file(rackup)
346
+ rack_options = rack_options || {}
347
+
346
348
  @options.file_options.merge!(rack_options)
347
349
 
348
350
  config_ru_binds = []
data/lib/puma/const.rb CHANGED
@@ -100,7 +100,7 @@ module Puma
100
100
  # too taxing on performance.
101
101
  module Const
102
102
 
103
- PUMA_VERSION = VERSION = "5.3.1".freeze
103
+ PUMA_VERSION = VERSION = "5.3.2".freeze
104
104
  CODE_NAME = "Sweetnighter".freeze
105
105
 
106
106
  PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze
data/lib/puma/dsl.rb CHANGED
@@ -201,7 +201,7 @@ module Puma
201
201
  # * Set the socket backlog depth with +backlog+, default is 1024.
202
202
  # * Set up an SSL certificate with +key+ & +cert+.
203
203
  # * Set whether to optimize for low latency instead of throughput with
204
- # +low_latency+, default is to optimize for low latency. This is done
204
+ # +low_latency+, default is to not optimize for low latency. This is done
205
205
  # via +Socket::TCP_NODELAY+.
206
206
  # * Set socket permissions with +umask+.
207
207
  #
data/lib/puma/request.rb CHANGED
@@ -26,9 +26,10 @@ module Puma
26
26
  # Finally, it'll return +true+ on keep-alive connections.
27
27
  # @param client [Puma::Client]
28
28
  # @param lines [Puma::IOBuffer]
29
+ # @param requests [Integer]
29
30
  # @return [Boolean,:async]
30
31
  #
31
- def handle_request(client, lines)
32
+ def handle_request(client, lines, requests)
32
33
  env = client.env
33
34
  io = client.io # io may be a MiniSSL::Socket
34
35
 
@@ -110,7 +111,7 @@ module Puma
110
111
 
111
112
  cork_socket io
112
113
 
113
- str_headers(env, status, headers, res_info, lines)
114
+ str_headers(env, status, headers, res_info, lines, requests, client)
114
115
 
115
116
  line_ending = LINE_END
116
117
 
@@ -367,9 +368,11 @@ module Puma
367
368
  # @param headers [Hash] the headers returned by the Rack application
368
369
  # @param res_info [Hash] used to pass info between this method and #handle_request
369
370
  # @param lines [Puma::IOBuffer] modified inn place
371
+ # @param requests [Integer] number of inline requests handled
372
+ # @param client [Puma::Client]
370
373
  # @version 5.0.3
371
374
  #
372
- def str_headers(env, status, headers, res_info, lines)
375
+ def str_headers(env, status, headers, res_info, lines, requests, client)
373
376
  line_ending = LINE_END
374
377
  colon = COLON
375
378
 
@@ -410,6 +413,14 @@ module Puma
410
413
  # if running without request queueing
411
414
  res_info[:keep_alive] &&= @queue_requests
412
415
 
416
+ # Close the connection after a reasonable number of inline requests
417
+ # if the server is at capacity and the listener has a new connection ready.
418
+ # This allows Puma to service connections fairly when the number
419
+ # of concurrent connections exceeds the size of the threadpool.
420
+ res_info[:keep_alive] &&= requests < @max_fast_inline ||
421
+ @thread_pool.busy_threads < @max_threads ||
422
+ !IO.select([client.listener], nil, nil, 0)
423
+
413
424
  res_info[:response_hijack] = nil
414
425
 
415
426
  headers.each do |k, vs|
data/lib/puma/server.rb CHANGED
@@ -341,6 +341,7 @@ module Puma
341
341
  end
342
342
  drain += 1 if shutting_down?
343
343
  client = Client.new io, @binder.env(sock)
344
+ client.listener = sock
344
345
  if remote_addr_value
345
346
  client.peerip = remote_addr_value
346
347
  elsif remote_addr_header
@@ -434,7 +435,7 @@ module Puma
434
435
 
435
436
  while true
436
437
  @requests_count += 1
437
- case handle_request(client, buffer)
438
+ case handle_request(client, buffer, requests + 1)
438
439
  when false
439
440
  break
440
441
  when :async
@@ -447,23 +448,17 @@ module Puma
447
448
 
448
449
  requests += 1
449
450
 
450
- # Closing keepalive sockets after they've made a reasonable
451
- # number of requests allows Puma to service many connections
452
- # fairly, even when the number of concurrent connections exceeds
453
- # the size of the threadpool. It also allows cluster mode Pumas
454
- # to keep load evenly distributed across workers, because clients
455
- # are randomly assigned a new worker when opening a new connection.
456
- #
457
- # Previously, Puma would kick connections in this conditional back
458
- # to the reactor. However, because this causes the todo set to increase
459
- # in size, the wait_until_full mutex would never unlock, leaving
460
- # any additional connections unserviced.
461
- break if requests >= @max_fast_inline
462
-
463
- check_for_more_data = @status == :run
451
+ # As an optimization, try to read the next request from the
452
+ # socket for a short time before returning to the reactor.
453
+ fast_check = @status == :run
454
+
455
+ # Always pass the client back to the reactor after a reasonable
456
+ # number of inline requests if there are other requests pending.
457
+ fast_check = false if requests >= @max_fast_inline &&
458
+ @thread_pool.backlog > 0
464
459
 
465
460
  next_request_ready = with_force_shutdown(client) do
466
- client.reset(check_for_more_data)
461
+ client.reset(fast_check)
467
462
  end
468
463
 
469
464
  unless next_request_ready
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.3.1
4
+ version: 5.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Phoenix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-11 00:00:00.000000000 Z
11
+ date: 2021-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nio4r