puma 5.3.1-java → 5.3.2-java

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: 2e9bfe6e0d16878b7c08f452189b8b740fffa62ab86c1031a1f7bcff6826fbb2
4
- data.tar.gz: cde6f178316ec5067a254669911999ae7f76d3a71fea25818c555613e648515f
3
+ metadata.gz: 12462a4a37d0a5a4d6e3406bfe4dd7f58b61a3d17c6704408956d11aaaae4f1d
4
+ data.tar.gz: dae78d98babe25b91a16d52b90dd41827048de405d0ace0a78606e03c53880e6
5
5
  SHA512:
6
- metadata.gz: 6f93afa0f71745b4fd8888794fb78d04590fce5d2bcc897bcc69dcad114464cb3111a41782b7a06a1513270fe448ea2a9ee3d207521567b54e22d3815d45ccfd
7
- data.tar.gz: 01c2be5ef8baab6014db28bda79f9d90b9252ec3859a66b1bdefaf2a12dcb9c24b8ca9cacf1e8cd57480e6a32562baa7f0528e14b3d1a8400320de8d3b1194ec
6
+ metadata.gz: 71f319f6476bb37a10f1f21dc143ed738248dfaf42a21e6e9c68b0378a905d664fdf425159b7c40533f78873ffd57bbd60c211c3cabc50f692e7ef1058b06ee9
7
+ data.tar.gz: 4123267b89373e4994e6dace674113796237304009d36e7501f3a3db9149b3b3a519163f73141bf73447bf4165fc5aeaf72b15fc5432abf6904b470e917b3fd9
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
  #
Binary file
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: java
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
  requirement: !ruby/object:Gem::Requirement