jun-puma 1.0.0-java → 1.0.1-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,14 +15,14 @@ module Puma
15
15
 
16
16
  LOG_QUEUE = Queue.new
17
17
 
18
- def initialize(ioerr, env: ENV)
18
+ def initialize(ioerr)
19
19
  @ioerr = ioerr
20
20
 
21
- @debug = env.key?('PUMA_DEBUG')
21
+ @debug = ENV.key? 'PUMA_DEBUG'
22
22
  end
23
23
 
24
- def self.stdio(env: ENV)
25
- new($stderr, env: env)
24
+ def self.stdio
25
+ new $stderr
26
26
  end
27
27
 
28
28
  # Print occurred error details.
@@ -6,6 +6,22 @@ module Puma
6
6
  module JRubyRestart
7
7
  extend FFI::Library
8
8
  ffi_lib 'c'
9
+
10
+ attach_function :execlp, [:string, :varargs], :int
9
11
  attach_function :chdir, [:string], :int
12
+ attach_function :fork, [], :int
13
+ attach_function :exit, [:int], :void
14
+ attach_function :setsid, [], :int
15
+
16
+ def self.chdir_exec(dir, argv)
17
+ chdir(dir)
18
+ cmd = argv.first
19
+ argv = ([:string] * argv.size).zip(argv)
20
+ argv.flatten!
21
+ argv << :string
22
+ argv << nil
23
+ execlp(cmd, *argv)
24
+ raise SystemCallError.new(FFI.errno)
25
+ end
10
26
  end
11
27
  end
data/lib/puma/launcher.rb CHANGED
@@ -46,8 +46,6 @@ module Puma
46
46
  @original_argv = @argv.dup
47
47
  @config = conf
48
48
 
49
- env = launcher_args.delete(:env) || ENV
50
-
51
49
  @config.options[:log_writer] = @log_writer
52
50
 
53
51
  # Advertise the Configuration
@@ -64,7 +62,7 @@ module Puma
64
62
  # Load the systemd integration if we detect systemd's NOTIFY_SOCKET.
65
63
  # Skip this on JRuby though, because it is incompatible with the systemd
66
64
  # integration due to https://github.com/jruby/jruby/issues/6504
67
- if ENV["NOTIFY_SOCKET"] && !Puma.jruby? && !ENV["PUMA_SKIP_SYSTEMD"]
65
+ if ENV["NOTIFY_SOCKET"] && !Puma.jruby?
68
66
  @config.plugins.create('systemd')
69
67
  end
70
68
 
@@ -107,7 +105,7 @@ module Puma
107
105
 
108
106
  @status = :run
109
107
 
110
- log_config if env['PUMA_LOG_CONFIG']
108
+ log_config if ENV['PUMA_LOG_CONFIG']
111
109
  end
112
110
 
113
111
  attr_reader :binder, :log_writer, :events, :config, :options, :restart_dir
@@ -289,9 +287,7 @@ module Puma
289
287
  close_binder_listeners
290
288
 
291
289
  require_relative 'jruby_restart'
292
- argv = restart_args
293
- JRubyRestart.chdir(@restart_dir)
294
- Kernel.exec(*argv)
290
+ JRubyRestart.chdir_exec(@restart_dir, restart_args)
295
291
  elsif Puma.windows?
296
292
  close_binder_listeners
297
293
 
@@ -31,31 +31,31 @@ module Puma
31
31
  attr_accessor :formatter, :custom_logger
32
32
 
33
33
  # Create a LogWriter that prints to +stdout+ and +stderr+.
34
- def initialize(stdout, stderr, env: ENV)
34
+ def initialize(stdout, stderr)
35
35
  @formatter = DefaultFormatter.new
36
36
  @custom_logger = nil
37
37
  @stdout = stdout
38
38
  @stderr = stderr
39
39
 
40
- @debug = env.key?('PUMA_DEBUG')
41
- @error_logger = ErrorLogger.new(@stderr, env: env)
40
+ @debug = ENV.key?('PUMA_DEBUG')
41
+ @error_logger = ErrorLogger.new(@stderr)
42
42
  end
43
43
 
44
44
  DEFAULT = new(STDOUT, STDERR)
45
45
 
46
46
  # Returns an LogWriter object which writes its status to
47
47
  # two StringIO objects.
48
- def self.strings(env: ENV)
49
- LogWriter.new(StringIO.new, StringIO.new, env: env)
48
+ def self.strings
49
+ LogWriter.new(StringIO.new, StringIO.new)
50
50
  end
51
51
 
52
- def self.stdio(env: ENV)
53
- LogWriter.new($stdout, $stderr, env: env)
52
+ def self.stdio
53
+ LogWriter.new($stdout, $stderr)
54
54
  end
55
55
 
56
- def self.null(env: ENV)
56
+ def self.null
57
57
  n = NullIO.new
58
- LogWriter.new(n, n, env: env)
58
+ LogWriter.new(n, n)
59
59
  end
60
60
 
61
61
  # Write +str+ to +@stdout+
@@ -57,7 +57,6 @@ module Puma
57
57
 
58
58
  ctx.ca = params['ca'] if params['ca']
59
59
  ctx.ssl_cipher_filter = params['ssl_cipher_filter'] if params['ssl_cipher_filter']
60
- ctx.ssl_ciphersuites = params['ssl_ciphersuites'] if params['ssl_ciphersuites'] && HAS_TLS1_3
61
60
 
62
61
  ctx.reuse = params['reuse'] if params['reuse']
63
62
  end
data/lib/puma/minissl.rb CHANGED
@@ -289,7 +289,6 @@ module Puma
289
289
  attr_reader :cert_pem
290
290
  attr_reader :key_pem
291
291
  attr_accessor :ssl_cipher_filter
292
- attr_accessor :ssl_ciphersuites
293
292
  attr_accessor :verification_flags
294
293
 
295
294
  attr_reader :reuse, :reuse_cache_size, :reuse_timeout
data/lib/puma/null_io.rb CHANGED
@@ -16,38 +16,15 @@ module Puma
16
16
  def each
17
17
  end
18
18
 
19
- def pos
20
- 0
21
- end
22
-
23
19
  # Mimics IO#read with no data.
24
20
  #
25
- def read(length = nil, buffer = nil)
26
- if length.to_i < 0
27
- raise ArgumentError, "(negative length #{length} given)"
28
- end
29
-
30
- buffer = if buffer.nil?
31
- "".b
32
- else
33
- String.try_convert(buffer) or raise TypeError, "no implicit conversion of #{buffer.class} into String"
34
- end
35
- buffer.clear
36
- if length.to_i > 0
37
- nil
38
- else
39
- buffer
40
- end
21
+ def read(count = nil, _buffer = nil)
22
+ count && count > 0 ? nil : ""
41
23
  end
42
24
 
43
25
  def rewind
44
26
  end
45
27
 
46
- def seek(pos, whence = 0)
47
- raise ArgumentError, "negative length #{pos} given" if pos.negative?
48
- 0
49
- end
50
-
51
28
  def close
52
29
  end
53
30
 
Binary file
data/lib/puma/request.rb CHANGED
@@ -53,6 +53,7 @@ module Puma
53
53
  socket = client.io # io may be a MiniSSL::Socket
54
54
  app_body = nil
55
55
 
56
+
56
57
  return false if closed_socket?(socket)
57
58
 
58
59
  if client.http_content_length_limit_exceeded
@@ -134,7 +135,7 @@ module Puma
134
135
  io_buffer.reset
135
136
  uncork_socket client.io
136
137
  app_body.close if app_body.respond_to? :close
137
- client&.tempfile_close
138
+ client.tempfile&.unlink
138
139
  after_reply = env[RACK_AFTER_REPLY] || []
139
140
  begin
140
141
  after_reply.each { |o| o.call }
@@ -164,14 +165,9 @@ module Puma
164
165
  # if the server is at capacity and the listener has a new connection ready.
165
166
  # This allows Puma to service connections fairly when the number
166
167
  # of concurrent connections exceeds the size of the threadpool.
167
- force_keep_alive = if @enable_keep_alives
168
- requests < @max_fast_inline ||
168
+ force_keep_alive = requests < @max_fast_inline ||
169
169
  @thread_pool.busy_threads < @max_threads ||
170
170
  !client.listener.to_io.wait_readable(0)
171
- else
172
- # Always set force_keep_alive to false if the server has keep-alives not enabled.
173
- false
174
- end
175
171
 
176
172
  resp_info = str_headers(env, status, headers, res_body, io_buffer, force_keep_alive)
177
173
 
@@ -499,11 +495,6 @@ module Puma
499
495
  # compatibility, we'll convert them back. This code is written to
500
496
  # avoid allocation in the common case (ie there are no headers
501
497
  # with `,` in their names), that's why it has the extra conditionals.
502
- #
503
- # @note If a normalized version of a `,` header already exists, we ignore
504
- # the `,` version. This prevents clobbering headers managed by proxies
505
- # but not by clients (Like X-Forwarded-For).
506
- #
507
498
  # @param env [Hash] see Puma::Client#env, from request, modifies in place
508
499
  # @version 5.0.3
509
500
  #
@@ -512,31 +503,23 @@ module Puma
512
503
  to_add = nil
513
504
 
514
505
  env.each do |k,v|
515
- if k.start_with?("HTTP_") && k.include?(",") && !UNMASKABLE_HEADERS.key?(k)
506
+ if k.start_with?("HTTP_") && k.include?(",") && k != "HTTP_TRANSFER,ENCODING"
516
507
  if to_delete
517
508
  to_delete << k
518
509
  else
519
510
  to_delete = [k]
520
511
  end
521
512
 
522
- new_k = k.tr(",", "_")
523
- if env.key?(new_k)
524
- next
525
- end
526
-
527
513
  unless to_add
528
514
  to_add = {}
529
515
  end
530
516
 
531
- to_add[new_k] = v
517
+ to_add[k.tr(",", "_")] = v
532
518
  end
533
519
  end
534
520
 
535
- if to_delete # rubocop:disable Style/SafeNavigation
521
+ if to_delete
536
522
  to_delete.each { |k| env.delete(k) }
537
- end
538
-
539
- if to_add
540
523
  env.merge! to_add
541
524
  end
542
525
  end
data/lib/puma/runner.rb CHANGED
@@ -27,7 +27,7 @@ module Puma
27
27
  def wakeup!
28
28
  return unless @wakeup
29
29
 
30
- @wakeup.write Puma::Const::PipeRequest::WAKEUP unless @wakeup.closed?
30
+ @wakeup.write "!" unless @wakeup.closed?
31
31
 
32
32
  rescue SystemCallError, IOError
33
33
  Puma::Util.purge_interrupt_queue
data/lib/puma/server.rb CHANGED
@@ -18,9 +18,6 @@ require 'io/wait' unless Puma::HAS_NATIVE_IO_WAIT
18
18
 
19
19
  module Puma
20
20
 
21
- # This method was private on Ruby 2.4 but became public on Ruby 2.5+:
22
- Thread.send(:attr_accessor, :puma_server)
23
-
24
21
  # The HTTP Server itself. Serves out a single Rack app.
25
22
  #
26
23
  # This class is used by the `Puma::Single` and `Puma::Cluster` classes
@@ -35,12 +32,12 @@ module Puma
35
32
  include Puma::Const
36
33
  include Request
37
34
 
38
- attr_reader :options
39
35
  attr_reader :thread
40
36
  attr_reader :log_writer
41
37
  attr_reader :events
42
38
  attr_reader :min_threads, :max_threads # for #stats
43
39
  attr_reader :requests_count # @version 5.0.0
40
+ attr_reader :idle_timeout_reached
44
41
 
45
42
  # @todo the following may be deprecated in the future
46
43
  attr_reader :auto_trim_time, :early_hints, :first_data_timeout,
@@ -50,6 +47,7 @@ module Puma
50
47
  attr_accessor :app
51
48
  attr_accessor :binder
52
49
 
50
+ THREAD_LOCAL_KEY = :puma_server
53
51
 
54
52
  # Create a server for the rack app +app+.
55
53
  #
@@ -84,8 +82,6 @@ module Puma
84
82
  UserFileDefaultOptions.new(options, Configuration::DEFAULTS)
85
83
  end
86
84
 
87
- @clustered = (@options.fetch :workers, 0) > 0
88
- @worker_write = @options[:worker_write]
89
85
  @log_writer = @options.fetch :log_writer, LogWriter.stdio
90
86
  @early_hints = @options[:early_hints]
91
87
  @first_data_timeout = @options[:first_data_timeout]
@@ -95,7 +91,6 @@ module Puma
95
91
  @max_threads = @options[:max_threads]
96
92
  @queue_requests = @options[:queue_requests]
97
93
  @max_fast_inline = @options[:max_fast_inline]
98
- @enable_keep_alives = @options[:enable_keep_alives]
99
94
  @io_selector_backend = @options[:io_selector_backend]
100
95
  @http_content_length_limit = @options[:http_content_length_limit]
101
96
 
@@ -134,7 +129,7 @@ module Puma
134
129
  class << self
135
130
  # @!attribute [r] current
136
131
  def current
137
- Thread.current.puma_server
132
+ Thread.current[THREAD_LOCAL_KEY]
138
133
  end
139
134
 
140
135
  # :nodoc:
@@ -246,7 +241,7 @@ module Puma
246
241
 
247
242
  @status = :run
248
243
 
249
- @thread_pool = ThreadPool.new(thread_name, options) { |client| process_client client }
244
+ @thread_pool = ThreadPool.new(thread_name, @options) { |client| process_client client }
250
245
 
251
246
  if @queue_requests
252
247
  @reactor = Reactor.new(@io_selector_backend) { |c| reactor_wakeup c }
@@ -254,8 +249,8 @@ module Puma
254
249
  end
255
250
 
256
251
 
257
- @thread_pool.auto_reap! if options[:reaping_time]
258
- @thread_pool.auto_trim! if options[:auto_trim_time]
252
+ @thread_pool.auto_reap! if @options[:reaping_time]
253
+ @thread_pool.auto_trim! if @options[:auto_trim_time]
259
254
 
260
255
  @check, @notify = Puma::Util.pipe unless @notify
261
256
 
@@ -319,15 +314,15 @@ module Puma
319
314
  sockets = [check] + @binder.ios
320
315
  pool = @thread_pool
321
316
  queue_requests = @queue_requests
322
- drain = options[:drain_on_shutdown] ? 0 : nil
317
+ drain = @options[:drain_on_shutdown] ? 0 : nil
323
318
 
324
- addr_send_name, addr_value = case options[:remote_address]
319
+ addr_send_name, addr_value = case @options[:remote_address]
325
320
  when :value
326
- [:peerip=, options[:remote_address_value]]
321
+ [:peerip=, @options[:remote_address_value]]
327
322
  when :header
328
- [:remote_addr_header=, options[:remote_address_header]]
323
+ [:remote_addr_header=, @options[:remote_address_header]]
329
324
  when :proxy_protocol
330
- [:expect_proxy_proto=, options[:remote_address_proxy_protocol]]
325
+ [:expect_proxy_proto=, @options[:remote_address_proxy_protocol]]
331
326
  else
332
327
  [nil, nil]
333
328
  end
@@ -338,30 +333,18 @@ module Puma
338
333
  unless ios
339
334
  unless shutting_down?
340
335
  @idle_timeout_reached = true
341
-
342
- if @clustered
343
- @worker_write << "#{PipeRequest::IDLE}#{Process.pid}\n" rescue nil
344
- next
345
- else
346
- @log_writer.log "- Idle timeout reached"
347
- @status = :stop
348
- end
336
+ @status = :stop
349
337
  end
350
338
 
351
339
  break
352
340
  end
353
341
 
354
- if @idle_timeout_reached && @clustered
355
- @idle_timeout_reached = false
356
- @worker_write << "#{PipeRequest::IDLE}#{Process.pid}\n" rescue nil
357
- end
358
-
359
342
  ios.first.each do |sock|
360
343
  if sock == check
361
344
  break if handle_check
362
345
  else
363
346
  pool.wait_until_not_full
364
- pool.wait_for_less_busy_worker(options[:wait_for_less_busy_worker])
347
+ pool.wait_for_less_busy_worker(@options[:wait_for_less_busy_worker])
365
348
 
366
349
  io = begin
367
350
  sock.accept_nonblock
@@ -441,9 +424,9 @@ module Puma
441
424
  # Return true if one or more requests were processed.
442
425
  def process_client(client)
443
426
  # Advertise this server into the thread
444
- Thread.current.puma_server = self
427
+ Thread.current[THREAD_LOCAL_KEY] = self
445
428
 
446
- clean_thread_locals = options[:clean_thread_locals]
429
+ clean_thread_locals = @options[:clean_thread_locals]
447
430
  close_socket = true
448
431
 
449
432
  requests = 0
@@ -552,7 +535,7 @@ module Puma
552
535
  # A fallback rack response if +@app+ raises as exception.
553
536
  #
554
537
  def lowlevel_error(e, env, status=500)
555
- if handler = options[:lowlevel_error_handler]
538
+ if handler = @options[:lowlevel_error_handler]
556
539
  if handler.arity == 1
557
540
  return handler.call(e)
558
541
  elsif handler.arity == 2
@@ -573,13 +556,14 @@ module Puma
573
556
  def response_to_error(client, requests, err, status_code)
574
557
  status, headers, res_body = lowlevel_error(err, client.env, status_code)
575
558
  prepare_response(status, headers, res_body, requests, client)
559
+ client.write_error(status_code)
576
560
  end
577
561
  private :response_to_error
578
562
 
579
563
  # Wait for all outstanding requests to finish.
580
564
  #
581
565
  def graceful_shutdown
582
- if options[:shutdown_debug]
566
+ if @options[:shutdown_debug]
583
567
  threads = Thread.list
584
568
  total = threads.size
585
569
 
@@ -599,7 +583,7 @@ module Puma
599
583
  end
600
584
 
601
585
  if @thread_pool
602
- if timeout = options[:force_shutdown_after]
586
+ if timeout = @options[:force_shutdown_after]
603
587
  @thread_pool.shutdown timeout.to_f
604
588
  else
605
589
  @thread_pool.shutdown
@@ -56,11 +56,11 @@ module Puma
56
56
  end
57
57
 
58
58
  ALLOWED_FIELDS.each do |f|
59
- define_method f.to_sym do
59
+ define_method f do
60
60
  @options[f]
61
61
  end
62
62
 
63
- define_method :"#{f}=" do |v|
63
+ define_method "#{f}=" do |v|
64
64
  @options[f] = v
65
65
  end
66
66
  end
data/lib/puma/util.rb CHANGED
@@ -11,7 +11,7 @@ module Puma
11
11
  end
12
12
 
13
13
  # An instance method on Thread has been provided to address https://bugs.ruby-lang.org/issues/13632,
14
- # which currently affects some older versions of Ruby: 2.2.7 2.2.8 2.2.9 2.2.10 2.3.4 2.4.1
14
+ # 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
15
15
  # Additional context: https://github.com/puma/puma/pull/1345
16
16
  def purge_interrupt_queue
17
17
  Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue
@@ -1,10 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # This module is used as an 'include' file in code at bottom of file
3
4
  module Puma
4
-
5
- # This module is used as an 'include' file in code at bottom of file. It loads
6
- # into either `Rackup::Handler::Puma` or `Rack::Handler::Puma`.
7
-
8
5
  module RackHandler
9
6
  DEFAULT_OPTIONS = {
10
7
  :Verbose => false,
@@ -96,9 +93,9 @@ module Puma
96
93
  def set_host_port_to_config(host, port, config)
97
94
  config.clear_binds! if host || port
98
95
 
99
- if host&.start_with? '.', '/', '@'
96
+ if host && (host[0,1] == '.' || host[0,1] == '/')
100
97
  config.bind "unix://#{host}"
101
- elsif host&.start_with? 'ssl://'
98
+ elsif host && host =~ /^ssl:\/\//
102
99
  uri = URI.parse(host)
103
100
  uri.port ||= port || ::Puma::Configuration::DEFAULTS[:tcp_port]
104
101
  config.bind uri.to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jun-puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: java
6
6
  authors:
7
7
  - Evan Phoenix
@@ -24,11 +24,10 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
- description: |
28
- Puma is a simple, fast, multi-threaded, and highly parallel HTTP 1.1 server
29
- for Ruby/Rack applications. Puma is intended for use in both development and
30
- production environments. It's great for highly parallel Ruby implementations such as
31
- JRuby and TruffleRuby as well as as providing process worker support to support CRuby well.
27
+ description: Puma is a simple, fast, threaded, and highly parallel HTTP 1.1 server
28
+ for Ruby/Rack applications. Puma is intended for use in both development and production
29
+ environments. It's great for highly parallel Ruby implementations such as Rubinius
30
+ and JRuby as well as as providing process worker support to support CRuby well.
32
31
  email:
33
32
  - evan@phx.io
34
33
  executables:
@@ -146,8 +145,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
145
  - !ruby/object:Gem::Version
147
146
  version: '0'
148
147
  requirements: []
149
- rubygems_version: 3.3.26
148
+ rubygems_version: 3.2.33
150
149
  signing_key:
151
150
  specification_version: 4
152
- summary: A Ruby/Rack web server built for parallelism.
151
+ summary: Puma is a simple, fast, threaded, and highly parallel HTTP 1.1 server for
152
+ Ruby/Rack applications
153
153
  test_files: []