From 2863e7603e83e5d5e36bfea1122c3aa1b61947b1 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 16 Sep 2020 17:04:49 -0500 Subject: [PATCH 01/19] Update puma.rb --- lib/puma.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/puma.rb b/lib/puma.rb index 1e8f8e2c19..ce143e9194 100644 --- a/lib/puma.rb +++ b/lib/puma.rb @@ -27,6 +27,7 @@ def self.stats @get_stats.stats.to_json end + # @version 5.0.0 def self.stats_hash @get_stats.stats end From 54c5245ef156eb246977dd8abaca9077e444c420 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Sun, 16 Aug 2020 19:02:38 -0500 Subject: [PATCH 02/19] Update cluster.rb --- lib/puma/cluster.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/puma/cluster.rb b/lib/puma/cluster.rb index 7e9dd95b20..879151afbb 100644 --- a/lib/puma/cluster.rb +++ b/lib/puma/cluster.rb @@ -98,6 +98,7 @@ def ping!(status) @last_status = JSON.parse(status, symbolize_names: true) end + # @see Puma::Cluster#check_workers def ping_timeout @last_checkin + (booted? ? @@ -649,6 +650,7 @@ def timeout_workers end end + # @version 5.0.0 def nakayoshi_gc return unless @options[:nakayoshi_fork] log "! Promoting existing objects to old generation..." From fbe08e6db18e9d2d0e60416768a4620b4c92f29e Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Sun, 16 Aug 2020 19:02:06 -0500 Subject: [PATCH 03/19] Update dsl.rb --- lib/puma/dsl.rb | 109 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 73 insertions(+), 36 deletions(-) diff --git a/lib/puma/dsl.rb b/lib/puma/dsl.rb index 4dbe4c3e75..92759396c4 100644 --- a/lib/puma/dsl.rb +++ b/lib/puma/dsl.rb @@ -14,22 +14,23 @@ module Puma # end # config.load # - # puts config.options[:binds] - # "tcp://127.0.0.1:3001" + # puts config.options[:binds] # => "tcp://127.0.0.1:3001" # # Used to load file: - # + # # $ cat puma_config.rb - # port 3002 + # port 3002 + # + # Resulting configuration: # # config = Configuration.new(config_file: "puma_config.rb") # config.load # - # puts config.options[:binds] - # # => "tcp://127.0.0.1:3002" + # puts config.options[:binds] # => "tcp://127.0.0.1:3002" # # You can also find many examples being used by the test suite in # +test/config+. + # class DSL include ConfigDefault @@ -98,6 +99,9 @@ def plugin(name) # [body] # ] # end + # + # @see Puma::Configuration#app + # def app(obj=nil, &block) obj ||= block @@ -160,12 +164,12 @@ def load(file) # # You can use query parameters within the url to specify options: # - # - Set the socket backlog depth with +backlog+, default is 1024. - # - Set up an SSL certificate with +key+ & +cert+. - # - Set whether to optimize for low latency instead of throughput with - # +low_latency+, default is to optimize for low latency. This is done - # via +Socket::TCP_NODELAY+. - # - Set socket permissions with +umask+. + # * Set the socket backlog depth with +backlog+, default is 1024. + # * Set up an SSL certificate with +key+ & +cert+. + # * Set whether to optimize for low latency instead of throughput with + # +low_latency+, default is to optimize for low latency. This is done + # via +Socket::TCP_NODELAY+. + # * Set socket permissions with +umask+. # # @example Backlog depth # bind 'unix:///var/run/puma.sock?backlog=512' @@ -175,6 +179,9 @@ def load(file) # bind 'tcp://0.0.0.0:9292?low_latency=false' # @example Socket permissions # bind 'unix:///var/run/puma.sock?umask=0111' + # @see Puma::Runner#load_and_bind + # @see Puma::Cluster#run + # def bind(url) @options[:binds] ||= [] @options[:binds] << url @@ -193,13 +200,14 @@ def port(port, host=nil) bind "tcp://#{host}:#{port}" end - # Define how long persistent connections can be idle before Puma closes - # them. + # Define how long persistent connections can be idle before Puma closes them. + # @see Puma::Server.new def persistent_timeout(seconds) @options[:persistent_timeout] = Integer(seconds) end # Define how long the tcp socket stays open, if no data has been received. + # @see Puma::Server.new def first_data_timeout(seconds) @options[:first_data_timeout] = Integer(seconds) end @@ -210,10 +218,11 @@ def clean_thread_locals(which=true) @options[:clean_thread_locals] = which end - # When shutting down, drain the accept socket of pending - # connections and process them. This loops over the accept - # socket until there are no more read events and then stops - # looking and waits for the requests to finish. + # When shutting down, drain the accept socket of pending connections and + # process them. This loops over the accept socket until there are no more + # read events and then stops looking and waits for the requests to finish. + # @see Puma::Server#graceful_shutdown + # def drain_on_shutdown(which=true) @options[:drain_on_shutdown] = which end @@ -236,6 +245,7 @@ def environment(environment) # # Puma always waits a few seconds after killing a thread for it to try # to finish up it's work, even in :immediately mode. + # @see Puma::Server#graceful_shutdown def force_shutdown_after(val=:forever) i = case val when :forever @@ -315,7 +325,7 @@ def early_hints(answer=true) @options[:early_hints] = answer end - # Redirect STDOUT and STDERR to files specified. The +append+ parameter + # Redirect +STDOUT+ and +STDERR+ to files specified. The +append+ parameter # specifies whether the output is appended, the default is +false+. # # @example @@ -356,8 +366,8 @@ def threads(min, max) @options[:max_threads] = max end - # Instead of "bind 'ssl://127.0.0.1:9292?key=key_path&cert=cert_path'" you - # can also use the "ssl_bind" option. + # Instead of `bind 'ssl://127.0.0.1:9292?key=key_path&cert=cert_path'` you + # can also use the this method. # # @example # ssl_bind '127.0.0.1', '9292', { @@ -403,6 +413,8 @@ def state_path(path) # # @example # state_permission 0600 + # @version 5.0.0 + # def state_permission(permission) @options[:state_permission] = permission end @@ -413,6 +425,7 @@ def state_permission(permission) # The default is 0. # # @note Cluster mode only. + # @see Puma::Cluster def workers(count) @options[:workers] = count.to_i end @@ -582,7 +595,7 @@ def lowlevel_error_handler(obj=nil, &block) # new Bundler context and thus can float around as the release # dictates. # - # See also: extra_runtime_dependencies + # @see extra_runtime_dependencies # # @note This is incompatible with +preload_app!+. # @note This is only supported for RubyGems 2.2+ @@ -599,6 +612,9 @@ def prune_bundler(answer=true) # # @example # raise_exception_on_sigterm false + # @see Puma::Launcher#setup_signals + # @see Puma::Cluster#setup_signals + # def raise_exception_on_sigterm(answer=true) @options[:raise_exception_on_sigterm] = answer end @@ -614,6 +630,8 @@ def raise_exception_on_sigterm(answer=true) # extra_runtime_dependencies ['gem_name_1', 'gem_name_2'] # @example # extra_runtime_dependencies ['puma_worker_killer', 'puma-heroku'] + # @see Puma::Launcher#extra_runtime_deps_directories + # def extra_runtime_dependencies(answer = []) @options[:extra_runtime_dependencies] = Array(answer) end @@ -641,6 +659,8 @@ def tag(string) # @note Cluster mode only. # @example # worker_timeout 60 + # @see Puma::Cluster::Worker#ping_timeout + # def worker_timeout(timeout) timeout = Integer(timeout) min = Const::WORKER_CHECK_INTERVAL @@ -657,15 +677,20 @@ def worker_timeout(timeout) # If unspecified, this defaults to the value of worker_timeout. # # @note Cluster mode only. - # @example: + # + # @example # worker_boot_timeout 60 + # @see Puma::Cluster::Worker#ping_timeout + # def worker_boot_timeout(timeout) @options[:worker_boot_timeout] = Integer(timeout) end - # Set the timeout for worker shutdown + # Set the timeout for worker shutdown. # # @note Cluster mode only. + # @see Puma::Cluster::Worker#term + # def worker_shutdown_timeout(timeout) @options[:worker_shutdown_timeout] = Integer(timeout) end @@ -683,6 +708,7 @@ def worker_shutdown_timeout(timeout) # slow clients will occupy a handler thread while the request # is being sent. A reverse proxy, such as nginx, can handle # slow clients and queue requests before they reach Puma. + # @see Puma::Server def queue_requests(answer=true) @options[:queue_requests] = answer end @@ -690,6 +716,7 @@ def queue_requests(answer=true) # When a shutdown is requested, the backtraces of all the # threads will be written to $stdout. This can help figure # out why shutdown is hanging. + # def shutdown_debug(val=true) @options[:shutdown_debug] = val end @@ -700,6 +727,10 @@ def shutdown_debug(val=true) # requests to pick up new requests first. # # Only works on MRI. For all other interpreters, this setting does nothing. + # @see Puma::Server#handle_servers + # @see Puma::ThreadPool#wait_for_less_busy_worker + # @version 5.0.0 + # def wait_for_less_busy_worker(val=0.005) @options[:wait_for_less_busy_worker] = val.to_f end @@ -711,18 +742,18 @@ def wait_for_less_busy_worker(val=0.005) # # There are 4 possible values: # - # * :socket (the default) - read the peername from the socket using the - # syscall. This is the normal behavior. - # * :localhost - set the remote address to "127.0.0.1" - # * header: http_header - set the remote address to the value of the - # provided http header. For instance: - # `set_remote_address header: "X-Real-IP"`. - # Only the first word (as separated by spaces or comma) - # is used, allowing headers such as X-Forwarded-For - # to be used as well. - # * Any string - this allows you to hardcode remote address to any value - # you wish. Because Puma never uses this field anyway, it's - # format is entirely in your hands. + # 1. **:socket** (the default) - read the peername from the socket using the + # syscall. This is the normal behavior. + # 2. **:localhost** - set the remote address to "127.0.0.1" + # 3. **header: **- set the remote address to the value of the + # provided http header. For instance: + # `set_remote_address header: "X-Real-IP"`. + # Only the first word (as separated by spaces or comma) is used, allowing + # headers such as X-Forwarded-For to be used as well. + # 4. **\** - this allows you to hardcode remote address to any value + # you wish. Because Puma never uses this field anyway, it's format is + # entirely in your hands. + # def set_remote_address(val=:socket) case val when :socket @@ -756,6 +787,8 @@ def set_remote_address(val=:socket) # (default 1000), or pass 0 to disable auto refork. # # @note Cluster mode only. + # @version 5.0.0 + # def fork_worker(after_requests=1000) @options[:fork_worker] = Integer(after_requests) end @@ -769,6 +802,10 @@ def fork_worker(after_requests=1000) # also increase time to boot and fork. See your logs for details on how much # time this adds to your boot process. For most apps, it will be less than one # second. + # + # @see Puma::Cluster#nakayoshi_gc + # @version 5.0.0 + # def nakayoshi_fork(enabled=true) @options[:nakayoshi_fork] = enabled end From 64bce28a01bdeaa56a30554d4a5d0656f50f696c Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 16 Sep 2020 17:05:11 -0500 Subject: [PATCH 04/19] Update detect.rb --- lib/puma/detect.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/puma/detect.rb b/lib/puma/detect.rb index fa57c70192..05d5384f16 100644 --- a/lib/puma/detect.rb +++ b/lib/puma/detect.rb @@ -20,10 +20,12 @@ def self.windows? IS_WINDOWS end + # @version 5.0.0 def self.mri? RUBY_ENGINE == 'ruby' || RUBY_ENGINE.nil? end + # @version 5.0.0 def self.forkable? ::Process.respond_to?(:fork) end From 789b4037fec1aee22f8a0fef524967211831437d Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 16 Sep 2020 18:32:42 -0500 Subject: [PATCH 05/19] Update binder.rb --- lib/puma/binder.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/puma/binder.rb b/lib/puma/binder.rb index 805bcd0cb6..e4af161c98 100644 --- a/lib/puma/binder.rb +++ b/lib/puma/binder.rb @@ -50,7 +50,12 @@ def initialize(events, conf = Configuration.new) @ios = [] end - attr_reader :ios, :listeners, :unix_paths, :proto_env, :envs, :activated_sockets, :inherited_fds + attr_reader :ios + + # @version 5.0.0 + attr_reader :activated_sockets, :envs, :inherited_fds, :listeners, :proto_env, , :unix_paths + + # @version 5.0.0 attr_writer :ios, :listeners def env(sock) @@ -61,10 +66,12 @@ def close @ios.each { |i| i.close } end + # @version 5.0.0 def connected_ports ios.map { |io| io.addr[1] }.uniq end + # @version 5.0.0 def create_inherited_fds(env_hash) env_hash.select {|k,v| k =~ /PUMA_INHERIT_\d+/}.each do |_k, v| fd, url = v.split(":", 2) @@ -75,7 +82,9 @@ def create_inherited_fds(env_hash) # systemd socket activation. # LISTEN_FDS = number of listening sockets. e.g. 2 means accept on 2 sockets w/descriptors 3 and 4. # LISTEN_PID = PID of the service process, aka us - # see https://www.freedesktop.org/software/systemd/man/systemd-socket-activate.html + # @see https://www.freedesktop.org/software/systemd/man/systemd-socket-activate.html + # @version 5.0.0 + # def create_activated_fds(env_hash) return [] unless env_hash['LISTEN_FDS'] && env_hash['LISTEN_PID'].to_i == $$ env_hash['LISTEN_FDS'].to_i.times do |index| @@ -373,6 +382,7 @@ def redirects_for_restart redirects end + # @version 5.0.0 def redirects_for_restart_env listeners.each_with_object({}).with_index do |(listen, memo), i| memo["PUMA_INHERIT_#{i}"] = "#{listen[1].to_i}:#{listen[0]}" @@ -387,6 +397,7 @@ def loopback_addresses end.map { |addrinfo| addrinfo.ip_address }.uniq end + # @version 5.0.0 def socket_activation_fd(int) int + 3 # 3 is the magic number you add to follow the SA protocol end From 75eb453f1342905216d1a1610b1930eac0ddb900 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 16 Sep 2020 18:32:45 -0500 Subject: [PATCH 06/19] Update client.rb --- lib/puma/client.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/puma/client.rb b/lib/puma/client.rb index 72ab6e5a33..1b7c0ea018 100644 --- a/lib/puma/client.rb +++ b/lib/puma/client.rb @@ -280,6 +280,8 @@ def peerip # Returns true if the persistent connection can be closed immediately # without waiting for the configured idle/shutdown timeout. + # @version 5.0.0 + # def can_close? # Allow connection to close if it's received at least one full request # and hasn't received any data for a future request. @@ -443,6 +445,7 @@ def setup_chunked_body(body) end end + # @version 5.0.0 def write_chunk(str) @chunked_content_length += @body.write(str) end From a7dc1c4f470956a5785278ad6bedc98f02f702f6 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 16 Sep 2020 18:32:49 -0500 Subject: [PATCH 07/19] Update cluster.rb --- lib/puma/cluster.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/puma/cluster.rb b/lib/puma/cluster.rb index 879151afbb..c1bcc3169b 100644 --- a/lib/puma/cluster.rb +++ b/lib/puma/cluster.rb @@ -77,6 +77,8 @@ def initialize(idx, pid, phase, options) end attr_reader :index, :pid, :phase, :signal, :last_checkin, :last_status, :started_at + + # @version 5.0.0 attr_writer :pid, :phase def booted? @@ -99,6 +101,7 @@ def ping!(status) end # @see Puma::Cluster#check_workers + # @version 5.0.0 def ping_timeout @last_checkin + (booted? ? @@ -161,6 +164,7 @@ def spawn_workers end end + # @version 5.0.0 def spawn_worker(idx, master) @launcher.config.run_hooks :before_worker_fork, idx, @launcher.events @@ -420,6 +424,7 @@ def preload? @options[:preload_app] end + # @version 5.0.0 def fork_worker! if (worker = @workers.find { |w| w.index == 0 }) worker.phase += 1 @@ -641,6 +646,7 @@ def wait_workers end end + # @version 5.0.0 def timeout_workers @workers.each do |w| if !w.term? && w.ping_timeout <= Time.now From 346b143b9369e5a6cbafbf1f4c0e6aa311a57d6f Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 16 Sep 2020 18:32:52 -0500 Subject: [PATCH 08/19] Update configuration.rb --- lib/puma/configuration.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/puma/configuration.rb b/lib/puma/configuration.rb index f244c3078d..f88b7cddbb 100644 --- a/lib/puma/configuration.rb +++ b/lib/puma/configuration.rb @@ -173,6 +173,7 @@ def flatten! self end + # @version 5.0.0 def default_max_threads Puma.mri? ? 5 : 16 end From 7ee373a44e6c1a1cf08f76dafd1ea1b262c72d46 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 16 Sep 2020 18:32:55 -0500 Subject: [PATCH 09/19] Update control_cli.rb --- lib/puma/control_cli.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/puma/control_cli.rb b/lib/puma/control_cli.rb index 381812386d..6e9c016ff0 100644 --- a/lib/puma/control_cli.rb +++ b/lib/puma/control_cli.rb @@ -12,6 +12,8 @@ module Puma class ControlCLI COMMANDS = %w{halt restart phased-restart start stats status stop reload-worker-directory gc gc-stats thread-backtraces refork} + + # @version 5.0.0 PRINTABLE_COMMANDS = %w{gc-stats stats thread-backtraces} def initialize(argv, stdout=STDOUT, stderr=STDERR) From 646068a8c54d1726e8e87547b9c5ebbcd8a531dc Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 16 Sep 2020 18:33:00 -0500 Subject: [PATCH 10/19] Update dsl.rb --- lib/puma/dsl.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/puma/dsl.rb b/lib/puma/dsl.rb index 92759396c4..928d9dfd3b 100644 --- a/lib/puma/dsl.rb +++ b/lib/puma/dsl.rb @@ -529,7 +529,8 @@ def after_worker_fork(&block) # on_refork do # 3.times {GC.start} # end - + # @version 5.0.0 + # def on_refork(&block) @options[:before_refork] ||= [] @options[:before_refork] << block From 5f68d664ab6c53fb612256f70ca264f6916895f5 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 16 Sep 2020 18:33:04 -0500 Subject: [PATCH 11/19] Update error_logger.rb --- lib/puma/error_logger.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/puma/error_logger.rb b/lib/puma/error_logger.rb index e9f2ad6478..e70b1b85c4 100644 --- a/lib/puma/error_logger.rb +++ b/lib/puma/error_logger.rb @@ -4,6 +4,7 @@ module Puma # The implementation of a detailed error logging. + # @version 5.0.0 # class ErrorLogger include Const From 9bf2ad18df630cc6fe68d29e152bd08ee583e189 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 16 Sep 2020 18:33:07 -0500 Subject: [PATCH 12/19] Update events.rb --- lib/puma/events.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/puma/events.rb b/lib/puma/events.rb index c746c9d1a5..36af4a6625 100644 --- a/lib/puma/events.rb +++ b/lib/puma/events.rb @@ -91,6 +91,7 @@ def format(str) # An HTTP connection error has occurred. # +error+ a connection exception, +req+ the request, # and +text+ additional info + # @version 5.0.0 # def connection_error(error, req, text="HTTP connection error") @error_logger.info(error: error, req: req, text: text) @@ -124,6 +125,7 @@ def unknown_error(error, req=nil, text="Unknown error") # Log occurred error debug dump. # +error+ an exception object, +req+ the request, # and +text+ additional info + # @version 5.0.0 # def debug_error(error, req=nil, text="") @error_logger.debug(error: error, req: req, text: text) From 62b213b2ad4557a44a57ee0a08d5f2174ce4e932 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 16 Sep 2020 18:33:11 -0500 Subject: [PATCH 13/19] Update launcher.rb --- lib/puma/launcher.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/puma/launcher.rb b/lib/puma/launcher.rb index 03c3824711..1b8c9ed9d7 100644 --- a/lib/puma/launcher.rb +++ b/lib/puma/launcher.rb @@ -188,6 +188,7 @@ def run end # Return all tcp ports the launcher may be using, TCP or SSL + # @version 5.0.0 def connected_ports @binder.connected_ports end @@ -206,6 +207,7 @@ def close_binder_listeners @binder.close_listeners end + # @version 5.0.0 def thread_status Thread.list.each do |thread| name = "Thread: TID-#{thread.object_id.to_s(36)}" @@ -478,6 +480,7 @@ def require_rubygems_min_version!(min_version, feature) "You must have RubyGems #{min_version}+ to use this feature." end + # @version 5.0.0 def with_unbundled_env bundler_ver = Gem::Version.new(Bundler::VERSION) if bundler_ver < Gem::Version.new('2.1.0') From 04b45d1181bcd66d95f080bf30a2e1ba290814d8 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 16 Sep 2020 18:33:20 -0500 Subject: [PATCH 14/19] Update minissl.rb --- lib/puma/minissl.rb | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/lib/puma/minissl.rb b/lib/puma/minissl.rb index fd21200510..643a268d9f 100644 --- a/lib/puma/minissl.rb +++ b/lib/puma/minissl.rb @@ -10,8 +10,9 @@ module Puma module MiniSSL - # define constant at runtime, as it's easy to determine at built time, + # Define constant at runtime, as it's easy to determine at built time, # but Puma could (it shouldn't) be loaded with an older OpenSSL version + # @version 5.0.0 HAS_TLS1_3 = !IS_JRUBY && (OPENSSL_VERSION[/ \d+\.\d+\.\d+/].split('.').map(&:to_i) <=> [1,1,1]) != -1 && (OPENSSL_LIBRARY_VERSION[/ \d+\.\d+\.\d+/].split('.').map(&:to_i) <=> [1,1,1]) !=-1 @@ -31,19 +32,21 @@ def closed? @socket.closed? end - # returns a two element array - # first is protocol version (SSL_get_version) + # Returns a two element array, + # first is protocol version (SSL_get_version), # second is 'handshake' state (SSL_state_string) # - # used for dropping tcp connections to ssl - # see OpenSSL ssl/ssl_stat.c SSL_state_string for info + # Used for dropping tcp connections to ssl. + # See OpenSSL ssl/ssl_stat.c SSL_state_string for info + # @version 5.0.0 # def ssl_version_state IS_JRUBY ? [nil, nil] : @engine.ssl_vers_st end - # used to check the handshake status, in particular when a TCP connection + # Used to check the handshake status, in particular when a TCP connection # is made with TLSv1.3 as an available protocol + # @version 5.0.0 def bad_tlsv1_3? HAS_TLS1_3 && @engine.ssl_vers_st == ['TLSv1.3', 'SSLERR'] end @@ -135,14 +138,18 @@ def write(data) alias_method :<<, :write # This is a temporary fix to deal with websockets code using - # write_nonblock. The problem with implementing it properly + # write_nonblock. + + # The problem with implementing it properly # is that it means we'd have to have the ability to rewind # an engine because after we write+extract, the socket # write_nonblock call might raise an exception and later # code would pass the same data in, but the engine would think - # it had already written the data in. So for the time being - # (and since write blocking is quite rare), go ahead and actually - # block in write_nonblock. + # it had already written the data in. + # + # So for the time being (and since write blocking is quite rare), + # go ahead and actually block in write_nonblock. + # def write_nonblock(data, *_) write data end @@ -258,13 +265,13 @@ def check # disables TLSv1 def no_tlsv1=(tlsv1) - raise ArgumentError, "Invalid value of no_tlsv1" unless ['true', 'false', true, false].include?(tlsv1) + raise ArgumentError, "Invalid value of no_tlsv1=" unless ['true', 'false', true, false].include?(tlsv1) @no_tlsv1 = tlsv1 end # disables TLSv1 and TLSv1.1. Overrides `#no_tlsv1=` def no_tlsv1_1=(tlsv1_1) - raise ArgumentError, "Invalid value of no_tlsv1" unless ['true', 'false', true, false].include?(tlsv1_1) + raise ArgumentError, "Invalid value of no_tlsv1_1=" unless ['true', 'false', true, false].include?(tlsv1_1) @no_tlsv1_1 = tlsv1_1 end @@ -300,6 +307,7 @@ def accept_nonblock Socket.new io, engine end + # @version 5.0.0 def addr @socket.addr end From 40ed7736bc611eb9dcd22c7fd800abda69e60280 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 16 Sep 2020 18:33:24 -0500 Subject: [PATCH 15/19] Update runner.rb --- lib/puma/runner.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/puma/runner.rb b/lib/puma/runner.rb index 022b39c704..1a674fec07 100644 --- a/lib/puma/runner.rb +++ b/lib/puma/runner.rb @@ -29,6 +29,7 @@ def log(str) @events.log str end + # @version 5.0.0 def stop_control @control.stop(true) if @control end @@ -63,6 +64,7 @@ def start_control @control = control end + # @version 5.0.0 def close_control_listeners @control.binder.close_listeners if @control end From a92c120f2022d49ac89f7f6d4bd171770dc86e4d Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 16 Sep 2020 18:33:28 -0500 Subject: [PATCH 16/19] Update server.rb --- lib/puma/server.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/puma/server.rb b/lib/puma/server.rb index 0aceb23a0c..a1e90b9b67 100644 --- a/lib/puma/server.rb +++ b/lib/puma/server.rb @@ -34,7 +34,7 @@ class Server attr_reader :thread attr_reader :events - attr_reader :requests_count + attr_reader :requests_count # @version 5.0.0 attr_accessor :app attr_accessor :min_threads @@ -97,6 +97,7 @@ def inherit_binder(bind) class << self # :nodoc: + # @version 5.0.0 def tcp_cork_supported? RbConfig::CONFIG['host_os'] =~ /linux/ && Socket.const_defined?(:IPPROTO_TCP) && @@ -994,9 +995,11 @@ def possible_header_injection?(header_value) private :possible_header_injection? # List of methods invoked by #stats. + # @version 5.0.0 STAT_METHODS = [:backlog, :running, :pool_capacity, :max_threads, :requests_count].freeze # Returns a hash of stats about the running server for reporting purposes. + # @version 5.0.0 def stats STAT_METHODS.map {|name| [name, send(name) || 0]}.to_h end From cae6c037651799ce6272943bf096ba7c05ac9bc4 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Mon, 17 Aug 2020 21:58:36 -0500 Subject: [PATCH 17/19] Update signals.md --- docs/signals.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/signals.md b/docs/signals.md index 7026927bb4..123ab99387 100644 --- a/docs/signals.md +++ b/docs/signals.md @@ -38,10 +38,10 @@ Puma cluster responds to these signals: - `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. +- `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. - `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 From 4e3de5e35ff59b63463ff97972ef7cc3fa8be408 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 16 Sep 2020 18:33:31 -0500 Subject: [PATCH 18/19] Update thread_pool.rb --- lib/puma/thread_pool.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/puma/thread_pool.rb b/lib/puma/thread_pool.rb index bb6a73c73a..0e44f7458d 100644 --- a/lib/puma/thread_pool.rb +++ b/lib/puma/thread_pool.rb @@ -66,7 +66,7 @@ def initialize(min, max, *extra, &block) attr_reader :spawned, :trim_requested, :waiting attr_accessor :clean_thread_locals - attr_accessor :out_of_band_hook + attr_accessor :out_of_band_hook # @version 5.0.0 def self.clean_thread_locals Thread.current.keys.each do |key| # rubocop: disable Performance/HashEachMethods @@ -84,6 +84,7 @@ def pool_capacity waiting + (@max - spawned) end + # @version 5.0.0 def busy_threads with_mutex { @spawned - @waiting + @todo.size } end @@ -151,6 +152,7 @@ def spawn_thread private :spawn_thread + # @version 5.0.0 def trigger_out_of_band_hook return false unless out_of_band_hook && out_of_band_hook.any? @@ -166,6 +168,7 @@ def trigger_out_of_band_hook private :trigger_out_of_band_hook + # @version 5.0.0 def with_mutex(&block) @mutex.owned? ? yield : @@ -231,6 +234,7 @@ def wait_until_not_full end end + # @version 5.0.0 def wait_for_less_busy_worker(delay_s) # Ruby MRI does GVL, this can result # in processing contention when multiple threads From b2d44fcb42254606ea8c3509e10b81c0ec506559 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 16 Sep 2020 18:32:25 -0500 Subject: [PATCH 19/19] Update ext/puma_http11/mini_ssl.c --- ext/puma_http11/mini_ssl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ext/puma_http11/mini_ssl.c b/ext/puma_http11/mini_ssl.c index 4a13d3011b..fd964cf3f4 100644 --- a/ext/puma_http11/mini_ssl.c +++ b/ext/puma_http11/mini_ssl.c @@ -463,6 +463,9 @@ VALUE engine_peercert(VALUE self) { return rb_cert_buf; } +/* @see Puma::MiniSSL::Socket#ssl_version_state + * @version 5.0.0 + */ static VALUE engine_ssl_vers_st(VALUE self) { ms_conn* conn;