Skip to content

Commit

Permalink
[rubygems/rubygems] Upgrade vendored libraries
Browse files Browse the repository at this point in the history
To match the versions that will be included in final ruby release.

rubygems/rubygems@84394919fb
  • Loading branch information
deivid-rodriguez authored and matzbot committed Dec 14, 2023
1 parent 912016f commit a79a1d3
Show file tree
Hide file tree
Showing 11 changed files with 952 additions and 223 deletions.
55 changes: 51 additions & 4 deletions lib/bundler/vendor/connection_pool/lib/connection_pool.rb
Expand Up @@ -36,25 +36,70 @@ class TimeoutError < ::Gem::Timeout::Error; end
# Accepts the following options:
# - :size - number of connections to pool, defaults to 5
# - :timeout - amount of time to wait for a connection if none currently available, defaults to 5 seconds
# - :auto_reload_after_fork - automatically drop all connections after fork, defaults to true
#
class Bundler::ConnectionPool
DEFAULTS = {size: 5, timeout: 5}
DEFAULTS = {size: 5, timeout: 5, auto_reload_after_fork: true}

def self.wrap(options, &block)
Wrapper.new(options, &block)
end

if Process.respond_to?(:fork)
INSTANCES = ObjectSpace::WeakMap.new
private_constant :INSTANCES

def self.after_fork
INSTANCES.values.each do |pool|
next unless pool.auto_reload_after_fork

# We're on after fork, so we know all other threads are dead.
# All we need to do is to ensure the main thread doesn't have a
# checked out connection
pool.checkin(force: true)
pool.reload do |connection|
# Unfortunately we don't know what method to call to close the connection,
# so we try the most common one.
connection.close if connection.respond_to?(:close)
end
end
nil
end

if ::Process.respond_to?(:_fork) # MRI 3.1+
module ForkTracker
def _fork
pid = super
if pid == 0
Bundler::ConnectionPool.after_fork
end
pid
end
end
Process.singleton_class.prepend(ForkTracker)
end
else
INSTANCES = nil
private_constant :INSTANCES

def self.after_fork
# noop
end
end

def initialize(options = {}, &block)
raise ArgumentError, "Connection pool requires a block" unless block

options = DEFAULTS.merge(options)

@size = Integer(options.fetch(:size))
@timeout = options.fetch(:timeout)
@auto_reload_after_fork = options.fetch(:auto_reload_after_fork)

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

def with(options = {})
Expand All @@ -81,16 +126,16 @@ def checkout(options = {})
end
end

def checkin
def checkin(force: false)
if ::Thread.current[@key]
if ::Thread.current[@key_count] == 1
if ::Thread.current[@key_count] == 1 || force
@available.push(::Thread.current[@key])
::Thread.current[@key] = nil
::Thread.current[@key_count] = nil
else
::Thread.current[@key_count] -= 1
end
else
elsif !force
raise Bundler::ConnectionPool::Error, "no connections are checked out"
end

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

# Size of this connection pool
attr_reader :size
# Automatically drop all connections after fork
attr_reader :auto_reload_after_fork

# Number of pool entries available for checkout at this instant.
def available
Expand Down
@@ -1,3 +1,3 @@
class Bundler::ConnectionPool
VERSION = "2.3.0"
VERSION = "2.4.1"
end
28 changes: 8 additions & 20 deletions lib/bundler/vendor/fileutils/lib/fileutils.rb
Expand Up @@ -180,7 +180,7 @@
# - {CVE-2004-0452}[https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452].
#
module Bundler::FileUtils
VERSION = "1.7.0"
VERSION = "1.7.2"

def self.private_module_function(name) #:nodoc:
module_function name
Expand All @@ -192,8 +192,6 @@ def self.private_module_function(name) #:nodoc:
#
# Bundler::FileUtils.pwd # => "/rdoc/fileutils"
#
# Bundler::FileUtils.getwd is an alias for Bundler::FileUtils.pwd.
#
# Related: Bundler::FileUtils.cd.
#
def pwd
Expand Down Expand Up @@ -235,8 +233,6 @@ def pwd
# cd ..
# cd fileutils
#
# Bundler::FileUtils.chdir is an alias for Bundler::FileUtils.cd.
#
# Related: Bundler::FileUtils.pwd.
#
def cd(dir, verbose: nil, &block) # :yield: dir
Expand Down Expand Up @@ -515,8 +511,6 @@ def rmdir(list, parents: nil, noop: nil, verbose: nil)
# Raises an exception if +dest+ is the path to an existing file
# and keyword argument +force+ is not +true+.
#
# Bundler::FileUtils#link is an alias for Bundler::FileUtils#ln.
#
# Related: Bundler::FileUtils.link_entry (has different options).
#
def ln(src, dest, force: nil, noop: nil, verbose: nil)
Expand Down Expand Up @@ -707,8 +701,6 @@ def cp_lr(src, dest, noop: nil, verbose: nil,
# ln -sf src2.txt dest2.txt
# ln -s srcdir3/src0.txt srcdir3/src1.txt destdir3
#
# Bundler::FileUtils.symlink is an alias for Bundler::FileUtils.ln_s.
#
# Related: Bundler::FileUtils.ln_sf.
#
def ln_s(src, dest, force: nil, relative: false, target_directory: true, noop: nil, verbose: nil)
Expand Down Expand Up @@ -876,8 +868,6 @@ def link_entry(src, dest, dereference_root = false, remove_destination = false)
#
# Raises an exception if +src+ is a directory.
#
# Bundler::FileUtils.copy is an alias for Bundler::FileUtils.cp.
#
# Related: {methods for copying}[rdoc-ref:FileUtils@Copying].
#
def cp(src, dest, preserve: nil, noop: nil, verbose: nil)
Expand Down Expand Up @@ -1164,8 +1154,6 @@ def copy_stream(src, dest)
# mv src0 dest0
# mv src1.txt src1 dest1
#
# Bundler::FileUtils.move is an alias for Bundler::FileUtils.mv.
#
def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
fu_output_message "mv#{force ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if verbose
return if noop
Expand Down Expand Up @@ -1223,8 +1211,6 @@ def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
#
# rm src0.dat src0.txt
#
# Bundler::FileUtils.remove is an alias for Bundler::FileUtils.rm.
#
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
#
def rm(list, force: nil, noop: nil, verbose: nil)
Expand All @@ -1250,8 +1236,6 @@ def rm(list, force: nil, noop: nil, verbose: nil)
#
# See Bundler::FileUtils.rm for keyword arguments.
#
# Bundler::FileUtils.safe_unlink is an alias for Bundler::FileUtils.rm_f.
#
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
#
def rm_f(list, noop: nil, verbose: nil)
Expand Down Expand Up @@ -1339,8 +1323,6 @@ def rm_r(list, force: nil, noop: nil, verbose: nil, secure: nil)
#
# See Bundler::FileUtils.rm_r for keyword arguments.
#
# Bundler::FileUtils.rmtree is an alias for Bundler::FileUtils.rm_rf.
#
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
#
def rm_rf(list, noop: nil, verbose: nil, secure: nil)
Expand Down Expand Up @@ -1642,7 +1624,13 @@ def install(src, dest, mode: nil, owner: nil, group: nil, preserve: nil,
st = File.stat(s)
unless File.exist?(d) and compare_file(s, d)
remove_file d, true
copy_file s, d
if d.end_with?('/')
mkdir_p d
copy_file s, d + File.basename(s)
else
mkdir_p File.expand_path('..', d)
copy_file s, d
end
File.utime st.atime, st.mtime, d if preserve
File.chmod fu_mode(mode, st), d if mode
File.chown uid, gid, d if uid or gid
Expand Down
3 changes: 3 additions & 0 deletions lib/bundler/vendor/tsort/lib/tsort.rb
Expand Up @@ -122,6 +122,9 @@
#

module Bundler::TSort

VERSION = "0.2.0"

class Cyclic < StandardError
end

Expand Down

0 comments on commit a79a1d3

Please sign in to comment.