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-08-25 20:58:11
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-puma (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-puma.new.1899 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-puma"

Wed Aug 25 20:58:11 2021 rev:46 rq:914128 version:5.4.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-puma/rubygem-puma.changes        
2021-06-01 10:41:34.105232548 +0200
+++ /work/SRC/openSUSE:Factory/.rubygem-puma.new.1899/rubygem-puma.changes      
2021-08-25 20:59:42.245043361 +0200
@@ -1,0 +2,19 @@
+Wed Aug 25 05:21:15 UTC 2021 - Manuel Schnitzer <mschnit...@suse.com>
+
+- updated to version 5.4.0
+
+  * Features
+    * Better/expanded names for threadpool threads ([#2657])
+    * Allow pkg_config for OpenSSL ([#2648], [#1412])
+    * Add `rack_url_scheme` to Puma::DSL, allows setting of `rack.url_scheme` 
header ([#2586], [#2569])
+
+  * Bugfixes
+    * `Binder#parse` - allow for symlinked unix path, add create_activated_fds 
debug ENV ([#2643], [#2638])
+    * Fix deprecation warning: minissl.c - Use Random.bytes if available 
([#2642])
+    * Client certificates: set session id context while creating SSLContext 
([#2633])
+    * Fix deadlock issue in thread pool ([#2656])
+
+  * Refactor
+    * Replace `IO.select` with `IO#wait_*` when checking a single IO ([#2666])
+
+-------------------------------------------------------------------

Old:
----
  puma-5.3.2.gem

New:
----
  puma-5.4.0.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-puma.spec ++++++
--- /var/tmp/diff_new_pack.6tfJob/_old  2021-08-25 20:59:42.705042758 +0200
+++ /var/tmp/diff_new_pack.6tfJob/_new  2021-08-25 20:59:42.705042758 +0200
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-puma
-Version:        5.3.2
+Version:        5.4.0
 Release:        0
 %define mod_name puma
 %define mod_full_name %{mod_name}-%{version}

++++++ puma-5.3.2.gem -> puma-5.4.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/History.md new/History.md
--- old/History.md      2021-05-21 19:15:55.000000000 +0200
+++ new/History.md      2021-07-29 16:25:52.000000000 +0200
@@ -1,14 +1,29 @@
+## 5.4.0 / 2021-07-28
+
+* Features
+  * Better/expanded names for threadpool threads ([#2657])
+  * Allow pkg_config for OpenSSL ([#2648], [#1412])
+  * Add `rack_url_scheme` to Puma::DSL, allows setting of `rack.url_scheme` 
header ([#2586], [#2569])
+
+* Bugfixes
+  * `Binder#parse` - allow for symlinked unix path, add create_activated_fds 
debug ENV ([#2643], [#2638])
+  * Fix deprecation warning: minissl.c - Use Random.bytes if available 
([#2642])
+  * Client certificates: set session id context while creating SSLContext 
([#2633])
+
+* Refactor
+  * Replace `IO.select` with `IO#wait_*` when checking a single IO ([#2666])
+
 ## 5.3.2 / 2021-05-21
 
 * Bugfixes
-  * Gracefully handle Rack not accepting CLI options (#2630, #2626)
-  * Fix sigterm misbehavior (#2629)
-  * Improvements to keepalive-connection shedding (#2628)
+  * Gracefully handle Rack not accepting CLI options ([#2630], [#2626])
+  * Fix sigterm misbehavior ([#2629])
+  * Improvements to keepalive-connection shedding ([#2628])
 
 ## 5.3.1 / 2021-05-11
 
 * Security
-  * Close keepalive connections after the maximum number of fast inlined 
requests (#2625)
+  * Close keepalive connections after the maximum number of fast inlined 
requests (CVE-2021-29509) ([#2625])
 
 ## 5.3.0 / 2021-05-07
 
@@ -223,7 +238,7 @@
 ## 4.3.8 / 2021-05-11
 
 * Security
-  * Close keepalive connections after the maximum number of fast inlined 
requests (#2625)
+  * Close keepalive connections after the maximum number of fast inlined 
requests (CVE-2021-29509) ([#2625])
 
 ## 4.3.7 / 2020-11-30
 
@@ -1753,6 +1768,21 @@
 * Bugfixes
   * Your bugfix goes here <Most recent on the top, like GitHub> (#Github 
Number)
 
+[#2657]:https://github.com/puma/puma/pull/2657     "PR by @olivierbellone, 
merged 2021-07-13"
+[#2648]:https://github.com/puma/puma/pull/2648     "PR by @MSP-Greg, merged 
2021-06-27"
+[#1412]:https://github.com/puma/puma/issues/1412   "Issue by @x-yuri, closed 
2021-06-27"
+[#2586]:https://github.com/puma/puma/pull/2586     "PR by @MSP-Greg, merged 
2021-05-26"
+[#2569]:https://github.com/puma/puma/issues/2569   "Issue by @tarragon, closed 
2021-05-26"
+[#2643]:https://github.com/puma/puma/pull/2643     "PR by @MSP-Greg, merged 
2021-06-27"
+[#2638]:https://github.com/puma/puma/issues/2638   "Issue by @gingerlime, 
closed 2021-06-27"
+[#2642]:https://github.com/puma/puma/pull/2642     "PR by @MSP-Greg, merged 
2021-06-16"
+[#2633]:https://github.com/puma/puma/pull/2633     "PR by @onlined, merged 
2021-06-04"
+[#2666]:https://github.com/puma/puma/pull/2666     "PR by @MSP-Greg, merged 
2021-07-25"
+[#2630]:https://github.com/puma/puma/pull/2630     "PR by @seangoedecke, 
merged 2021-05-20"
+[#2626]:https://github.com/puma/puma/issues/2626   "Issue by @rorymckinley, 
closed 2021-05-20"
+[#2629]:https://github.com/puma/puma/pull/2629     "PR by @ye-lin-aung, merged 
2021-05-20"
+[#2628]:https://github.com/puma/puma/pull/2628     "PR by @wjordan, merged 
2021-05-20"
+[#2625]:https://github.com/puma/puma/issues/2625   "Issue by @jarthod, closed 
2021-05-11"
 [#2564]:https://github.com/puma/puma/pull/2564     "PR by @MSP-Greg, merged 
2021-04-24"
 [#2526]:https://github.com/puma/puma/issues/2526   "Issue by @nerdrew, closed 
2021-04-24"
 [#2559]:https://github.com/puma/puma/pull/2559     "PR by @ylecuyer, merged 
2021-03-11"
@@ -1767,7 +1797,7 @@
 [#2605]:https://github.com/puma/puma/pull/2605     "PR by @pascalbetz, merged 
2021-04-26"
 [#2584]:https://github.com/puma/puma/issues/2584   "Issue by @kaorihinata, 
closed 2021-04-26"
 [#2607]:https://github.com/puma/puma/pull/2607     "PR by @calvinxiao, merged 
2021-04-23"
-[#2552]:https://github.com/puma/puma/issues/2552   "Issue by @feliperaul, 
opened 2021-02-09"
+[#2552]:https://github.com/puma/puma/issues/2552   "Issue by @feliperaul, 
closed 2021-05-24"
 [#2606]:https://github.com/puma/puma/pull/2606     "PR by @wjordan, merged 
2021-04-20"
 [#2574]:https://github.com/puma/puma/issues/2574   "Issue by @darkhelmet, 
closed 2021-04-20"
 [#2567]:https://github.com/puma/puma/pull/2567     "PR by @kddeisz, merged 
2021-04-19"
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/docs/deployment.md new/docs/deployment.md
--- old/docs/deployment.md      2021-05-21 19:15:55.000000000 +0200
+++ new/docs/deployment.md      2021-07-29 16:25:52.000000000 +0200
@@ -97,20 +97,5 @@
 ## Restarting
 
 You probably will want to deploy some new code at some point, and you'd like
-puma to start running that new code. Minimizing the amount of time the server
-is unavailable would be nice as well. Here's how to do it:
-
-1. Don't use `preload!`. This dirties the master process and means it will have
-to shutdown all the workers and re-exec itself to get your new code. It is not 
compatible with phased-restart and `prune_bundler` as well.
-
-1. Use `prune_bundler`. This makes it so that the cluster master will detach 
itself
-from a Bundler context on start. This allows the cluster workers to load your 
app
-and start a brand new Bundler context within the worker only. This means your
-master remains pristine and can live on between new releases of your code.
-
-1. Use phased-restart (`SIGUSR1` or `pumactl phased-restart`). This tells the 
master
-to kill off one worker at a time and restart them in your new code. This 
minimizes
-downtime and staggers the restart nicely. **WARNING** This means that both your
-old code and your new code will be running concurrently. Most deployment 
solutions
-already cause that, but it's worth warning you about it again. Be careful with 
your
-migrations, etc!
+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/ext/puma_http11/extconf.rb 
new/ext/puma_http11/extconf.rb
--- old/ext/puma_http11/extconf.rb      2021-05-21 19:15:55.000000000 +0200
+++ new/ext/puma_http11/extconf.rb      2021-07-29 16:25:52.000000000 +0200
@@ -11,9 +11,18 @@
 unless ENV["DISABLE_SSL"]
   dir_config("openssl")
 
-  if %w'crypto libeay32'.find {|crypto| have_library(crypto, 'BIO_read')} and
+  found_ssl = if pkg_config 'openssl'
+    puts 'using OpenSSL pkgconfig (openssl.pc)'
+    true
+  elsif %w'crypto libeay32'.find {|crypto| have_library(crypto, 'BIO_read')} &&
       %w'ssl ssleay32'.find {|ssl| have_library(ssl, 'SSL_CTX_new')}
+    true
+  else
+    puts '** Puma will be compiled without SSL support'
+    false
+  end
 
+  if found_ssl
     have_header "openssl/bio.h"
 
     # below is  yes for 1.0.2 & later
@@ -25,6 +34,14 @@
 
     have_func  "X509_STORE_up_ref"
     have_func("SSL_CTX_set_ecdh_auto(NULL, 0)", "openssl/ssl.h")
+
+    # Random.bytes available in Ruby 2.5 and later, Random::DEFAULT deprecated 
in 3.0
+    if Random.respond_to?(:bytes)
+      $defs.push("-DHAVE_RANDOM_BYTES")
+      puts "checking for Random.bytes... yes"
+    else
+      puts "checking for Random.bytes... no"
+    end
   end
 end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ext/puma_http11/mini_ssl.c 
new/ext/puma_http11/mini_ssl.c
--- old/ext/puma_http11/mini_ssl.c      2021-05-21 19:15:55.000000000 +0200
+++ new/ext/puma_http11/mini_ssl.c      2021-07-29 16:25:52.000000000 +0200
@@ -208,7 +208,7 @@
 #endif
   int ssl_options;
   VALUE key, cert, ca, verify_mode, ssl_cipher_filter, no_tlsv1, no_tlsv1_1,
-    verification_flags;
+    verification_flags, session_id_bytes;
   DH *dh;
 
 #if OPENSSL_VERSION_NUMBER < 0x10002000L
@@ -309,6 +309,21 @@
   } else {
     SSL_CTX_set_verify(ctx, NUM2INT(verify_mode), engine_verify_callback);
   }
+
+  // Random.bytes available in Ruby 2.5 and later, Random::DEFAULT deprecated 
in 3.0
+  session_id_bytes = rb_funcall(
+#ifdef HAVE_RANDOM_BYTES
+    rb_cRandom,
+#else
+    rb_const_get(rb_cRandom, rb_intern_const("DEFAULT")),
+#endif
+    rb_intern_const("bytes"),
+    1, ULL2NUM(SSL_MAX_SSL_SESSION_ID_LENGTH));
+
+  SSL_CTX_set_session_id_context(ctx,
+                                 (unsigned char *) 
RSTRING_PTR(session_id_bytes),
+                                 SSL_MAX_SSL_SESSION_ID_LENGTH);
+
   // printf("\ninitialize end security_level %d\n", 
SSL_CTX_get_security_level(ctx));
   rb_obj_freeze(self);
   return self;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/puma/app/status.rb new/lib/puma/app/status.rb
--- old/lib/puma/app/status.rb  2021-05-21 19:15:55.000000000 +0200
+++ new/lib/puma/app/status.rb  2021-07-29 16:25:52.000000000 +0200
@@ -1,5 +1,5 @@
 # frozen_string_literal: true
-require 'puma/json'
+require 'puma/json_serialization'
 
 module Puma
   module App
@@ -46,17 +46,17 @@
             GC.start ; 200
 
           when 'gc-stats'
-            Puma::JSON.generate GC.stat
+            Puma::JSONSerialization.generate GC.stat
 
           when 'stats'
-            Puma::JSON.generate @launcher.stats
+            Puma::JSONSerialization.generate @launcher.stats
 
           when 'thread-backtraces'
             backtraces = []
             @launcher.thread_status do |name, backtrace|
               backtraces << { name: name, backtrace: backtrace }
             end
-            Puma::JSON.generate backtraces
+            Puma::JSONSerialization.generate backtraces
 
           else
             return rack_response(404, "Unsupported action", 'text/plain')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/puma/binder.rb new/lib/puma/binder.rb
--- old/lib/puma/binder.rb      2021-05-21 19:15:55.000000000 +0200
+++ new/lib/puma/binder.rb      2021-07-29 16:25:52.000000000 +0200
@@ -41,6 +41,7 @@
         "rack.multithread".freeze => conf.options[:max_threads] > 1,
         "rack.multiprocess".freeze => conf.options[:workers] >= 1,
         "rack.run_once".freeze => false,
+        RACK_URL_SCHEME => conf.options[:rack_url_scheme],
         "SCRIPT_NAME".freeze => ENV['SCRIPT_NAME'] || "",
 
         # I'd like to set a default CONTENT_TYPE here but some things
@@ -95,6 +96,7 @@
     # @version 5.0.0
     #
     def create_activated_fds(env_hash)
+      @events.debug "ENV['LISTEN_FDS'] #{ENV['LISTEN_FDS'].inspect}  
env_hash['LISTEN_PID'] #{env_hash['LISTEN_PID'].inspect}"
       return [] unless env_hash['LISTEN_FDS'] && env_hash['LISTEN_PID'].to_i 
== $$
       env_hash['LISTEN_FDS'].to_i.times do |index|
         sock = TCPServer.for_fd(socket_activation_fd(index))
@@ -188,7 +190,8 @@
             @unix_paths << path unless abstract
             io = inherit_unix_listener path, fd
             logger.log "* Inherited #{str}"
-          elsif sock = @activated_sockets.delete([ :unix, path ])
+          elsif sock = @activated_sockets.delete([ :unix, path ]) ||
+              @activated_sockets.delete([ :unix, File.realdirpath(path) ])
             @unix_paths << path unless abstract || File.exist?(path)
             io = inherit_unix_listener path, sock
             logger.log "* Activated #{str}"
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-05-21 19:15:55.000000000 +0200
+++ new/lib/puma/client.rb      2021-07-29 16:25:52.000000000 +0200
@@ -143,8 +143,7 @@
         return false
       else
         begin
-          if fast_check &&
-              IO.select([@to_io], nil, nil, FAST_TRACK_KA_TIMEOUT)
+          if fast_check && @to_io.wait_readable(FAST_TRACK_KA_TIMEOUT)
             return try_to_finish
           end
         rescue IOError
@@ -202,13 +201,13 @@
 
     def eagerly_finish
       return true if @ready
-      return false unless IO.select([@to_io], nil, nil, 0)
+      return false unless @to_io.wait_readable(0)
       try_to_finish
     end
 
     def finish(timeout)
       return if @ready
-      IO.select([@to_io], nil, nil, timeout) || timeout! until try_to_finish
+      @to_io.wait_readable(timeout) || timeout! until try_to_finish
     end
 
     def timeout!
@@ -309,7 +308,7 @@
 
       @body_remain = remain
 
-      return false
+      false
     end
 
     def read_body
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-05-21 19:15:55.000000000 +0200
+++ new/lib/puma/cluster/worker.rb      2021-07-29 16:25:52.000000000 +0200
@@ -35,7 +35,7 @@
 
        Thread.new do
           Puma.set_thread_name "worker check pipe"
-          IO.select [@check_pipe]
+          @check_pipe.wait_readable
           log "! Detected parent died, dying"
           exit! 1
         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-05-21 19:15:55.000000000 +0200
+++ new/lib/puma/cluster.rb     2021-07-29 16:25:52.000000000 +0200
@@ -426,9 +426,7 @@
 
             check_workers
 
-            res = IO.select([read], nil, nil, [0, @next_check - Time.now].max)
-
-            if res
+            if read.wait_readable([0, @next_check - Time.now].max)
               req = read.read_nonblock(1)
 
               @next_check = Time.now if req == "!"
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-05-21 19:15:55.000000000 +0200
+++ new/lib/puma/const.rb       2021-07-29 16:25:52.000000000 +0200
@@ -100,8 +100,8 @@
   # too taxing on performance.
   module Const
 
-    PUMA_VERSION = VERSION = "5.3.2".freeze
-    CODE_NAME = "Sweetnighter".freeze
+    PUMA_VERSION = VERSION = "5.4.0".freeze
+    CODE_NAME = "Super Flight".freeze
 
     PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/puma/dsl.rb new/lib/puma/dsl.rb
--- old/lib/puma/dsl.rb 2021-05-21 19:15:55.000000000 +0200
+++ new/lib/puma/dsl.rb 2021-07-29 16:25:52.000000000 +0200
@@ -381,6 +381,13 @@
       @options[:rackup] ||= path.to_s
     end
 
+    # Allows setting `env['rack.url_scheme']`.
+    # Only necessary if X-Forwarded-Proto is not being set by your proxy
+    # Normal values are 'http' or 'https'.
+    def rack_url_scheme(scheme=nil)
+      @options[:rack_url_scheme] = scheme
+    end
+
     def early_hints(answer=true)
       @options[:early_hints] = answer
     end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/puma/json.rb new/lib/puma/json.rb
--- old/lib/puma/json.rb        2021-05-21 19:15:55.000000000 +0200
+++ new/lib/puma/json.rb        1970-01-01 01:00:00.000000000 +0100
@@ -1,96 +0,0 @@
-# frozen_string_literal: true
-require 'stringio'
-
-module Puma
-
-  # Puma deliberately avoids the use of the json gem and instead performs JSON
-  # serialization without any external dependencies. In a puma cluster, loading
-  # any gem into the puma master process means that operators cannot use a
-  # phased restart to upgrade their application if the new version of that
-  # application uses a different version of that gem. The json gem in
-  # particular is additionally problematic because it leverages native
-  # extensions. If the puma master process relies on a gem with native
-  # extensions and operators remove gems from disk related to old releases,
-  # subsequent phased restarts can fail.
-  #
-  # The implementation of JSON serialization in this module is not designed to
-  # be particularly full-featured or fast. It just has to handle the few places
-  # where Puma relies on JSON serialization internally.
-
-  module JSON
-    QUOTE = /"/
-    BACKSLASH = /\\/
-    CONTROL_CHAR_TO_ESCAPE = /[\x00-\x1F]/ # As required by ECMA-404
-    CHAR_TO_ESCAPE = Regexp.union QUOTE, BACKSLASH, CONTROL_CHAR_TO_ESCAPE
-
-    class SerializationError < StandardError; end
-
-    class << self
-      def generate(value)
-        StringIO.open do |io|
-          serialize_value io, value
-          io.string
-        end
-      end
-
-      private
-
-      def serialize_value(output, value)
-        case value
-        when Hash
-          output << '{'
-          value.each_with_index do |(k, v), index|
-            output << ',' if index != 0
-            serialize_object_key output, k
-            output << ':'
-            serialize_value output, v
-          end
-          output << '}'
-        when Array
-          output << '['
-          value.each_with_index do |member, index|
-            output << ',' if index != 0
-            serialize_value output, member
-          end
-          output << ']'
-        when Integer, Float
-          output << value.to_s
-        when String
-          serialize_string output, value
-        when true
-          output << 'true'
-        when false
-          output << 'false'
-        when nil
-          output << 'null'
-        else
-          raise SerializationError, "Unexpected value of type #{value.class}"
-        end
-      end
-
-      def serialize_string(output, value)
-        output << '"'
-        output << value.gsub(CHAR_TO_ESCAPE) do |character|
-          case character
-          when BACKSLASH
-            '\\\\'
-          when QUOTE
-            '\\"'
-          when CONTROL_CHAR_TO_ESCAPE
-            '\u%.4X' % character.ord
-          end
-        end
-        output << '"'
-      end
-
-      def serialize_object_key(output, value)
-        case value
-        when Symbol, String
-          serialize_string output, value.to_s
-        else
-          raise SerializationError, "Could not serialize object of type 
#{value.class} as object key"
-        end
-      end
-    end
-  end
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/puma/json_serialization.rb 
new/lib/puma/json_serialization.rb
--- old/lib/puma/json_serialization.rb  1970-01-01 01:00:00.000000000 +0100
+++ new/lib/puma/json_serialization.rb  2021-07-29 16:25:52.000000000 +0200
@@ -0,0 +1,96 @@
+# frozen_string_literal: true
+require 'stringio'
+
+module Puma
+
+  # Puma deliberately avoids the use of the json gem and instead performs JSON
+  # serialization without any external dependencies. In a puma cluster, loading
+  # any gem into the puma master process means that operators cannot use a
+  # phased restart to upgrade their application if the new version of that
+  # application uses a different version of that gem. The json gem in
+  # particular is additionally problematic because it leverages native
+  # extensions. If the puma master process relies on a gem with native
+  # extensions and operators remove gems from disk related to old releases,
+  # subsequent phased restarts can fail.
+  #
+  # The implementation of JSON serialization in this module is not designed to
+  # be particularly full-featured or fast. It just has to handle the few places
+  # where Puma relies on JSON serialization internally.
+
+  module JSONSerialization
+    QUOTE = /"/
+    BACKSLASH = /\\/
+    CONTROL_CHAR_TO_ESCAPE = /[\x00-\x1F]/ # As required by ECMA-404
+    CHAR_TO_ESCAPE = Regexp.union QUOTE, BACKSLASH, CONTROL_CHAR_TO_ESCAPE
+
+    class SerializationError < StandardError; end
+
+    class << self
+      def generate(value)
+        StringIO.open do |io|
+          serialize_value io, value
+          io.string
+        end
+      end
+
+      private
+
+      def serialize_value(output, value)
+        case value
+        when Hash
+          output << '{'
+          value.each_with_index do |(k, v), index|
+            output << ',' if index != 0
+            serialize_object_key output, k
+            output << ':'
+            serialize_value output, v
+          end
+          output << '}'
+        when Array
+          output << '['
+          value.each_with_index do |member, index|
+            output << ',' if index != 0
+            serialize_value output, member
+          end
+          output << ']'
+        when Integer, Float
+          output << value.to_s
+        when String
+          serialize_string output, value
+        when true
+          output << 'true'
+        when false
+          output << 'false'
+        when nil
+          output << 'null'
+        else
+          raise SerializationError, "Unexpected value of type #{value.class}"
+        end
+      end
+
+      def serialize_string(output, value)
+        output << '"'
+        output << value.gsub(CHAR_TO_ESCAPE) do |character|
+          case character
+          when BACKSLASH
+            '\\\\'
+          when QUOTE
+            '\\"'
+          when CONTROL_CHAR_TO_ESCAPE
+            '\u%.4X' % character.ord
+          end
+        end
+        output << '"'
+      end
+
+      def serialize_object_key(output, value)
+        case value
+        when Symbol, String
+          serialize_string output, value.to_s
+        else
+          raise SerializationError, "Could not serialize object of type 
#{value.class} as object key"
+        end
+      end
+    end
+  end
+end
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-05-21 19:15:55.000000000 +0200
+++ new/lib/puma/minissl.rb     2021-07-29 16:25:52.000000000 +0200
@@ -162,7 +162,7 @@
       end
 
       def read_and_drop(timeout = 1)
-        return :timeout unless IO.select([@socket], nil, nil, timeout)
+        return :timeout unless @socket.wait_readable(timeout)
         case @socket.read_nonblock(1024, exception: false)
         when nil
           :eof
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/puma/plugin.rb new/lib/puma/plugin.rb
--- old/lib/puma/plugin.rb      2021-05-21 19:15:55.000000000 +0200
+++ new/lib/puma/plugin.rb      2021-07-29 16:25:52.000000000 +0200
@@ -91,7 +91,7 @@
       path = ary.first[CALLER_FILE]
 
       m = %r!puma/plugin/([^/]*)\.rb$!.match(path)
-      return m[1]
+      m[1]
     end
 
     def self.create(&blk)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/puma/rack/builder.rb new/lib/puma/rack/builder.rb
--- old/lib/puma/rack/builder.rb        2021-05-21 19:15:55.000000000 +0200
+++ new/lib/puma/rack/builder.rb        2021-07-29 16:25:52.000000000 +0200
@@ -165,7 +165,7 @@
         require config
         app = Object.const_get(::File.basename(config, '.rb').capitalize)
       end
-      return app, options
+      [app, options]
     end
 
     def self.new_from_string(builder_script, file="(rackup)")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/puma/request.rb new/lib/puma/request.rb
--- old/lib/puma/request.rb     2021-05-21 19:15:55.000000000 +0200
+++ new/lib/puma/request.rb     2021-07-29 16:25:52.000000000 +0200
@@ -51,7 +51,7 @@
       head = env[REQUEST_METHOD] == HEAD
 
       env[RACK_INPUT] = body
-      env[RACK_URL_SCHEME] = default_server_port(env) == PORT_443 ? HTTPS : 
HTTP
+      env[RACK_URL_SCHEME] ||= default_server_port(env) == PORT_443 ? HTTPS : 
HTTP
 
       if @early_hints
         env[EARLY_HINTS] = lambda { |headers|
@@ -176,7 +176,7 @@
         after_reply.each { |o| o.call }
       end
 
-      return res_info[:keep_alive]
+      res_info[:keep_alive]
     end
 
     # @param env [Hash] see Puma::Client#env, from request
@@ -201,7 +201,7 @@
         begin
           n = io.syswrite str
         rescue Errno::EAGAIN, Errno::EWOULDBLOCK
-          if !IO.select(nil, [io], nil, WRITE_TIMEOUT)
+          unless io.wait_writable WRITE_TIMEOUT
             raise ConnectionError, "Socket timeout writing data"
           end
 
@@ -419,7 +419,7 @@
       # of concurrent connections exceeds the size of the threadpool.
       res_info[:keep_alive] &&= requests < @max_fast_inline ||
         @thread_pool.busy_threads < @max_threads ||
-        !IO.select([client.listener], nil, nil, 0)
+        !client.listener.to_io.wait_readable(0)
 
       res_info[:response_hijack] = nil
 
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-05-21 19:15:55.000000000 +0200
+++ new/lib/puma/server.rb      2021-07-29 16:25:52.000000000 +0200
@@ -14,6 +14,7 @@
 require 'puma/request'
 
 require 'socket'
+require 'io/wait'
 require 'forwardable'
 
 module Puma
@@ -227,6 +228,7 @@
       @status = :run
 
       @thread_pool = ThreadPool.new(
+        thread_name,
         @min_threads,
         @max_threads,
         ::Puma::IOBuffer,
@@ -396,7 +398,7 @@
         return true
       end
 
-      return false
+      false
     end
 
     # Given a connection on +client+, handle the incoming requests,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/puma/thread_pool.rb new/lib/puma/thread_pool.rb
--- old/lib/puma/thread_pool.rb 2021-05-21 19:15:55.000000000 +0200
+++ new/lib/puma/thread_pool.rb 2021-07-29 16:25:52.000000000 +0200
@@ -29,7 +29,7 @@
     # The block passed is the work that will be performed in each
     # thread.
     #
-    def initialize(min, max, *extra, &block)
+    def initialize(name, min, max, *extra, &block)
       @not_empty = ConditionVariable.new
       @not_full = ConditionVariable.new
       @mutex = Mutex.new
@@ -39,6 +39,7 @@
       @spawned = 0
       @waiting = 0
 
+      @name = name
       @min = Integer(min)
       @max = Integer(max)
       @block = block
@@ -101,7 +102,7 @@
       @spawned += 1
 
       th = Thread.new(@spawned) do |spawned|
-        Puma.set_thread_name 'threadpool %03i' % spawned
+        Puma.set_thread_name '%s threadpool %03i' % [@name, spawned]
         todo  = @todo
         block = @block
         mutex = @mutex
@@ -119,6 +120,7 @@
                 @trim_requested -= 1
                 @spawned -= 1
                 @workers.delete th
+                not_full.signal
                 Thread.exit
               end
 
@@ -318,12 +320,12 @@
     end
 
     def auto_trim!(timeout=30)
-      @auto_trim = Automaton.new(self, timeout, "threadpool trimmer", :trim)
+      @auto_trim = Automaton.new(self, timeout, "#{@name} threadpool trimmer", 
:trim)
       @auto_trim.start!
     end
 
     def auto_reap!(timeout=5)
-      @reaper = Automaton.new(self, timeout, "threadpool reaper", :reap)
+      @reaper = Automaton.new(self, timeout, "#{@name} threadpool reaper", 
:reap)
       @reaper.start!
     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-05-21 19:15:55.000000000 +0200
+++ new/lib/puma/util.rb        2021-07-29 16:25:52.000000000 +0200
@@ -61,7 +61,7 @@
         end
       end
 
-      return params
+      params
     end
 
     # A case-insensitive Hash that preserves the original case of a
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/puma.rb new/lib/puma.rb
--- old/lib/puma.rb     2021-05-21 19:15:55.000000000 +0200
+++ new/lib/puma.rb     2021-07-29 16:25:52.000000000 +0200
@@ -12,7 +12,7 @@
 
 require 'puma/puma_http11'
 require 'puma/detect'
-require 'puma/json'
+require 'puma/json_serialization'
 
 module Puma
   autoload :Const, 'puma/const'
@@ -60,7 +60,7 @@
 
   # @!attribute [rw] stats_object
   def self.stats
-    Puma::JSON.generate @get_stats.stats
+    Puma::JSONSerialization.generate @get_stats.stats
   end
 
   # @!attribute [r] stats_hash
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2021-05-21 19:15:55.000000000 +0200
+++ new/metadata        2021-07-29 16:25:52.000000000 +0200
@@ -1,14 +1,14 @@
 --- !ruby/object:Gem::Specification
 name: puma
 version: !ruby/object:Gem::Version
-  version: 5.3.2
+  version: 5.4.0
 platform: ruby
 authors:
 - Evan Phoenix
 autorequire:
 bindir: bin
 cert_chain: []
-date: 2021-05-21 00:00:00.000000000 Z
+date: 2021-07-29 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: nio4r
@@ -94,7 +94,7 @@
 - lib/puma/events.rb
 - lib/puma/io_buffer.rb
 - lib/puma/jruby_restart.rb
-- lib/puma/json.rb
+- lib/puma/json_serialization.rb
 - lib/puma/launcher.rb
 - lib/puma/minissl.rb
 - lib/puma/minissl/context_builder.rb

Reply via email to