Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package rubygem-puma for openSUSE:Factory checked in at 2021-12-22 20:18:05 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-puma (Old) and /work/SRC/openSUSE:Factory/.rubygem-puma.new.2520 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-puma" Wed Dec 22 20:18:05 2021 rev:48 rq:942023 version:5.5.2 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-puma/rubygem-puma.changes 2021-10-11 15:32:32.406933741 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-puma.new.2520/rubygem-puma.changes 2021-12-22 20:19:09.091877561 +0100 @@ -1,0 +2,7 @@ +Tue Dec 21 00:24:34 UTC 2021 - Marcus Rueckert <mrueck...@suse.de> + +- Update to version 5.5.2 + https://github.com/puma/puma/security/advisories/GHSA-48w2-rm65-62xx + Re-allows UTF-8 in HTTP header values + +------------------------------------------------------------------- Old: ---- puma-5.5.0.gem New: ---- puma-5.5.2.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-puma.spec ++++++ --- /var/tmp/diff_new_pack.8ACqgN/_old 2021-12-22 20:19:09.491877750 +0100 +++ /var/tmp/diff_new_pack.8ACqgN/_new 2021-12-22 20:19:09.495877751 +0100 @@ -24,7 +24,7 @@ # Name: rubygem-puma -Version: 5.5.0 +Version: 5.5.2 Release: 0 %define mod_name puma %define mod_full_name %{mod_name}-%{version} ++++++ puma-5.5.0.gem -> puma-5.5.2.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/History.md new/History.md --- old/History.md 2021-09-19 22:09:23.000000000 +0200 +++ new/History.md 2021-10-13 01:07:08.000000000 +0200 @@ -1,3 +1,13 @@ +## 5.5.2 / 2021-10-12 + +* Bugfixes + * Allow UTF-8 in HTTP header values + +## 5.5.1 / 2021-10-12 + +* Security + * Do not allow LF as a line ending in a header (CVE-2021-41136) + ## 5.5.0 / 2021-09-19 * Features @@ -251,6 +261,11 @@ * Support parallel tests in verbose progress reporting ([#2223]) * Refactor error handling in server accept loop ([#2239]) +## 4.3.9 / 2021-10-12 + +* Security + * Do not allow LF as a line ending in a header (CVE-2021-41136) + ## 4.3.8 / 2021-05-11 * Security diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2021-09-19 22:09:23.000000000 +0200 +++ new/README.md 2021-10-13 01:07:08.000000000 +0200 @@ -187,21 +187,38 @@ ``` $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert' ``` -#### Self-signed SSL certificates (via _localhost_ gem, for development use): +#### Self-signed SSL certificates (via the [`localhost`] gem, for development use): -Puma supports [localhost](https://github.com/socketry/localhost) gem for self-signed certificates. This is particularly useful if you want to use Puma with SSL locally, and self-signed certificates will work for your use-case. Currently, `localhost-authority` can be used only in MRI. To use [localhost](https://github.com/socketry/localhost), you have to `require "localhost/authority"`: +Puma supports the [`localhost`] gem for self-signed certificates. This is particularly useful if you want to use Puma with SSL locally, and self-signed certificates will work for your use-case. Currently, the integration can only be used in MRI. + +Puma automatically configures SSL when the [`localhost`] gem is loaded in a `development` environment: ```ruby -# config.ru +# Add the gem to your Gemfile +group(:development) do + gem 'localhost' +end + +# And require it implicitly using bundler +require "bundler" +Bundler.require(:default, ENV["RACK_ENV"].to_sym) + +# Alternatively, you can require the gem in config.ru: require './app' -require 'localhost/authority' +require 'localhost' run Sinatra::Application +``` -... +Additionally, Puma must be listening to an SSL socket: +```shell $ puma -b 'ssl://localhost:9292' config.ru + +# The following options allow you to reach Puma over HTTP as well: +$ puma -b ssl://localhost:9292 -b tcp://localhost:9393 config.ru ``` +[`localhost`]: https://github.com/socketry/localhost #### Controlling SSL Cipher Suites @@ -270,7 +287,7 @@ $ puma -C /path/to/config ``` -If no configuration file is specified, Puma will look for a configuration file at `config/puma.rb`. If an environment is specified, either via the `-e` and `--environment` flags, or through the `RACK_ENV` or the `RAILS_ENV` environment variables, Puma first looks for configuration at `config/puma/<environment_name>.rb`, and then falls back to `config/puma.rb`. +If no configuration file is specified, Puma will look for a configuration file at `config/puma.rb`. If an environment is specified (via the `--environment` flag or through the `APP_ENV`, `RACK_ENV`, or `RAILS_ENV` environment variables) Puma looks for a configuration file at `config/puma/<environment_name>.rb` and then falls back to `config/puma.rb`. If you want to prevent Puma from looking for a configuration file in those locations, include the `--no-config` flag: Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/docs/architecture.md new/docs/architecture.md --- old/docs/architecture.md 2021-09-19 22:09:23.000000000 +0200 +++ new/docs/architecture.md 2021-10-13 01:07:08.000000000 +0200 @@ -4,38 +4,71 @@  -Puma is a threaded Ruby HTTP application server, processing requests across a TCP or UNIX socket. +Puma is a threaded Ruby HTTP application server processing requests across a TCP +and/or UNIX socket. -Puma processes (there can be one or many) accept connections from the socket via a thread (in the [`Reactor`](../lib/puma/reactor.rb) 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`](../lib/puma/thread_pool.rb) class). - -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. - -We sometimes call `child` processes (or Puma processes in `single` mode) _workers_, and we sometimes call the threads created by Puma's [`ThreadPool`](../lib/puma/thread_pool.rb) _worker threads_. +Puma processes (there can be one or many) accept connections from the socket via +a thread (in the [`Reactor`](../lib/puma/reactor.rb) class). The connection, +once fully buffered and read, moves into the `todo` list, where an available +thread will pick it up (in the [`ThreadPool`](../lib/puma/thread_pool.rb) +class). + +Puma works in two main modes: cluster and single. In single mode, only one Puma +process boots. In cluster mode, a `master` process is booted, which prepares +(and may boot) the application and then uses the `fork()` system call to create +one 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 primarily to manage and listen for UNIX signals and possibly kill +or boot `child` processes. + +We sometimes call `child` processes (or Puma processes in `single` mode) +_workers_, and we sometimes call the threads created by Puma's +[`ThreadPool`](../lib/puma/thread_pool.rb) _worker threads_. ## How Requests Work  * Upon startup, Puma listens on a TCP or UNIX socket. - * 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. - * 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`](../lib/puma/thread_pool.rb). -* By default, a single, separate thread (created by the [`Reactor`](../lib/puma/reactor.rb) class) is used to read and buffer requests from the socket. - * 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. + * The backlog of this socket is configured (with a default of 1024). The + backlog determines the size of the queue for unaccepted connections. + Generally, you'll never hit the backlog cap in production. If the backlog is + full, the operating system refuses new connections. + * This socket backlog is distinct from the `backlog` of work as reported by + `Puma.stats` or the control server. The backlog that `Puma.stats` refers to + represents the number of connections in the process' `todo` set waiting for + a thread from the [`ThreadPool`](../lib/puma/thread_pool.rb). +* By default, a single, separate thread (created by the + [`Reactor`](../lib/puma/reactor.rb) class) reads and buffers requests from the + socket. + * 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). * The reactor thread waits for the entire HTTP request to be received. - * 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). - * Once fully buffered and received, the connection is pushed into the "todo" set. + * Puma exposes the time spent waiting for the HTTP request body to be + received to the Rack app as `env['puma.request_body_wait']` + (milliseconds). + * Once fully buffered and received, the connection is pushed into the "todo" + set. * Worker threads pop work off the "todo" set for processing. - * The worker thread processes the request via `call`ing the configured Rack application. The Rack application generates the HTTP response. - * 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. - * Once done, the thread become available to process another connection in the "todo" set. + * The worker thread processes the request via `call`ing the configured Rack + application. The Rack application generates the HTTP response. + * The worker thread writes the response to the connection. While Puma buffers + requests via a separate thread, it does not use a separate thread for + responses. + * Once done, the thread becomes available to process another connection in the + "todo" set. ### `queue_requests`  -The `queue_requests` option is `true` by default, enabling the separate reactor thread used to buffer requests as described above. +The `queue_requests` option is `true` by default, enabling the separate reactor +thread used to buffer requests as described above. -If set to `false`, this buffer will not be used for connections while waiting for the request to arrive. +If set to `false`, this buffer will not be used for connections while waiting +for the request to arrive. -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. +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. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/docs/compile_options.md new/docs/compile_options.md --- old/docs/compile_options.md 2021-09-19 22:09:23.000000000 +0200 +++ new/docs/compile_options.md 2021-10-13 01:07:08.000000000 +0200 @@ -1,10 +1,12 @@ # Compile Options -There are some `cflags` provided to change Puma's default configuration for its C extension. +There are some `cflags` provided to change Puma's default configuration for its +C extension. ## Query String, `PUMA_QUERY_STRING_MAX_LENGTH` -By default, the max length of `QUERY_STRING` is `1024 * 10`. But you may want to adjust it to allow accept larger queries in GET requests. +By default, the max length of `QUERY_STRING` is `1024 * 10`. But you may want to +adjust it to accept longer queries in GET requests. For manual install, pass the `PUMA_QUERY_STRING_MAX_LENGTH` option like this: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/docs/deployment.md new/docs/deployment.md --- old/docs/deployment.md 2021-09-19 22:09:23.000000000 +0200 +++ new/docs/deployment.md 2021-10-13 01:07:08.000000000 +0200 @@ -1,35 +1,32 @@ # Deployment engineering for Puma -Puma is software that is expected to be run in a deployed environment eventually. -You can certainly use it as your dev server only, but most people look to use -it in their production deployments as well. +Puma expects to be run in a deployed environment eventually. You can use it as +your development server, but most people use it in their production deployments. -To that end, this is meant to serve as a foundation of wisdom how to do that -in a way that increases happiness and decreases downtime. +To that end, this document serves as a foundation of wisdom regarding deploying +Puma to production while increasing happiness and decreasing downtime. ## Specifying Puma -Most people want to do this by putting `gem "puma"` into their Gemfile, so we'll -go ahead and assume that. Go add it now... we'll wait. +Most people will specify Puma by including `gem "puma"` in a Gemfile, so we'll +assume this is how you're using Puma. -Welcome back! +## Single vs. Cluster mode -## Single vs Cluster mode +Initially, Puma was conceived as a thread-only web server, but support for +processes was added in version 2. -Puma was originally conceived as a thread-only web server, but grew the ability to -also use processes in version 2. +To run `puma` in single mode (i.e., as a development environment), set the +number of workers to 0; anything higher will run in cluster mode. -To run `puma` in single mode (e.g. for a development environment) you will need to -set the number of workers to 0, anything above will run in cluster mode. - -Here are some rules of thumb for cluster mode: +Here are some tips for cluster mode: ### MRI -* Use cluster mode and set the number of workers to 1.5x the number of cpu cores - in the machine, minimum 2. -* Set the number of threads to desired concurrent requests / number of workers. - Puma defaults to 5 and that's a decent number. +* Use cluster mode and set the number of workers to 1.5x the number of CPU cores + in the machine, starting from a minimum of 2. +* Set the number of threads to desired concurrent requests/number of workers. + Puma defaults to 5, and that's a decent number. #### Migrating from Unicorn @@ -37,7 +34,7 @@ * Set workers to half the number of unicorn workers you're using * Set threads to 2 * Enjoy 50% memory savings -* As you grow more confident in the thread safety of your app, you can tune the +* As you grow more confident in the thread-safety of your app, you can tune the workers down and the threads up. #### Ubuntu / Systemd (Systemctl) Installation @@ -48,54 +45,58 @@ **How do you know if you've got enough (or too many workers)?** -A good question. Due to MRI's GIL, only one thread can be executing Ruby code at a time. -But since so many apps are waiting on IO from DBs, etc., they can utilize threads -to make better use of the process. - -The rule of thumb is you never want processes that are pegged all the time. This -means that there is more work to do than the process can get through. On the other -hand, if you have processes that sit around doing nothing, then they're just eating -up resources. +A good question. Due to MRI's GIL, only one thread can be executing Ruby code at +a time. But since so many apps are waiting on IO from DBs, etc., they can +utilize threads to use the process more efficiently. + +Generally, you never want processes that are pegged all the time. That can mean +there is more work to do than the process can get through. On the other hand, if +you have processes that sit around doing nothing, then they're just eating up +resources. -Watch your CPU utilization over time and aim for about 70% on average. This means -you've got capacity still but aren't starving threads. +Watch your CPU utilization over time and aim for about 70% on average. 70% +utilization means you've got capacity still but aren't starving threads. **Measuring utilization** -Using a timestamp header from an upstream proxy server (eg. nginx or haproxy), it's -possible to get an indication of how long requests have been waiting for a Puma -thread to become available. +Using a timestamp header from an upstream proxy server (e.g., `nginx` or +`haproxy`) makes it possible to indicate how long requests have been waiting for +a Puma thread to become available. * Have your upstream proxy set a header with the time it received the request: * nginx: `proxy_set_header X-Request-Start "${msec}";` - * haproxy >= 1.9: `http-request set-header X-Request-Start t=%[date()]%[date_us()]` + * haproxy >= 1.9: `http-request set-header X-Request-Start + t=%[date()]%[date_us()]` * haproxy < 1.9: `http-request set-header X-Request-Start t=%[date()]` -* In your Rack middleware, determine the amount of time elapsed since `X-Request-Start`. -* To improve accuracy, you will want to subtract time spent waiting for slow clients: - * `env['puma.request_body_wait']` contains the number of milliseconds Puma spent - waiting for the client to send the request body. - * haproxy: `%Th` (TLS handshake time) and `%Ti` (idle time before request) can - can also be added as headers. +* In your Rack middleware, determine the amount of time elapsed since + `X-Request-Start`. +* To improve accuracy, you will want to subtract time spent waiting for slow + clients: + * `env['puma.request_body_wait']` contains the number of milliseconds Puma + spent waiting for the client to send the request body. + * haproxy: `%Th` (TLS handshake time) and `%Ti` (idle time before request) + can can also be added as headers. ## Should I daemonize? -Daemonization was removed in Puma 5.0. For alternatives, continue reading. +The Puma 5.0 release removed daemonization. For older versions and alternatives, +continue reading. -I prefer to not daemonize my servers and use something like `runit` or `systemd` to -monitor them as child processes. This gives them fast response to crashes and +I prefer not to daemonize my servers and use something like `runit` or `systemd` +to monitor them as child processes. This gives them fast response to crashes and makes it easy to figure out what is going on. Additionally, unlike `unicorn`, -puma does not require daemonization to do zero-downtime restarts. +Puma does not require daemonization to do zero-downtime restarts. -I see people using daemonization because they start puma directly via capistrano -task and thus want it to live on past the `cap deploy`. To these people I say: -You need to be using a process monitor. Nothing is making sure puma stays up in -this scenario! You're just waiting for something weird to happen, puma to die, -and to get paged at 3am. Do yourself a favor, at least the process monitoring -your OS comes with, be it `sysvinit` or `systemd`. Or branch out -and use `runit` or hell, even `monit`. +I see people using daemonization because they start puma directly via Capistrano +task and thus want it to live on past the `cap deploy`. To these people, I say: +You need to be using a process monitor. Nothing is making sure Puma stays up in +this scenario! You're just waiting for something weird to happen, Puma to die, +and to get paged at 3 AM. Do yourself a favor, at least the process monitoring +your OS comes with, be it `sysvinit` or `systemd`. Or branch out and use `runit` +or hell, even `monit`. ## Restarting You probably will want to deploy some new code at some point, and you'd like -puma to start running that new code. There are a few options for restarting -puma, described separately in our [restart documentation](restart.md). +Puma to start running that new code. There are a few options for restarting +Puma, described separately in our [restart documentation](restart.md). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/docs/plugins.md new/docs/plugins.md --- old/docs/plugins.md 2021-09-19 22:09:23.000000000 +0200 +++ new/docs/plugins.md 2021-10-13 01:07:08.000000000 +0200 @@ -3,22 +3,22 @@ Puma 3.0 added support for plugins that can augment configuration and service operations. -2 canonical plugins to look to aid in development of further plugins: +There are two canonical plugins to aid in the development of new plugins: * [tmp\_restart](https://github.com/puma/puma/blob/master/lib/puma/plugin/tmp_restart.rb): Restarts the server if the file `tmp/restart.txt` is touched * [heroku](https://github.com/puma/puma-heroku/blob/master/lib/puma/plugin/heroku.rb): - Packages up the default configuration used by puma on Heroku (being sunset with the release of Puma 5.0) + Packages up the default configuration used by Puma on Heroku (being sunset + with the release of Puma 5.0) -Plugins are activated in a puma configuration file (such as `config/puma.rb'`) +Plugins are activated in a Puma configuration file (such as `config/puma.rb'`) by adding `plugin "name"`, such as `plugin "heroku"`. -Plugins are activated based simply on path requirements so, activating the -`heroku` plugin will simply be doing `require "puma/plugin/heroku"`. This -allows gems to provide multiple plugins (as well as unrelated gems to provide -puma plugins). +Plugins are activated based on path requirements so, activating the `heroku` +plugin is much like `require "puma/plugin/heroku"`. This allows gems to provide +multiple plugins (as well as unrelated gems to provide Puma plugins). -The `tmp_restart` plugin is bundled with puma, so it can always be used. +The `tmp_restart` plugin comes with Puma, so it is always available. To use the `heroku` plugin, add `puma-heroku` to your Gemfile or install it. @@ -26,13 +26,13 @@ ## Server-wide hooks -Plugins can use a couple of hooks at server level: `start` and `config`. +Plugins can use a couple of hooks at the server level: `start` and `config`. -`start` runs when the server has started and allows the plugin to start other -functionality to augment puma. +`start` runs when the server has started and allows the plugin to initiate other +functionality to augment Puma. -`config` runs when the server is being configured and is passed a `Puma::DSL` -object that can be used to add additional configuration. +`config` runs when the server is being configured and receives a `Puma::DSL` +object that is useful for additional configuration. -Any public methods in [`Puma::Plugin`](../lib/puma/plugin.rb) are the public API that any plugin may -use. +Public methods in [`Puma::Plugin`](../lib/puma/plugin.rb) are treated as a +public API for plugins. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/docs/rails_dev_mode.md new/docs/rails_dev_mode.md --- old/docs/rails_dev_mode.md 2021-09-19 22:09:23.000000000 +0200 +++ new/docs/rails_dev_mode.md 2021-10-13 01:07:08.000000000 +0200 @@ -2,16 +2,15 @@ ## "Loopback requests" -Be cautious of "loopback requests", where a Rails application executes a request to a server that in turn, results in another request back to the same Rails application before the first request is completed. Having a loopback request will trigger [Rails' load interlock](https://guides.rubyonrails.org/threading_and_code_execution.html#load-interlock) mechanism. The load interlock mechanism prevents a thread from using Rails autoloading mechanism to load constants while the application code is still running inside another thread. +Be cautious of "loopback requests," where a Rails application executes a request to a server that, in turn, results in another request back to the same Rails application before the first request completes. Having a loopback request will trigger [Rails' load interlock](https://guides.rubyonrails.org/threading_and_code_execution.html#load-interlock) mechanism. The load interlock mechanism prevents a thread from using Rails autoloading mechanism to load constants while the application code is still running inside another thread. This issue only occurs in the development environment as Rails' load interlock is not used in production environments. Although we're not sure, we believe this issue may not occur with the new `zeitwerk` code loader. ### Solutions - #### 1. Bypass Rails' load interlock with `.permit_concurrent_loads` -Wrap the first request inside a block that will allow concurrent loads, [`ActiveSupport::Dependencies.interlock.permit_concurrent_loads`](https://guides.rubyonrails.org/threading_and_code_execution.html#permit-concurrent-loads). Anything wrapped inside the `.permit_concurrent_loads` block will bypass the load interlock mechanism, allowing new threads to access the Rails environment and boot properly. +Wrap the first request inside a block that will allow concurrent loads: [`ActiveSupport::Dependencies.interlock.permit_concurrent_loads`](https://guides.rubyonrails.org/threading_and_code_execution.html#permit-concurrent-loads). Anything wrapped inside the `.permit_concurrent_loads` block will bypass the load interlock mechanism, allowing new threads to access the Rails environment and boot properly. ###### Example diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/docs/restart.md new/docs/restart.md --- old/docs/restart.md 2021-09-19 22:09:23.000000000 +0200 +++ new/docs/restart.md 2021-10-13 01:07:08.000000000 +0200 @@ -1,8 +1,8 @@ -Puma provides three distinct kinds of restart operations, each for different use cases. Hot restarts and phased restarts are described here. The third kind of restart operation is called "refork" and is described in the documentation for [`fork_worker`](fork_worker.md). +Puma provides three distinct kinds of restart operations, each for different use cases. This document describes "hot restarts" and "phased restarts." The third kind of restart operation is called "refork" and is described in the documentation for [`fork_worker`](fork_worker.md). ## Hot restart -To perform a "hot" restart, Puma performs an `exec` operation to start the process up again, so no memory is shared between the old process and the new process. As a result, it is safe to issue a restart any place where you would manually stop Puma and start it again. In particular, it is safe to upgrade Puma itself using a hot restart. +To perform a "hot" restart, Puma performs an `exec` operation to start the process up again, so no memory is shared between the old process and the new process. As a result, it is safe to issue a restart at any place where you would manually stop Puma and start it again. In particular, it is safe to upgrade Puma itself using a hot restart. If the new process is unable to load, it will simply exit. You should therefore run Puma under a process monitor when using it in production. @@ -16,14 +16,14 @@ ### Supported configurations -* Works in cluster mode and in single mode +* Works in cluster mode and single mode * Supported on all platforms ### Client experience -* All platforms: for clients with an in-flight request, those clients will be served responses before the connection is closed gracefully. Puma gracefully disconnects any idle HTTP persistent connections before restarting. +* All platforms: clients with an in-flight request are served responses before the connection is closed gracefully. Puma gracefully disconnects any idle HTTP persistent connections before restarting. * On MRI or TruffleRuby on Linux and BSD: Clients who connect just before the server restarts may experience increased latency while the server stops and starts again, but their connections will not be closed prematurely. -* On Windows and on JRuby: Clients who connect just before a restart may experience "connection reset" errors. +* On Windows and JRuby: Clients who connect just before a restart may experience "connection reset" errors. ### Additional notes @@ -32,7 +32,7 @@ ## Phased restart -Phased restarts replace all running workers in a Puma cluster. This is a useful way to gracefully upgrade the application that Puma is serving. A phased restart works by first killing an old worker, then starting a new worker, waiting until the new worker has successfully started before proceeding to the next worker. This process continues until all workers have been replaced. The master process is not restarted. +Phased restarts replace all running workers in a Puma cluster. This is a useful way to upgrade the application that Puma is serving gracefully. A phased restart works by first killing an old worker, then starting a new worker, waiting until the new worker has successfully started before proceeding to the next worker. This process continues until all workers are replaced. The master process is not restarted. ### How-to diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/docs/signals.md new/docs/signals.md --- old/docs/signals.md 2021-09-19 22:09:23.000000000 +0200 +++ new/docs/signals.md 2021-10-13 01:07:08.000000000 +0200 @@ -1,8 +1,8 @@ -The [unix signal](https://en.wikipedia.org/wiki/Unix_signal) is a method of sending messages between [processes](https://en.wikipedia.org/wiki/Process_(computing)). When a signal is sent, the operating system interrupts the target process's normal flow of execution. There are standard signals that are used to stop a process but there are also custom signals that can be used for other purposes. This document is an attempt to list all supported signals that Puma will respond to. In general, signals need only be sent to the master process of a cluster. +The [unix signal](https://en.wikipedia.org/wiki/Unix_signal) is a method of sending messages between [processes](https://en.wikipedia.org/wiki/Process_(computing)). When a signal is sent, the operating system interrupts the target process's normal flow of execution. There are standard signals that are used to stop a process, but there are also custom signals that can be used for other purposes. This document is an attempt to list all supported signals that Puma will respond to. In general, signals need only be sent to the master process of a cluster. ## Sending Signals -If you are new to signals it can be useful to see how they can be used. When a process is created in a *nix like operating system it will have a [PID - or process identifier](https://en.wikipedia.org/wiki/Process_identifier) that can be used to send signals to the process. For demonstration we will create an infinitely running process by tailing a file: +If you are new to signals, it can be helpful to see how they are used. When a process starts in a *nix-like operating system, it will have a [PID - or process identifier](https://en.wikipedia.org/wiki/Process_identifier) that can be used to send signals to the process. For demonstration, we will create an infinitely running process by tailing a file: ```sh $ echo "foo" >> my.log @@ -10,7 +10,7 @@ > pid = Process.spawn 'tail -f my.log' ``` -From here we can see that the tail process is running by using the `ps` command: +From here, we can see that the tail process is running by using the `ps` command: ```sh $ ps aux | grep tail @@ -27,7 +27,7 @@ Process.kill("TERM", pid) ``` -Now you will see via `ps` that there is no more `tail` process. Sometimes when referring to signals the `SIG` prefix will be used for instance `SIGTERM` is equivalent to sending `TERM` via `Process.kill`. +Now you will see via `ps` that there is no more `tail` process. Sometimes when referring to signals, the `SIG` prefix will be used. For example, `SIGTERM` is equivalent to sending `TERM` via `Process.kill`. ## Puma Signals @@ -35,13 +35,13 @@ - `TTIN` increment the worker count by 1 - `TTOU` decrement the worker count by 1 -- `TERM` send `TERM` to worker. Worker will attempt to finish then exit. -- `USR2` restart workers. This also reloads puma configuration file, if there is one. -- `USR1` restart workers in phases, a rolling restart. This will not reload configuration file. -- `HUP ` reopen log files defined in stdout_redirect configuration parameter. If there is no stdout_redirect option provided it will behave like `INT` -- `INT ` equivalent of sending Ctrl-C to cluster. Will attempt to finish then exit. +- `TERM` send `TERM` to worker. The worker will attempt to finish then exit. +- `USR2` restart workers. This also reloads the Puma configuration file, if there is one. +- `USR1` restart workers in phases, a rolling restart. This will not reload the configuration file. +- `HUP ` reopen log files defined in stdout_redirect configuration parameter. If there is no stdout_redirect option provided, it will behave like `INT` +- `INT ` equivalent of sending Ctrl-C to cluster. Puma will attempt to finish then exit. - `CHLD` -- `URG ` refork workers in phases from worker 0, if `fork_workers` option is enabled. +- `URG ` refork workers in phases from worker 0 if `fork_workers` option is enabled. ## Callbacks order in case of different signals diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/docs/stats.md new/docs/stats.md --- old/docs/stats.md 2021-09-19 22:09:23.000000000 +0200 +++ new/docs/stats.md 2021-10-13 01:07:08.000000000 +0200 @@ -1,4 +1,4 @@ -## accessing stats +## Accessing stats Stats can be accessed in two ways: @@ -47,18 +47,18 @@ ## Explanation of stats -`Puma.stats` returns different information and a different structure depending on if Puma is in single vs cluster mode. There is one top-level attribute that is common to both modes: +`Puma.stats` returns different information and a different structure depending on if Puma is in single vs. cluster mode. There is one top-level attribute that is common to both modes: -* started_at: when puma was started +* started_at: when Puma was started ### single mode and individual workers in cluster mode -When Puma is run in single mode, these stats are available at the top level. When Puma is run in cluster mode, these stats are available within the `worker_status` array in a hash labeled `last_status`, in an array of hashes, one hash for each worker. +When Puma runs in single mode, these stats are available at the top level. When Puma runs in cluster mode, these stats are available within the `worker_status` array in a hash labeled `last_status`, in an array of hashes where one hash represents each worker. * backlog: requests that are waiting for an available thread to be available. if this is above 0, you need more capacity [always true?] * running: how many threads are running -* pool_capacity: the number of requests that the server is capable of taking right now. For example if the number is 5 then it means there are 5 threads sitting idle ready to take a request. If one request comes in, then the value would be 4 until it finishes processing. If the minimum threads allowed is zero, this number will still have a maximum value of the maximum threads allowed. -* max_threads: the maximum number of threads puma is configured to spool up per worker +* pool_capacity: the number of requests that the server is capable of taking right now. For example, if the number is 5, then it means there are 5 threads sitting idle ready to take a request. If one request comes in, then the value would be 4 until it finishes processing. If the minimum threads allowed is zero, this number will still have a maximum value of the maximum threads allowed. +* max_threads: the maximum number of threads Puma is configured to spool per worker * requests_count: the number of requests this worker has served since starting @@ -72,9 +72,9 @@ ### worker status -* started_at: when the worker was started +* started_at: when the worker started * pid: the process id of the worker process -* index: each worker gets a number. if puma is configured to have 3 workers, then this will be 0, 1, or 2 +* index: each worker gets a number. if Puma is configured to have 3 workers, then this will be 0, 1, or 2 * booted: if it's done booting [?] * last_checkin: Last time the worker responded to the master process' heartbeat check. * last_status: a hash of info about the worker's state handling requests. See the explanation for this in "single mode and individual workers in cluster mode" section above. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/docs/systemd.md new/docs/systemd.md --- old/docs/systemd.md 2021-09-19 22:09:23.000000000 +0200 +++ new/docs/systemd.md 2021-10-13 01:07:08.000000000 +0200 @@ -1,19 +1,18 @@ # systemd -[systemd](https://www.freedesktop.org/wiki/Software/systemd/) is a -commonly available init system (PID 1) on many Linux distributions. It -offers process monitoring (including automatic restarts) and other -useful features for running Puma in production. +[systemd](https://www.freedesktop.org/wiki/Software/systemd/) is a commonly +available init system (PID 1) on many Linux distributions. It offers process +monitoring (including automatic restarts) and other useful features for running +Puma in production. ## Service Configuration -Below is a sample puma.service configuration file for systemd, which -can be copied or symlinked to `/etc/systemd/system/puma.service`, or if -desired, using an application or instance specific name. - -Note that this uses the systemd preferred "simple" type where the -start command remains running in the foreground (does not fork and -exit). +Below is a sample puma.service configuration file for systemd, which can be +copied or symlinked to `/etc/systemd/system/puma.service`, or if desired, using +an application or instance-specific name. + +Note that this uses the systemd preferred "simple" type where the start command +remains running in the foreground (does not fork and exit). ~~~~ ini [Unit] @@ -37,8 +36,8 @@ # Preferably configure a non-privileged user # User= -# The path to the your application code root directory. -# Also replace the "<YOUR_APP_PATH>" place holders below with this path. +# The path to your application code root directory. +# Also replace the "<YOUR_APP_PATH>" placeholders below with this path. # Example /home/username/myapp WorkingDirectory=<YOUR_APP_PATH> @@ -64,33 +63,31 @@ WantedBy=multi-user.target ~~~~ -See [systemd.exec](https://www.freedesktop.org/software/systemd/man/systemd.exec.html) +See +[systemd.exec](https://www.freedesktop.org/software/systemd/man/systemd.exec.html) for additional details. ## Socket Activation -systemd and puma also support socket activation, where systemd opens -the listening socket(s) in advance and provides them to the puma -master process on startup. Among other advantages, this keeps -listening sockets open across puma restarts and achieves graceful -restarts, including when upgraded puma, and is compatible with both -clustered mode and application preload. - -**Note:** Any wrapper scripts which `exec`, or other indirections in -`ExecStart`, may result in activated socket file descriptors being closed -before they reach the puma master process. For example, if using `bundle exec`, -pass the `--keep-file-descriptors` flag. `bundle exec` can be avoided by using a -`puma` executable generated by `bundle binstubs puma`. This is tracked in -[#1499]. - -**Note:** Socket activation doesn't currently work on JRuby. This is -tracked in [#1367]. - -To use socket activation, configure one or more `ListenStream` sockets -in a companion `*.socket` unit file. Also uncomment the associated -`Requires` directive for the socket unit in the service file (see -above.) Here is a sample puma.socket, matching the ports used in the -above puma.service: +systemd and Puma also support socket activation, where systemd opens the +listening socket(s) in advance and provides them to the Puma master process on +startup. Among other advantages, this keeps listening sockets open across puma +restarts and achieves graceful restarts, including when upgraded Puma, and is +compatible with both clustered mode and application preload. + +**Note:** Any wrapper scripts which `exec`, or other indirections in `ExecStart` +may result in activated socket file descriptors being closed before reaching the +puma master process. For example, if using `bundle exec`, pass the +`--keep-file-descriptors` flag. `bundle exec` can be avoided by using a `puma` +executable generated by `bundle binstubs puma`. This is tracked in [#1499]. + +**Note:** Socket activation doesn't currently work on JRuby. This is tracked in +[#1367]. + +Configure one or more `ListenStream` sockets in a companion `*.socket` unit file +to use socket activation. Also, uncomment the associated `Requires` directive +for the socket unit in the service file (see above.) Here is a sample +puma.socket, matching the ports used in the above puma.service: ~~~~ ini [Unit] @@ -113,31 +110,32 @@ WantedBy=sockets.target ~~~~ -See [systemd.socket](https://www.freedesktop.org/software/systemd/man/systemd.socket.html) +See +[systemd.socket](https://www.freedesktop.org/software/systemd/man/systemd.socket.html) for additional configuration details. -Note that the above configurations will work with Puma in either -single process or cluster mode. +Note that the above configurations will work with Puma in either single process +or cluster mode. ### Sockets and symlinks -When using releases folders, you should set the socket path using the -shared folder path (ex. `/srv/projet/shared/tmp/puma.sock`), not the -release folder path (`/srv/projet/releases/1234/tmp/puma.sock`). +When using releases folders, you should set the socket path using the shared +folder path (ex. `/srv/projet/shared/tmp/puma.sock`), not the release folder +path (`/srv/projet/releases/1234/tmp/puma.sock`). Puma will detect the release path socket as different than the one provided by -systemd and attempt to bind it again, resulting in the exception - `There is already a server bound to:`. +systemd and attempt to bind it again, resulting in the exception `There is +already a server bound to:`. ### Binding -By default you need to configure puma to have binds matching with all +By default, you need to configure Puma to have binds matching with all ListenStream statements. Any mismatched systemd ListenStreams will be closed by -puma. +Puma. To automatically bind to all activated sockets, the option `--bind-to-activated-sockets` can be used. This matches the config DSL -`bind_to_activated_sockets` statement. This will cause puma to create a bind +`bind_to_activated_sockets` statement. This will cause Puma to create a bind automatically for any activated socket. When systemd socket activation is not enabled, this option does nothing. @@ -146,8 +144,8 @@ ## Usage -Without socket activation, use `systemctl` as root (e.g. via `sudo`) as -with other system services: +Without socket activation, use `systemctl` as root (i.e., via `sudo`) as with +other system services: ~~~~ sh # After installing or making changes to puma.service @@ -156,35 +154,35 @@ # Enable so it starts on boot systemctl enable puma.service -# Initial start up. +# Initial startup. systemctl start puma.service # Check status systemctl status puma.service -# A normal restart. Warning: listeners sockets will be closed +# A normal restart. Warning: listener's sockets will be closed # while a new puma process initializes. systemctl restart puma.service ~~~~ -With socket activation, several but not all of these commands should -be run for both socket and service: +With socket activation, several but not all of these commands should be run for +both socket and service: ~~~~ sh # After installing or making changes to either puma.socket or # puma.service. systemctl daemon-reload -# Enable both socket and service so they start on boot. Alternatively -# you could leave puma.service disabled and systemd will start it on -# first use (with startup lag on first request) +# Enable both socket and service, so they start on boot. Alternatively +# you could leave puma.service disabled, and systemd will start it on +# the first use (with startup lag on the first request) systemctl enable puma.socket puma.service -# Initial start up. The Requires directive (see above) ensures the +# Initial startup. The Requires directive (see above) ensures the # socket is started before the service. systemctl start puma.socket puma.service -# Check status of both socket and service. +# Check the status of both socket and service. systemctl status puma.socket puma.service # A "hot" restart, with systemd keeping puma.socket listening and @@ -197,8 +195,8 @@ systemctl restart puma.socket puma.service ~~~~ -Here is sample output from `systemctl status` with both service and -socket running: +Here is sample output from `systemctl status` with both service and socket +running: ~~~~ ??? puma.socket - Puma HTTP Server Accept Sockets @@ -231,14 +229,12 @@ ### capistrano3-puma -By default, -[capistrano3-puma](https://github.com/seuros/capistrano-puma) uses -`pumactl` for deployment restarts, outside of systemd. To learn the -exact commands that this tool would use for `ExecStart` and -`ExecStop`, use the following `cap` commands in dry-run mode, and -update from the above forking service configuration accordingly. Note -also that the configured `User` should likely be the same as the -capistrano3-puma `:puma_user` option. +By default, [capistrano3-puma](https://github.com/seuros/capistrano-puma) uses +`pumactl` for deployment restarts outside of systemd. To learn the exact +commands that this tool would use for `ExecStart` and `ExecStop`, use the +following `cap` commands in dry-run mode, and update from the above forking +service configuration accordingly. Note also that the configured `User` should +likely be the same as the capistrano3-puma `:puma_user` option. ~~~~ sh stage=production # or different stage, as needed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/puma_http11/http11_parser.c new/ext/puma_http11/http11_parser.c --- old/ext/puma_http11/http11_parser.c 2021-09-19 22:09:23.000000000 +0200 +++ new/ext/puma_http11/http11_parser.c 2021-10-13 01:07:08.000000000 +0200 @@ -428,7 +428,13 @@ switch( (*p) ) { case 13: goto tr26; case 32: goto tr27; + case 127: goto st0; } + if ( (*p) > 8 ) { + if ( 10 <= (*p) && (*p) <= 31 ) + goto st0; + } else if ( (*p) >= 0 ) + goto st0; goto tr25; tr25: #line 46 "ext/puma_http11/http11_parser.rl" @@ -438,9 +444,16 @@ if ( ++p == pe ) goto _test_eof19; case 19: -#line 442 "ext/puma_http11/http11_parser.c" - if ( (*p) == 13 ) - goto tr29; +#line 448 "ext/puma_http11/http11_parser.c" + switch( (*p) ) { + case 13: goto tr29; + case 127: goto st0; + } + if ( (*p) > 8 ) { + if ( 10 <= (*p) && (*p) <= 31 ) + goto st0; + } else if ( (*p) >= 0 ) + goto st0; goto st19; tr9: #line 53 "ext/puma_http11/http11_parser.rl" @@ -484,7 +497,7 @@ if ( ++p == pe ) goto _test_eof20; case 20: -#line 488 "ext/puma_http11/http11_parser.c" +#line 501 "ext/puma_http11/http11_parser.c" switch( (*p) ) { case 32: goto tr31; case 60: goto st0; @@ -505,7 +518,7 @@ if ( ++p == pe ) goto _test_eof21; case 21: -#line 509 "ext/puma_http11/http11_parser.c" +#line 522 "ext/puma_http11/http11_parser.c" switch( (*p) ) { case 32: goto tr33; case 60: goto st0; @@ -526,7 +539,7 @@ if ( ++p == pe ) goto _test_eof22; case 22: -#line 530 "ext/puma_http11/http11_parser.c" +#line 543 "ext/puma_http11/http11_parser.c" switch( (*p) ) { case 43: goto st22; case 58: goto st23; @@ -551,7 +564,7 @@ if ( ++p == pe ) goto _test_eof23; case 23: -#line 555 "ext/puma_http11/http11_parser.c" +#line 568 "ext/puma_http11/http11_parser.c" switch( (*p) ) { case 32: goto tr8; case 34: goto st0; @@ -571,7 +584,7 @@ if ( ++p == pe ) goto _test_eof24; case 24: -#line 575 "ext/puma_http11/http11_parser.c" +#line 588 "ext/puma_http11/http11_parser.c" switch( (*p) ) { case 32: goto tr37; case 34: goto st0; @@ -594,7 +607,7 @@ if ( ++p == pe ) goto _test_eof25; case 25: -#line 598 "ext/puma_http11/http11_parser.c" +#line 611 "ext/puma_http11/http11_parser.c" switch( (*p) ) { case 32: goto tr41; case 34: goto st0; @@ -614,7 +627,7 @@ if ( ++p == pe ) goto _test_eof26; case 26: -#line 618 "ext/puma_http11/http11_parser.c" +#line 631 "ext/puma_http11/http11_parser.c" switch( (*p) ) { case 32: goto tr44; case 34: goto st0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/puma_http11/http11_parser_common.rl new/ext/puma_http11/http11_parser_common.rl --- old/ext/puma_http11/http11_parser_common.rl 2021-09-19 22:09:23.000000000 +0200 +++ new/ext/puma_http11/http11_parser_common.rl 2021-10-13 01:07:08.000000000 +0200 @@ -43,7 +43,7 @@ field_name = ( token -- ":" )+ >start_field $snake_upcase_field %write_field; - field_value = any* >start_value %write_value; + field_value = ( (any -- CTL) | "\t" )* >start_value %write_value; message_header = field_name ":" " "* field_value :> CRLF; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/puma_http11/org/jruby/puma/Http11Parser.java new/ext/puma_http11/org/jruby/puma/Http11Parser.java --- old/ext/puma_http11/org/jruby/puma/Http11Parser.java 2021-09-19 22:09:23.000000000 +0200 +++ new/ext/puma_http11/org/jruby/puma/Http11Parser.java 2021-10-13 01:07:08.000000000 +0200 @@ -34,9 +34,9 @@ { return new short [] { 0, 0, 8, 17, 27, 29, 30, 31, 32, 33, 34, 36, - 39, 41, 44, 45, 61, 62, 78, 80, 81, 89, 97, 107, - 115, 124, 132, 140, 149, 158, 167, 176, 185, 194, 203, 212, - 221, 230, 239, 248, 257, 266, 275, 284, 293, 302, 303 + 39, 41, 44, 45, 61, 62, 78, 85, 91, 99, 107, 117, + 125, 134, 142, 150, 159, 168, 177, 186, 195, 204, 213, 222, + 231, 240, 249, 258, 267, 276, 285, 294, 303, 312, 313 }; } @@ -52,26 +52,27 @@ 46, 48, 57, 48, 57, 13, 48, 57, 10, 13, 33, 124, 126, 35, 39, 42, 43, 45, 46, 48, 57, 65, 90, 94, 122, 10, 33, 58, 124, 126, 35, 39, 42, 43, 45, 46, - 48, 57, 65, 90, 94, 122, 13, 32, 13, 32, 60, 62, - 127, 0, 31, 34, 35, 32, 60, 62, 127, 0, 31, 34, - 35, 43, 58, 45, 46, 48, 57, 65, 90, 97, 122, 32, - 34, 35, 60, 62, 127, 0, 31, 32, 34, 35, 60, 62, - 63, 127, 0, 31, 32, 34, 35, 60, 62, 127, 0, 31, - 32, 34, 35, 60, 62, 127, 0, 31, 32, 36, 95, 45, - 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, - 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, - 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, - 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, - 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, - 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, - 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, - 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, - 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, - 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, - 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, - 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, - 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, - 65, 90, 32, 0 + 48, 57, 65, 90, 94, 122, 13, 32, 127, 0, 8, 10, + 31, 13, 127, 0, 8, 10, 31, 32, 60, 62, 127, 0, + 31, 34, 35, 32, 60, 62, 127, 0, 31, 34, 35, 43, + 58, 45, 46, 48, 57, 65, 90, 97, 122, 32, 34, 35, + 60, 62, 127, 0, 31, 32, 34, 35, 60, 62, 63, 127, + 0, 31, 32, 34, 35, 60, 62, 127, 0, 31, 32, 34, + 35, 60, 62, 127, 0, 31, 32, 36, 95, 45, 46, 48, + 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, + 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, + 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, + 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, + 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, + 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, + 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, + 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, + 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, + 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, + 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, + 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, + 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, + 32, 0 }; } @@ -82,7 +83,7 @@ { return new byte [] { 0, 2, 3, 4, 2, 1, 1, 1, 1, 1, 0, 1, - 0, 1, 1, 4, 1, 4, 2, 1, 4, 4, 2, 6, + 0, 1, 1, 4, 1, 4, 3, 2, 4, 4, 2, 6, 7, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 0 }; @@ -95,7 +96,7 @@ { return new byte [] { 0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 1, 0, 6, 0, 6, 0, 0, 2, 2, 4, 1, + 1, 1, 0, 6, 0, 6, 2, 2, 2, 2, 4, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0 }; @@ -108,9 +109,9 @@ { return new short [] { 0, 0, 6, 13, 21, 24, 26, 28, 30, 32, 34, 36, - 39, 41, 44, 46, 57, 59, 70, 73, 75, 82, 89, 96, - 104, 113, 121, 129, 136, 143, 150, 157, 164, 171, 178, 185, - 192, 199, 206, 213, 220, 227, 234, 241, 248, 255, 257 + 39, 41, 44, 46, 57, 59, 70, 76, 81, 88, 95, 102, + 110, 119, 127, 135, 142, 149, 156, 163, 170, 177, 184, 191, + 198, 205, 212, 219, 226, 233, 240, 247, 254, 261, 263 }; } @@ -126,22 +127,23 @@ 16, 15, 1, 17, 1, 18, 17, 1, 19, 1, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 1, 22, 1, 23, 24, 23, 23, 23, 23, 23, 23, 23, 23, 1, 26, 27, - 25, 29, 28, 30, 1, 1, 1, 1, 1, 31, 32, 1, - 1, 1, 1, 1, 33, 34, 35, 34, 34, 34, 34, 1, - 8, 1, 9, 1, 1, 1, 1, 35, 36, 1, 38, 1, - 1, 39, 1, 1, 37, 40, 1, 42, 1, 1, 1, 1, - 41, 43, 1, 45, 1, 1, 1, 1, 44, 2, 46, 46, - 46, 46, 46, 1, 2, 47, 47, 47, 47, 47, 1, 2, - 48, 48, 48, 48, 48, 1, 2, 49, 49, 49, 49, 49, - 1, 2, 50, 50, 50, 50, 50, 1, 2, 51, 51, 51, - 51, 51, 1, 2, 52, 52, 52, 52, 52, 1, 2, 53, - 53, 53, 53, 53, 1, 2, 54, 54, 54, 54, 54, 1, - 2, 55, 55, 55, 55, 55, 1, 2, 56, 56, 56, 56, - 56, 1, 2, 57, 57, 57, 57, 57, 1, 2, 58, 58, - 58, 58, 58, 1, 2, 59, 59, 59, 59, 59, 1, 2, - 60, 60, 60, 60, 60, 1, 2, 61, 61, 61, 61, 61, - 1, 2, 62, 62, 62, 62, 62, 1, 2, 63, 63, 63, - 63, 63, 1, 2, 1, 1, 0 + 1, 1, 1, 25, 29, 1, 1, 1, 28, 30, 1, 1, + 1, 1, 1, 31, 32, 1, 1, 1, 1, 1, 33, 34, + 35, 34, 34, 34, 34, 1, 8, 1, 9, 1, 1, 1, + 1, 35, 36, 1, 38, 1, 1, 39, 1, 1, 37, 40, + 1, 42, 1, 1, 1, 1, 41, 43, 1, 45, 1, 1, + 1, 1, 44, 2, 46, 46, 46, 46, 46, 1, 2, 47, + 47, 47, 47, 47, 1, 2, 48, 48, 48, 48, 48, 1, + 2, 49, 49, 49, 49, 49, 1, 2, 50, 50, 50, 50, + 50, 1, 2, 51, 51, 51, 51, 51, 1, 2, 52, 52, + 52, 52, 52, 1, 2, 53, 53, 53, 53, 53, 1, 2, + 54, 54, 54, 54, 54, 1, 2, 55, 55, 55, 55, 55, + 1, 2, 56, 56, 56, 56, 56, 1, 2, 57, 57, 57, + 57, 57, 1, 2, 58, 58, 58, 58, 58, 1, 2, 59, + 59, 59, 59, 59, 1, 2, 60, 60, 60, 60, 60, 1, + 2, 61, 61, 61, 61, 61, 1, 2, 62, 62, 62, 62, + 62, 1, 2, 63, 63, 63, 63, 63, 1, 2, 1, 1, + 0 }; } @@ -210,7 +212,7 @@ cs = 0; -// line 214 "ext/puma_http11/org/jruby/puma/Http11Parser.java" +// line 216 "ext/puma_http11/org/jruby/puma/Http11Parser.java" { cs = puma_parser_start; } @@ -242,7 +244,7 @@ parser.buffer = buffer; -// line 246 "ext/puma_http11/org/jruby/puma/Http11Parser.java" +// line 248 "ext/puma_http11/org/jruby/puma/Http11Parser.java" { int _klen; int _trans = 0; @@ -398,7 +400,7 @@ { p += 1; _goto_targ = 5; if (true) continue _goto;} } break; -// line 402 "ext/puma_http11/org/jruby/puma/Http11Parser.java" +// line 404 "ext/puma_http11/org/jruby/puma/Http11Parser.java" } } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/puma/client.rb new/lib/puma/client.rb --- old/lib/puma/client.rb 2021-09-19 22:09:23.000000000 +0200 +++ new/lib/puma/client.rb 2021-10-13 01:07:08.000000000 +0200 @@ -162,7 +162,7 @@ begin @io.close rescue IOError - Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue + Puma::Util.purge_interrupt_queue end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/puma/cluster/worker.rb new/lib/puma/cluster/worker.rb --- old/lib/puma/cluster/worker.rb 2021-09-19 22:09:23.000000000 +0200 +++ new/lib/puma/cluster/worker.rb 2021-10-13 01:07:08.000000000 +0200 @@ -106,7 +106,7 @@ begin @worker_write << "b#{Process.pid}:#{index}\n" rescue SystemCallError, IOError - Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue + Puma::Util.purge_interrupt_queue STDERR.puts "Master seems to have exited, exiting." return end @@ -127,7 +127,7 @@ payload = %Q!#{base_payload}{ "backlog":#{b}, "running":#{r}, "pool_capacity":#{t}, "max_threads": #{m}, "requests_count": #{rc} }\n! io << payload rescue IOError - Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue + Puma::Util.purge_interrupt_queue break end sleep Const::WORKER_CHECK_INTERVAL @@ -168,16 +168,6 @@ @launcher.config.run_hooks :after_worker_fork, idx, @launcher.events pid end - - def wakeup! - return unless @wakeup - - begin - @wakeup.write "!" unless @wakeup.closed? - rescue SystemCallError, IOError - Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue - end - end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/puma/cluster.rb new/lib/puma/cluster.rb --- old/lib/puma/cluster.rb 2021-09-19 22:09:23.000000000 +0200 +++ new/lib/puma/cluster.rb 2021-10-13 01:07:08.000000000 +0200 @@ -164,16 +164,6 @@ ].compact.min end - def wakeup! - return unless @wakeup - - begin - @wakeup.write "!" unless @wakeup.closed? - rescue SystemCallError, IOError - Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue - end - end - def worker(index, master) @workers = [] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/puma/configuration.rb new/lib/puma/configuration.rb --- old/lib/puma/configuration.rb 2021-09-19 22:09:23.000000000 +0200 +++ new/lib/puma/configuration.rb 2021-10-13 01:07:08.000000000 +0200 @@ -200,7 +200,7 @@ :worker_shutdown_timeout => DefaultWorkerShutdownTimeout, :remote_address => :socket, :tag => method(:infer_tag), - :environment => -> { ENV['RACK_ENV'] || ENV['RAILS_ENV'] || "development" }, + :environment => -> { ENV['APP_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development' }, :rackup => DefaultRackup, :logger => STDOUT, :persistent_timeout => Const::PERSISTENT_TIMEOUT, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/puma/const.rb new/lib/puma/const.rb --- old/lib/puma/const.rb 2021-09-19 22:09:23.000000000 +0200 +++ new/lib/puma/const.rb 2021-10-13 01:07:08.000000000 +0200 @@ -100,7 +100,7 @@ # too taxing on performance. module Const - PUMA_VERSION = VERSION = "5.5.0".freeze + PUMA_VERSION = VERSION = "5.5.2".freeze CODE_NAME = "Zawgyi".freeze PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/puma/control_cli.rb new/lib/puma/control_cli.rb --- old/lib/puma/control_cli.rb 2021-09-19 22:09:23.000000000 +0200 +++ new/lib/puma/control_cli.rb 2021-10-13 01:07:08.000000000 +0200 @@ -47,7 +47,7 @@ @control_auth_token = nil @config_file = nil @command = nil - @environment = ENV['RACK_ENV'] || ENV['RAILS_ENV'] + @environment = ENV['APP_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV'] @argv = argv.dup @stdout = stdout diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/puma/minissl.rb new/lib/puma/minissl.rb --- old/lib/puma/minissl.rb 2021-09-19 22:09:23.000000000 +0200 +++ new/lib/puma/minissl.rb 2021-10-13 01:07:08.000000000 +0200 @@ -169,7 +169,7 @@ end end rescue IOError, SystemCallError - Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue + Puma::Util.purge_interrupt_queue # nothing ensure @socket.close diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/puma/runner.rb new/lib/puma/runner.rb --- old/lib/puma/runner.rb 2021-09-19 22:09:23.000000000 +0200 +++ new/lib/puma/runner.rb 2021-10-13 01:07:08.000000000 +0200 @@ -15,6 +15,16 @@ @app = nil @control = nil @started_at = Time.now + @wakeup = nil + end + + def wakeup! + return unless @wakeup + + @wakeup.write "!" unless @wakeup.closed? + + rescue SystemCallError, IOError + Puma::Util.purge_interrupt_queue end def development? @@ -108,9 +118,7 @@ append = @options[:redirect_append] if stdout - unless Dir.exist?(File.dirname(stdout)) - raise "Cannot redirect STDOUT to #{stdout}" - end + ensure_output_directory_exists(stdout, 'STDOUT') STDOUT.reopen stdout, (append ? "a" : "w") STDOUT.puts "=== puma startup: #{Time.now} ===" @@ -118,9 +126,7 @@ end if stderr - unless Dir.exist?(File.dirname(stderr)) - raise "Cannot redirect STDERR to #{stderr}" - end + ensure_output_directory_exists(stderr, 'STDERR') STDERR.reopen stderr, (append ? "a" : "w") STDERR.puts "=== puma startup: #{Time.now} ===" @@ -159,5 +165,12 @@ server.inherit_binder @launcher.binder server end + + private + def ensure_output_directory_exists(path, io_name) + unless Dir.exist?(File.dirname(path)) + raise "Cannot redirect #{io_name} to #{path}" + end + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/puma/server.rb new/lib/puma/server.rb --- old/lib/puma/server.rb 2021-09-19 22:09:23.000000000 +0200 +++ new/lib/puma/server.rb 2021-10-13 01:07:08.000000000 +0200 @@ -146,7 +146,7 @@ begin skt.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_CORK, 1) if skt.kind_of? TCPSocket rescue IOError, SystemCallError - Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue + Puma::Util.purge_interrupt_queue end end @@ -155,7 +155,7 @@ begin skt.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_CORK, 0) if skt.kind_of? TCPSocket rescue IOError, SystemCallError - Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue + Puma::Util.purge_interrupt_queue end end else @@ -176,7 +176,7 @@ begin tcp_info = skt.getsockopt(Socket::IPPROTO_TCP, Socket::TCP_INFO) rescue IOError, SystemCallError - Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue + Puma::Util.purge_interrupt_queue @precheck_closing = false false else @@ -491,7 +491,7 @@ begin client.close if close_socket rescue IOError, SystemCallError - Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue + Puma::Util.purge_interrupt_queue # Already closed rescue StandardError => e @events.unknown_error e, nil, "Client" @@ -583,11 +583,11 @@ @notify << message rescue IOError, NoMethodError, Errno::EPIPE # The server, in another thread, is shutting down - Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue + Puma::Util.purge_interrupt_queue rescue RuntimeError => e # Temporary workaround for https://bugs.ruby-lang.org/issues/13239 if e.message.include?('IOError') - Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue + Puma::Util.purge_interrupt_queue else raise e end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/puma/util.rb new/lib/puma/util.rb --- old/lib/puma/util.rb 2021-09-19 22:09:23.000000000 +0200 +++ new/lib/puma/util.rb 2021-10-13 01:07:08.000000000 +0200 @@ -10,6 +10,13 @@ IO.pipe end + # An instance method on Thread has been provided to address https://bugs.ruby-lang.org/issues/13632, + # which currently effects some older versions of Ruby: 2.2.7 2.2.8 2.2.9 2.2.10 2.3.4 2.4.1 + # Additional context: https://github.com/puma/puma/pull/1345 + def purge_interrupt_queue + Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue + end + # Unescapes a URI escaped string with +encoding+. +encoding+ will be the # target encoding of the string returned, and it defaults to UTF-8 if defined?(::Encoding) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2021-09-19 22:09:23.000000000 +0200 +++ new/metadata 2021-10-13 01:07:08.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: puma version: !ruby/object:Gem::Version - version: 5.5.0 + version: 5.5.2 platform: ruby authors: - Evan Phoenix autorequire: bindir: bin cert_chain: [] -date: 2021-09-19 00:00:00.000000000 Z +date: 2021-10-12 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: nio4r