puma 4.3.6 → 4.3.8

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: d378ab70a4eac21fe4bf571b95b655d6cbc590b2b91ac323f849986bf8f7ad6c
4
- data.tar.gz: 1b288cc39f5d80119dde26e844490e572b5f1043060060a1a1d70180743123c3
3
+ metadata.gz: 0133cf43153c495af4daa489fd6db234a14fb0d7b72201b71260d4d57dfb1211
4
+ data.tar.gz: a1a369772eaf8e3e0efa2931c4cdfdc1880314540c260d6c01226f4b0fd2a863
5
5
  SHA512:
6
- metadata.gz: b63ddad40bdeae9c86d62af5bf044238e273cbf8e95ff944d7b0a736dd39532dfe3b562a77c97b14f86d8e3f916b7cb94ccdbf898e75c4088d075d20e83744d5
7
- data.tar.gz: abc975210626407c096848540f068a9731ecdc5191327b3ad87355ef4b88b6ac2605ccc7e31ca5398cd787cf9a34efdffc501afe61a2542cc322768af7b26830
6
+ metadata.gz: 6dfe3a8aa4e40676eb2c70822dac050c75f9bf9ec5270626e2b282a5971f323b2661d5792a4d24982e236f378a13ddf8408080e18bf7f4957cfd5971a7d8d034
7
+ data.tar.gz: 95706c08d6b746d82af99474001664b282bf760fbbef14860b5e6897dd4eaedc3f4b49a5da2a1809dcfcf0a23fe5f62baabe5da88c631c8228889c615248fe03
data/History.md CHANGED
@@ -1,8 +1,19 @@
1
+ ## 4.3.8 / 2021-05-11
2
+
3
+ * Security
4
+ * Close keepalive connections after the maximum number of fast inlined requests (#2625)
5
+
6
+ ## 4.3.7 / 2020-11-30
7
+
8
+ * Bugfixes
9
+ * Backport set CONTENT_LENGTH for chunked requests (Originally: #2287, backport: #2496)
10
+
1
11
  ## 4.3.6 / 2020-09-05
2
12
 
3
13
  * Bugfixes
4
14
  * Explicitly include ctype.h to fix compilation warning and build error on macOS with Xcode 12 (#2304)
5
15
  * Don't require json at boot (#2269)
16
+ * Set `CONTENT_LENGTH` for chunked requests (#2287)
6
17
 
7
18
  ## 4.3.4/4.3.5 and 3.12.5/3.12.6 / 2020-05-22
8
19
 
@@ -1,7 +1,7 @@
1
1
  require 'mkmf'
2
2
 
3
3
  dir_config("puma_http11")
4
- if RUBY_PLATFORM[/mingw32/]
4
+ if $mingw && RUBY_VERSION >= '2.4'
5
5
  append_cflags '-D_FORTIFY_SOURCE=2'
6
6
  append_ldflags '-fstack-protector'
7
7
  have_library 'ssp'
data/lib/puma/client.rb CHANGED
@@ -153,7 +153,7 @@ module Puma
153
153
 
154
154
  begin
155
155
  data = @io.read_nonblock(CHUNK_SIZE)
156
- rescue Errno::EAGAIN
156
+ rescue IO::WaitReadable
157
157
  return false
158
158
  rescue SystemCallError, IOError, EOFError
159
159
  raise ConnectionError, "Connection error detected during read"
@@ -351,7 +351,7 @@ module Puma
351
351
 
352
352
  begin
353
353
  chunk = @io.read_nonblock(want)
354
- rescue Errno::EAGAIN
354
+ rescue IO::WaitReadable
355
355
  return false
356
356
  rescue SystemCallError, IOError
357
357
  raise ConnectionError, "Connection error detected during read"
@@ -397,7 +397,10 @@ module Puma
397
397
  raise EOFError
398
398
  end
399
399
 
400
- return true if decode_chunk(chunk)
400
+ if decode_chunk(chunk)
401
+ @env[CONTENT_LENGTH] = @chunked_content_length
402
+ return true
403
+ end
401
404
  end
402
405
  end
403
406
 
@@ -410,19 +413,28 @@ module Puma
410
413
  @body.binmode
411
414
  @tempfile = @body
412
415
 
413
- return decode_chunk(body)
416
+ @chunked_content_length = 0
417
+
418
+ if decode_chunk(body)
419
+ @env[CONTENT_LENGTH] = @chunked_content_length
420
+ return true
421
+ end
422
+ end
423
+
424
+ def write_chunk(str)
425
+ @chunked_content_length += @body.write(str)
414
426
  end
415
427
 
416
428
  def decode_chunk(chunk)
417
429
  if @partial_part_left > 0
418
430
  if @partial_part_left <= chunk.size
419
431
  if @partial_part_left > 2
420
- @body << chunk[0..(@partial_part_left-3)] # skip the \r\n
432
+ write_chunk(chunk[0..(@partial_part_left-3)]) # skip the \r\n
421
433
  end
422
434
  chunk = chunk[@partial_part_left..-1]
423
435
  @partial_part_left = 0
424
436
  else
425
- @body << chunk if @partial_part_left > 2 # don't include the last \r\n
437
+ write_chunk(chunk) if @partial_part_left > 2 # don't include the last \r\n
426
438
  @partial_part_left -= chunk.size
427
439
  return false
428
440
  end
@@ -469,12 +481,12 @@ module Puma
469
481
 
470
482
  case
471
483
  when got == len
472
- @body << part[0..-3] # to skip the ending \r\n
484
+ write_chunk(part[0..-3]) # to skip the ending \r\n
473
485
  when got <= len - 2
474
- @body << part
486
+ write_chunk(part)
475
487
  @partial_part_left = len - part.size
476
488
  when got == len - 1 # edge where we get just \r but not \n
477
- @body << part[0..-2]
489
+ write_chunk(part[0..-2])
478
490
  @partial_part_left = len - part.size
479
491
  end
480
492
  else
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 = "4.3.6".freeze
103
+ PUMA_VERSION = VERSION = "4.3.8".freeze
104
104
  CODE_NAME = "Mysterious Traveller".freeze
105
105
  PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze
106
106
 
data/lib/puma/server.rb CHANGED
@@ -483,15 +483,20 @@ module Puma
483
483
 
484
484
  requests += 1
485
485
 
486
- check_for_more_data = @status == :run
486
+ # Closing keepalive sockets after they've made a reasonable
487
+ # number of requests allows Puma to service many connections
488
+ # fairly, even when the number of concurrent connections exceeds
489
+ # the size of the threadpool. It also allows cluster mode Pumas
490
+ # to keep load evenly distributed across workers, because clients
491
+ # are randomly assigned a new worker when opening a new connection.
492
+ #
493
+ # Previously, Puma would kick connections in this conditional back
494
+ # to the reactor. However, because this causes the todo set to increase
495
+ # in size, the wait_until_full mutex would never unlock, leaving
496
+ # any additional connections unserviced.
497
+ break if requests >= MAX_FAST_INLINE
487
498
 
488
- if requests >= MAX_FAST_INLINE
489
- # This will mean that reset will only try to use the data it already
490
- # has buffered and won't try to read more data. What this means is that
491
- # every client, independent of their request speed, gets treated like a slow
492
- # one once every MAX_FAST_INLINE requests.
493
- check_for_more_data = false
494
- end
499
+ check_for_more_data = @status == :run
495
500
 
496
501
  unless client.reset(check_for_more_data)
497
502
  close_socket = false
@@ -694,7 +699,7 @@ module Puma
694
699
  to_add = {}
695
700
  end
696
701
 
697
- to_add[k.gsub(",", "_")] = v
702
+ to_add[k.tr(",", "_")] = v
698
703
  end
699
704
  end
700
705
 
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: 4.3.6
4
+ version: 4.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Phoenix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-05 00:00:00.000000000 Z
11
+ date: 2021-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nio4r
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  requirements: []
139
- rubygems_version: 3.1.2
139
+ rubygems_version: 3.2.3
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for