Skip to content

Commit d91f1e8

Browse files
Merge pull request #7275 from rubygems/upgrade-all-vendored-libraries
Upgrade vendored libraries
2 parents 38e6d49 + 8439491 commit d91f1e8

File tree

13 files changed

+960
-231
lines changed

13 files changed

+960
-231
lines changed

.codespellrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
check-filenames=
33
check-hidden=
44
ignore-words=.codespellignore
5-
skip=*.pem,.git,man,vcr_cassettes,vendor,net-http
5+
skip=*.pem,.git,man,vcr_cassettes,vendor,./lib/rubygems/net*,./lib/rubygems/resolv,./lib/rubygems/tsort,./lib/rubygems/timeout,./lib/rubygems/optparse

Rakefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ if File.exist?("tool/automatiek.rake")
122122
lib.license_path = "LICENSE"
123123

124124
lib.dependency("tsort") do |sublib|
125-
sublib.version = "v0.1.1"
125+
sublib.version = "v0.2.0"
126126
sublib.download = { github: "https://github.com/ruby/tsort" }
127127
sublib.namespace = "TSort"
128128
sublib.prefix = "Gem"
@@ -139,7 +139,7 @@ if File.exist?("tool/automatiek.rake")
139139
# this library should not be documented.
140140
desc "Vendor a specific version of optparse to rubygems"
141141
Automatiek::RakeTask.new("optparse") do |lib|
142-
lib.version = "v0.3.0"
142+
lib.version = "v0.4.0"
143143
lib.download = { github: "https://github.com/ruby/optparse" }
144144
lib.namespace = "OptionParser"
145145
lib.prefix = "Gem"
@@ -159,7 +159,7 @@ if File.exist?("tool/automatiek.rake")
159159

160160
desc "Vendor a specific version of tsort to bundler"
161161
Automatiek::RakeTask.new("tsort") do |lib|
162-
lib.version = "v0.1.1"
162+
lib.version = "v0.2.0"
163163
lib.download = { github: "https://github.com/ruby/tsort" }
164164
lib.namespace = "TSort"
165165
lib.prefix = "Bundler"
@@ -179,7 +179,7 @@ if File.exist?("tool/automatiek.rake")
179179

180180
desc "Vendor a specific version of fileutils to bundler"
181181
Automatiek::RakeTask.new("fileutils") do |lib|
182-
lib.version = "v1.7.0"
182+
lib.version = "v1.7.2"
183183
lib.download = { github: "https://github.com/ruby/fileutils" }
184184
lib.namespace = "FileUtils"
185185
lib.prefix = "Bundler"
@@ -200,7 +200,7 @@ if File.exist?("tool/automatiek.rake")
200200
lib.license_path = "README.rdoc"
201201

202202
lib.dependency("connection_pool") do |sublib|
203-
sublib.version = "v2.3.0"
203+
sublib.version = "v2.4.1"
204204
sublib.download = { github: "https://github.com/mperham/connection_pool" }
205205
sublib.namespace = "ConnectionPool"
206206
sublib.prefix = "Bundler"
@@ -218,7 +218,7 @@ if File.exist?("tool/automatiek.rake")
218218
end
219219

220220
lib.dependency("uri") do |sublib|
221-
sublib.version = "v0.12.2"
221+
sublib.version = "v0.13.0"
222222
sublib.download = { github: "https://github.com/ruby/uri" }
223223
sublib.namespace = "URI"
224224
sublib.prefix = "Bundler"
@@ -262,7 +262,7 @@ if File.exist?("tool/automatiek.rake")
262262
end
263263

264264
sublib.dependency("resolv") do |subsublib|
265-
subsublib.version = "v0.2.2"
265+
subsublib.version = "v0.3.0"
266266
subsublib.download = { github: "https://github.com/ruby/resolv" }
267267
subsublib.namespace = "Resolv"
268268
subsublib.prefix = "Gem"

bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,70 @@ class TimeoutError < ::Gem::Timeout::Error; end
3636
# Accepts the following options:
3737
# - :size - number of connections to pool, defaults to 5
3838
# - :timeout - amount of time to wait for a connection if none currently available, defaults to 5 seconds
39+
# - :auto_reload_after_fork - automatically drop all connections after fork, defaults to true
3940
#
4041
class Bundler::ConnectionPool
41-
DEFAULTS = {size: 5, timeout: 5}
42+
DEFAULTS = {size: 5, timeout: 5, auto_reload_after_fork: true}
4243

4344
def self.wrap(options, &block)
4445
Wrapper.new(options, &block)
4546
end
4647

48+
if Process.respond_to?(:fork)
49+
INSTANCES = ObjectSpace::WeakMap.new
50+
private_constant :INSTANCES
51+
52+
def self.after_fork
53+
INSTANCES.values.each do |pool|
54+
next unless pool.auto_reload_after_fork
55+
56+
# We're on after fork, so we know all other threads are dead.
57+
# All we need to do is to ensure the main thread doesn't have a
58+
# checked out connection
59+
pool.checkin(force: true)
60+
pool.reload do |connection|
61+
# Unfortunately we don't know what method to call to close the connection,
62+
# so we try the most common one.
63+
connection.close if connection.respond_to?(:close)
64+
end
65+
end
66+
nil
67+
end
68+
69+
if ::Process.respond_to?(:_fork) # MRI 3.1+
70+
module ForkTracker
71+
def _fork
72+
pid = super
73+
if pid == 0
74+
Bundler::ConnectionPool.after_fork
75+
end
76+
pid
77+
end
78+
end
79+
Process.singleton_class.prepend(ForkTracker)
80+
end
81+
else
82+
INSTANCES = nil
83+
private_constant :INSTANCES
84+
85+
def self.after_fork
86+
# noop
87+
end
88+
end
89+
4790
def initialize(options = {}, &block)
4891
raise ArgumentError, "Connection pool requires a block" unless block
4992

5093
options = DEFAULTS.merge(options)
5194

5295
@size = Integer(options.fetch(:size))
5396
@timeout = options.fetch(:timeout)
97+
@auto_reload_after_fork = options.fetch(:auto_reload_after_fork)
5498

5599
@available = TimedStack.new(@size, &block)
56100
@key = :"pool-#{@available.object_id}"
57101
@key_count = :"pool-#{@available.object_id}-count"
102+
INSTANCES[self] = self if INSTANCES
58103
end
59104

60105
def with(options = {})
@@ -81,16 +126,16 @@ def checkout(options = {})
81126
end
82127
end
83128

84-
def checkin
129+
def checkin(force: false)
85130
if ::Thread.current[@key]
86-
if ::Thread.current[@key_count] == 1
131+
if ::Thread.current[@key_count] == 1 || force
87132
@available.push(::Thread.current[@key])
88133
::Thread.current[@key] = nil
89134
::Thread.current[@key_count] = nil
90135
else
91136
::Thread.current[@key_count] -= 1
92137
end
93-
else
138+
elsif !force
94139
raise Bundler::ConnectionPool::Error, "no connections are checked out"
95140
end
96141

@@ -117,6 +162,8 @@ def reload(&block)
117162

118163
# Size of this connection pool
119164
attr_reader :size
165+
# Automatically drop all connections after fork
166+
attr_reader :auto_reload_after_fork
120167

121168
# Number of pool entries available for checkout at this instant.
122169
def available
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class Bundler::ConnectionPool
2-
VERSION = "2.3.0"
2+
VERSION = "2.4.1"
33
end

bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
# - {CVE-2004-0452}[https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452].
181181
#
182182
module Bundler::FileUtils
183-
VERSION = "1.7.0"
183+
VERSION = "1.7.2"
184184

185185
def self.private_module_function(name) #:nodoc:
186186
module_function name
@@ -192,8 +192,6 @@ def self.private_module_function(name) #:nodoc:
192192
#
193193
# Bundler::FileUtils.pwd # => "/rdoc/fileutils"
194194
#
195-
# Bundler::FileUtils.getwd is an alias for Bundler::FileUtils.pwd.
196-
#
197195
# Related: Bundler::FileUtils.cd.
198196
#
199197
def pwd
@@ -235,8 +233,6 @@ def pwd
235233
# cd ..
236234
# cd fileutils
237235
#
238-
# Bundler::FileUtils.chdir is an alias for Bundler::FileUtils.cd.
239-
#
240236
# Related: Bundler::FileUtils.pwd.
241237
#
242238
def cd(dir, verbose: nil, &block) # :yield: dir
@@ -515,8 +511,6 @@ def rmdir(list, parents: nil, noop: nil, verbose: nil)
515511
# Raises an exception if +dest+ is the path to an existing file
516512
# and keyword argument +force+ is not +true+.
517513
#
518-
# Bundler::FileUtils#link is an alias for Bundler::FileUtils#ln.
519-
#
520514
# Related: Bundler::FileUtils.link_entry (has different options).
521515
#
522516
def ln(src, dest, force: nil, noop: nil, verbose: nil)
@@ -707,8 +701,6 @@ def cp_lr(src, dest, noop: nil, verbose: nil,
707701
# ln -sf src2.txt dest2.txt
708702
# ln -s srcdir3/src0.txt srcdir3/src1.txt destdir3
709703
#
710-
# Bundler::FileUtils.symlink is an alias for Bundler::FileUtils.ln_s.
711-
#
712704
# Related: Bundler::FileUtils.ln_sf.
713705
#
714706
def ln_s(src, dest, force: nil, relative: false, target_directory: true, noop: nil, verbose: nil)
@@ -876,8 +868,6 @@ def link_entry(src, dest, dereference_root = false, remove_destination = false)
876868
#
877869
# Raises an exception if +src+ is a directory.
878870
#
879-
# Bundler::FileUtils.copy is an alias for Bundler::FileUtils.cp.
880-
#
881871
# Related: {methods for copying}[rdoc-ref:FileUtils@Copying].
882872
#
883873
def cp(src, dest, preserve: nil, noop: nil, verbose: nil)
@@ -1164,8 +1154,6 @@ def copy_stream(src, dest)
11641154
# mv src0 dest0
11651155
# mv src1.txt src1 dest1
11661156
#
1167-
# Bundler::FileUtils.move is an alias for Bundler::FileUtils.mv.
1168-
#
11691157
def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
11701158
fu_output_message "mv#{force ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if verbose
11711159
return if noop
@@ -1223,8 +1211,6 @@ def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
12231211
#
12241212
# rm src0.dat src0.txt
12251213
#
1226-
# Bundler::FileUtils.remove is an alias for Bundler::FileUtils.rm.
1227-
#
12281214
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
12291215
#
12301216
def rm(list, force: nil, noop: nil, verbose: nil)
@@ -1250,8 +1236,6 @@ def rm(list, force: nil, noop: nil, verbose: nil)
12501236
#
12511237
# See Bundler::FileUtils.rm for keyword arguments.
12521238
#
1253-
# Bundler::FileUtils.safe_unlink is an alias for Bundler::FileUtils.rm_f.
1254-
#
12551239
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
12561240
#
12571241
def rm_f(list, noop: nil, verbose: nil)
@@ -1339,8 +1323,6 @@ def rm_r(list, force: nil, noop: nil, verbose: nil, secure: nil)
13391323
#
13401324
# See Bundler::FileUtils.rm_r for keyword arguments.
13411325
#
1342-
# Bundler::FileUtils.rmtree is an alias for Bundler::FileUtils.rm_rf.
1343-
#
13441326
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
13451327
#
13461328
def rm_rf(list, noop: nil, verbose: nil, secure: nil)
@@ -1642,7 +1624,13 @@ def install(src, dest, mode: nil, owner: nil, group: nil, preserve: nil,
16421624
st = File.stat(s)
16431625
unless File.exist?(d) and compare_file(s, d)
16441626
remove_file d, true
1645-
copy_file s, d
1627+
if d.end_with?('/')
1628+
mkdir_p d
1629+
copy_file s, d + File.basename(s)
1630+
else
1631+
mkdir_p File.expand_path('..', d)
1632+
copy_file s, d
1633+
end
16461634
File.utime st.atime, st.mtime, d if preserve
16471635
File.chmod fu_mode(mode, st), d if mode
16481636
File.chown uid, gid, d if uid or gid

bundler/lib/bundler/vendor/tsort/lib/tsort.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@
122122
#
123123

124124
module Bundler::TSort
125+
126+
VERSION = "0.2.0"
127+
125128
class Cyclic < StandardError
126129
end
127130

0 commit comments

Comments
 (0)