puma 5.2.1 → 5.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d702fffe078664ed49a411a31910737455c819d6acadd3875c89e00368f68dd8
4
- data.tar.gz: 972f53b07a05363ff839b6f176150bdf4cbc19f7445601ad10f41e9bcaf73af2
3
+ metadata.gz: 472ee56cda171d14d1ba6dee3f83d6b5cce8458e6346d36443295c6aae8ca243
4
+ data.tar.gz: 625953f46071794b66b44974a74a4382015ecef0ce85b629cf7448935d1f15c8
5
5
  SHA512:
6
- metadata.gz: fff3451918f8e34324189c0fa6c161baa1860181920f934541a4db9b5e484d20edae74dd9ac33baa3c14514c75d052cbb5d42539f371bf33cca82e644aa52c57
7
- data.tar.gz: 86c7ba8cb909bedb1dceb259d28677295a71e66b53ed1f1fb6ce324ddab0dbe05c5469aaa120f50f7427cc257d6fa6b6898c7b0346810871f1fceb2ad25bab93
6
+ metadata.gz: b8510e5f6e17815d2d36be57806f70294d4796cf7a63c7c9e76cfc31454f314b46da8ab3a83b2f35436e4ae98a1a138dbb20c9f75fee89a41edeeb5689459ff4
7
+ data.tar.gz: ef268e432c892a993831786227eee70ab3c013b5aaf306538e603a405cbc40457dffd961acfefa98a0fef6117f4b6463634f60fd4a5e111c79f361f7e5ae28e4
data/History.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 5.2.2 / 2021-02-22
2
+
3
+ * Bugfixes
4
+ * Add `#flush` and `#sync` methods to `Puma::NullIO` ([#2553])
5
+ * Restore `sync=true` on `STDOUT` and `STDERR` streams ([#2557])
6
+
1
7
  ## 5.2.1 / 2021-02-05
2
8
 
3
9
  * Bugfixes
@@ -1702,6 +1708,8 @@ be added back in a future date when a java Puma::MiniSSL is added.
1702
1708
  * Bugfixes
1703
1709
  * Your bugfix goes here <Most recent on the top, like GitHub> (#Github Number)
1704
1710
 
1711
+ [#2557]:https://github.com/puma/puma/pull/2557 "PR by @cjlarose, merged 2021-02-22"
1712
+ [#2553]:https://github.com/puma/puma/pull/2553 "PR by @olivierbellone, merged 02-10-22"
1705
1713
  [#2550]:https://github.com/puma/puma/pull/2550 "PR by @MSP-Greg, merged 2021-02-05"
1706
1714
  [#2547]:https://github.com/puma/puma/pull/2547 "PR by @wildmaples, merged 2021-02-03"
1707
1715
  [#2543]:https://github.com/puma/puma/pull/2543 "PR by @MSP-Greg, merged 2021-02-01"
data/docs/architecture.md CHANGED
@@ -4,34 +4,37 @@
4
4
 
5
5
  ![https://bit.ly/2iJuFky](images/puma-general-arch.png)
6
6
 
7
- Puma is a threaded web server, processing requests across a TCP or UNIX socket.
7
+ Puma is a threaded Ruby HTTP application server, processing requests across a TCP or UNIX socket.
8
8
 
9
- Workers accept connections from the socket and a thread in the worker's thread pool processes the client's request.
9
+ Puma processes (there can be one or many) accept connections from the socket via a thread (in the `Reactor` class). The connection, once fully buffered and read, moves in to the `todo` list, where it will be picked up by a free/waiting thread in the threadpool (the `ThreadPool` class).
10
10
 
11
- Clustered mode is shown/discussed here. Single mode is analogous to having a single worker process.
11
+ Puma works in two main modes: cluster and single. In single mode, only one Puma process is booted. In cluster mode, a `master` process is booted, which prepares (and may boot) the application, and then uses the `fork()` system call to create 1 or more `child` processes. These `child` processes all listen to the same socket. The `master` process does not listen to the socket or process requests - its purpose is mostly to manage and listen for UNIX signals and possibly kill or boot `child` processes.
12
12
 
13
- ## Connection pipeline
13
+ We sometimes call `child` processes (or Puma processes in `single` mode) _workers_, and we sometimes call the threads created by Puma's `ThreadPool` _worker threads_.
14
+
15
+ ## How Requests Work
14
16
 
15
17
  ![https://bit.ly/2zwzhEK](images/puma-connection-flow.png)
16
18
 
17
19
  * Upon startup, Puma listens on a TCP or UNIX socket.
18
- * The backlog of this socket is configured (with a default of 1024), determining how many established but unaccepted connections can exist concurrently.
19
- * This socket backlog is distinct from the "backlog" of work as reported by the control server stats. The latter is the number of connections in that worker's "todo" set waiting for a worker thread.
20
- * By default, a single, separate thread is used to receive HTTP requests across the socket.
21
- * When at least one worker thread is available for work, a connection is accepted and placed in this request buffer
22
- * This thread waits for entire HTTP requests to be received over the connection
23
- * The time spent waiting for the HTTP request body to be received is exposed to the Rack app as `env['puma.request_body_wait']` (milliseconds)
24
- * Once received, the connection is pushed into the "todo" set
25
- * Worker threads pop work off the "todo" set for processing
26
- * The thread processes the request via the rack application (which generates the HTTP response)
27
- * The thread writes the response to the connection
28
- * Finally, the thread become available to process another connection in the "todo" set
29
-
30
- ### Disabling `queue_requests`
20
+ * The backlog of this socket is configured (with a default of 1024). This determines the size of the queue for unaccepted connections. Generally, this setting is unimportant and will never be hit in production use. If the backlog is full, the connection will be refused by the operating system.
21
+ * This socket backlog is distinct from the `backlog` of work as reported by `Puma.stats` or the control server. The backlog as reported by Puma is the number of connections in the process' `todo` set waiting for a thread from the `ThreadPool`.
22
+ * By default, a single, separate thread (created by the `Reactor` class) is used to read and buffer requests from the socket.
23
+ * When at least one worker thread is available for work, the reactor thread listens to the socket and accepts a request, if one is waiting.
24
+ * The reactor thread waits for the entire HTTP request to be received.
25
+ * The time spent waiting for the HTTP request body to be received is exposed to the Rack app as `env['puma.request_body_wait']` (milliseconds).
26
+ * Once fully buffered and received, the connection is pushed into the "todo" set.
27
+ * Worker threads pop work off the "todo" set for processing.
28
+ * The worker thread processes the request via `call`ing the configured Rack application. The Rack application generates the HTTP response.
29
+ * The worker thread writes the response to the connection. Note that while Puma buffers requests via a separate thread, it does not use a separate thread for responses.
30
+ * Once done, the thread become available to process another connection in the "todo" set.
31
+
32
+ ### `queue_requests`
31
33
 
32
34
  ![https://bit.ly/2zxCJ1Z](images/puma-connection-flow-no-reactor.png)
33
35
 
34
- The `queue_requests` option is `true` by default, enabling the separate thread used to buffer requests as described above.
36
+ The `queue_requests` option is `true` by default, enabling the separate reactor thread used to buffer requests as described above.
35
37
 
36
38
  If set to `false`, this buffer will not be used for connections while waiting for the request to arrive.
39
+
37
40
  In this mode, when a connection is accepted, it is added to the "todo" queue immediately, and a worker will synchronously do any waiting necessary to read the HTTP request from the socket.
@@ -206,7 +206,8 @@ module Puma
206
206
  :first_data_timeout => Const::FIRST_DATA_TIMEOUT,
207
207
  :raise_exception_on_sigterm => true,
208
208
  :max_fast_inline => Const::MAX_FAST_INLINE,
209
- :io_selector_backend => :auto
209
+ :io_selector_backend => :auto,
210
+ :mutate_stdout_and_stderr_to_sync_on_write => true,
210
211
  }
211
212
  end
212
213
 
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.2.1".freeze
103
+ PUMA_VERSION = VERSION = "5.2.2".freeze
104
104
  CODE_NAME = "Fettisdagsbulle".freeze
105
105
 
106
106
  PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze
data/lib/puma/dsl.rb CHANGED
@@ -888,5 +888,9 @@ module Puma
888
888
  def io_selector_backend(backend)
889
889
  @options[:io_selector_backend] = backend.to_sym
890
890
  end
891
+
892
+ def mutate_stdout_and_stderr_to_sync_on_write(enabled=true)
893
+ @options[:mutate_stdout_and_stderr_to_sync_on_write] = enabled
894
+ end
891
895
  end
892
896
  end
data/lib/puma/null_io.rb CHANGED
@@ -36,6 +36,10 @@ module Puma
36
36
  true
37
37
  end
38
38
 
39
+ def sync
40
+ true
41
+ end
42
+
39
43
  def sync=(v)
40
44
  end
41
45
 
@@ -44,5 +48,9 @@ module Puma
44
48
 
45
49
  def write(*ary)
46
50
  end
51
+
52
+ def flush
53
+ self
54
+ end
47
55
  end
48
56
  end
data/lib/puma/runner.rb CHANGED
@@ -126,6 +126,11 @@ module Puma
126
126
  STDERR.puts "=== puma startup: #{Time.now} ==="
127
127
  STDERR.flush unless STDERR.sync
128
128
  end
129
+
130
+ if @options[:mutate_stdout_and_stderr_to_sync_on_write]
131
+ STDOUT.sync = true
132
+ STDERR.sync = true
133
+ end
129
134
  end
130
135
 
131
136
  def load_and_bind
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.2.1
4
+ version: 5.2.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-02-05 00:00:00.000000000 Z
11
+ date: 2021-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nio4r
@@ -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.2.1
143
+ rubygems_version: 3.2.3
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for