connection_pool 3.0.0 → 3.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60f53f4a83f6a13be41059753aeff5fad1518a45946aa13ab29111f1612c5119
4
- data.tar.gz: 7edefa375ea7f3852eee9d7644f2aae955119e0cd96049697b7f38bfc54e5c87
3
+ metadata.gz: df5a1a8f1b7d70d93a4403456967159204d6fa5e1c963be3c9fb0eb4363dd2f5
4
+ data.tar.gz: 92788a9007f9bad4187a3d48060cd277c24b6f1e572ca43e84b2d83ae2574806
5
5
  SHA512:
6
- metadata.gz: 3007eb8a2cf804da6b3850162098b221a5a613244ba20506fed109e3a47e0046099ba56c48ccd8a260a3afc13362552ddd9040a512ca1b512cfae1f18937c32b
7
- data.tar.gz: 4cdb681918cefe624b3c00e6d7580330f120c6c53cc414e694d6568eee7f24ed109d69ec150c7a7ccbf5dec17ffb1cfdc8422e78bcb9d1b436240bb81c5464a6
6
+ metadata.gz: 731dc286738cf2b2da51801b194ff169cf2124c9941b6867310accd77924a27ab0f7288ed5e9b1984e1fff9d8e112db5aae31beed2afafd1074d85c992c33dd1
7
+ data.tar.gz: 524a89e82d009395952aae23bc35724629e8d092679780394508821ab7073c9e43c9109229bce8cd8bd8b64a4538fcf235c0890cdf0494f9b673dc8b8d9b6a5e
data/Changes.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # connection_pool Changelog
2
2
 
3
+ 3.0.1
4
+ ------
5
+
6
+ - Add missing `fork.rb` to gemspec.
7
+
3
8
  3.0.0
4
9
  ------
5
10
 
@@ -10,8 +10,11 @@ Gem::Specification.new do |s|
10
10
  s.description = s.summary = "Generic connection pool for Ruby"
11
11
 
12
12
  s.files = ["Changes.md", "LICENSE", "README.md", "connection_pool.gemspec",
13
- "lib/connection_pool.rb", "lib/connection_pool/timed_stack.rb",
14
- "lib/connection_pool/version.rb", "lib/connection_pool/wrapper.rb"]
13
+ "lib/connection_pool.rb",
14
+ "lib/connection_pool/timed_stack.rb",
15
+ "lib/connection_pool/version.rb",
16
+ "lib/connection_pool/fork.rb",
17
+ "lib/connection_pool/wrapper.rb"]
15
18
  s.executables = []
16
19
  s.require_paths = ["lib"]
17
20
  s.license = "MIT"
@@ -0,0 +1,40 @@
1
+ class ConnectionPool
2
+ if Process.respond_to?(:fork)
3
+ INSTANCES = ObjectSpace::WeakMap.new
4
+ private_constant :INSTANCES
5
+
6
+ def self.after_fork
7
+ INSTANCES.each_value do |pool|
8
+ # We're in after_fork, so we know all other threads are dead.
9
+ # All we need to do is ensure the main thread doesn't have a
10
+ # checked out connection
11
+ pool.checkin(force: true)
12
+ pool.reload do |connection|
13
+ # Unfortunately we don't know what method to call to close the connection,
14
+ # so we try the most common one.
15
+ connection.close if connection.respond_to?(:close)
16
+ end
17
+ end
18
+ nil
19
+ end
20
+
21
+ module ForkTracker
22
+ def _fork
23
+ pid = super
24
+ if pid == 0
25
+ ConnectionPool.after_fork
26
+ end
27
+ pid
28
+ end
29
+ end
30
+ Process.singleton_class.prepend(ForkTracker)
31
+ else
32
+ # JRuby, et al
33
+ INSTANCES = nil
34
+ private_constant :INSTANCES
35
+
36
+ def self.after_fork
37
+ # noop
38
+ end
39
+ end
40
+ end
@@ -1,3 +1,3 @@
1
1
  class ConnectionPool
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: connection_pool
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
@@ -65,6 +65,7 @@ files:
65
65
  - README.md
66
66
  - connection_pool.gemspec
67
67
  - lib/connection_pool.rb
68
+ - lib/connection_pool/fork.rb
68
69
  - lib/connection_pool/timed_stack.rb
69
70
  - lib/connection_pool/version.rb
70
71
  - lib/connection_pool/wrapper.rb