puma 5.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puma might be problematic. Click here for more details.

@@ -13,6 +13,7 @@ module Puma
13
13
  # gets created via the `start_server` method from the `Puma::Runner` class
14
14
  # that this inherits from.
15
15
  class Single < Runner
16
+ # @!attribute [r] stats
16
17
  def stats
17
18
  {
18
19
  started_at: @started_at.utc.iso8601
@@ -62,6 +62,8 @@ module Puma
62
62
  end
63
63
 
64
64
  @clean_thread_locals = false
65
+ @force_shutdown = false
66
+ @shutdown_mutex = Mutex.new
65
67
  end
66
68
 
67
69
  attr_reader :spawned, :trim_requested, :waiting
@@ -80,10 +82,12 @@ module Puma
80
82
  with_mutex { @todo.size }
81
83
  end
82
84
 
85
+ # @!attribute [r] pool_capacity
83
86
  def pool_capacity
84
87
  waiting + (@max - spawned)
85
88
  end
86
89
 
90
+ # @!attribute [r] busy_threads
87
91
  # @version 5.0.0
88
92
  def busy_threads
89
93
  with_mutex { @spawned - @waiting + @todo.size }
@@ -322,6 +326,19 @@ module Puma
322
326
  @reaper.start!
323
327
  end
324
328
 
329
+ # Allows ThreadPool::ForceShutdown to be raised within the
330
+ # provided block if the thread is forced to shutdown during execution.
331
+ def with_force_shutdown
332
+ t = Thread.current
333
+ @shutdown_mutex.synchronize do
334
+ raise ForceShutdown if @force_shutdown
335
+ t[:with_force_shutdown] = true
336
+ end
337
+ yield
338
+ ensure
339
+ t[:with_force_shutdown] = false
340
+ end
341
+
325
342
  # Tell all threads in the pool to exit and wait for them to finish.
326
343
  # Wait +timeout+ seconds then raise +ForceShutdown+ in remaining threads.
327
344
  # Next, wait an extra +grace+ seconds then force-kill remaining threads.
@@ -356,8 +373,11 @@ module Puma
356
373
  join.call(timeout)
357
374
 
358
375
  # If threads are still running, raise ForceShutdown and wait to finish.
359
- threads.each do |t|
360
- t.raise ForceShutdown
376
+ @shutdown_mutex.synchronize do
377
+ @force_shutdown = true
378
+ threads.each do |t|
379
+ t.raise ForceShutdown if t[:with_force_shutdown]
380
+ end
361
381
  end
362
382
  join.call(SHUTDOWN_GRACE_TIME)
363
383
 
@@ -72,6 +72,7 @@ module Puma
72
72
  end
73
73
  end
74
74
 
75
+ # @!attribute [r] to_hash
75
76
  def to_hash
76
77
  hash = {}
77
78
  each { |k,v| hash[k] = v }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Phoenix
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-17 00:00:00.000000000 Z
11
+ date: 2020-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nio4r
@@ -119,7 +119,7 @@ metadata:
119
119
  changelog_uri: https://github.com/puma/puma/blob/master/History.md
120
120
  homepage_uri: https://puma.io
121
121
  source_code_uri: https://github.com/puma/puma
122
- post_install_message:
122
+ post_install_message:
123
123
  rdoc_options: []
124
124
  require_paths:
125
125
  - lib
@@ -134,8 +134,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  - !ruby/object:Gem::Version
135
135
  version: '0'
136
136
  requirements: []
137
- rubygems_version: 3.1.2
138
- signing_key:
137
+ rubygems_version: 3.0.3
138
+ signing_key:
139
139
  specification_version: 4
140
140
  summary: Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for
141
141
  Ruby/Rack applications