1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Move ssl detection to puma.rb (#2541)

puma.rb loads puma/puma_http11, which contains the compiled c code for ssl.  Move ssl detection from puma/detect.rb to puma.rb
This commit is contained in:
MSP-Greg 2021-02-01 15:10:28 -06:00 committed by GitHub
parent 03346ae1ec
commit 37f47cad94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 18 deletions

View file

@ -19,6 +19,24 @@ module Puma
autoload :Server, 'puma/server'
autoload :Launcher, 'puma/launcher'
# at present, MiniSSL::Engine is only defined in extension code (puma_http11),
# not in minissl.rb
HAS_SSL = const_defined?(:MiniSSL, false) && MiniSSL.const_defined?(:Engine, false)
if HAS_SSL
require 'puma/minissl'
else
module MiniSSL
# this class is defined so that it exists when Puma is compiled
# without ssl support, as Server and Reactor use it in rescue statements.
class SSLError < StandardError ; end
end
end
def self.ssl?
HAS_SSL
end
# @!attribute [rw] stats_object=
def self.stats_object=(val)
@get_stats = val
@ -40,12 +58,4 @@ module Puma
return unless Thread.current.respond_to?(:name=)
Thread.current.name = "puma #{name}"
end
unless HAS_SSL
module MiniSSL
# this class is defined so that it exists when Puma is compiled
# without ssl support, as Server and Reactor use it in rescue statements.
class SSLError < StandardError ; end
end
end
end

View file

@ -1,32 +1,36 @@
# frozen_string_literal: true
# This file can be loaded independently of puma.rb, so it cannot have any code
# that assumes puma.rb is loaded.
module Puma
# at present, MiniSSL::Engine is only defined in extension code, not in minissl.rb
HAS_SSL = const_defined?(:MiniSSL, false) && MiniSSL.const_defined?(:Engine, false)
# @version 5.2.1
HAS_FORK = ::Process.respond_to? :fork
def self.ssl?
HAS_SSL
end
IS_JRUBY = Object.const_defined? :JRUBY_VERSION
IS_JRUBY = defined?(JRUBY_VERSION)
IS_WINDOWS = !!(RUBY_PLATFORM =~ /mswin|ming|cygwin/ ||
IS_JRUBY && RUBY_DESCRIPTION =~ /mswin/)
# @version 5.2.0
IS_MRI = (RUBY_ENGINE == 'ruby' || RUBY_ENGINE.nil?)
def self.jruby?
IS_JRUBY
end
IS_WINDOWS = RUBY_PLATFORM =~ /mswin|ming|cygwin/
def self.windows?
IS_WINDOWS
end
# @version 5.0.0
def self.mri?
RUBY_ENGINE == 'ruby' || RUBY_ENGINE.nil?
IS_MRI
end
# @version 5.0.0
def self.forkable?
::Process.respond_to?(:fork)
HAS_FORK
end
end