Skip to content

Commit

Permalink
[rubygems/rubygems] Bump vendored net-http-persistent to 4.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and matzbot committed Jun 30, 2023
1 parent d49a92d commit 41779fe
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
##
# The version of Bundler::Persistent::Net::HTTP::Persistent you are using

VERSION = '4.0.1'
VERSION = '4.0.2'

##
# Error class for errors raised by Bundler::Persistent::Net::HTTP::Persistent. Various
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def finish
ensure
reset
end
alias_method :close, :finish

def reset
@last_use = Bundler::Persistent::Net::HTTP::Persistent::EPOCH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,32 @@ def initialize(options = {}, &block)
end

def checkin net_http_args
stack = Thread.current[@key][net_http_args] ||= []
if net_http_args.is_a?(Hash) && net_http_args.size == 1 && net_http_args[:force]
# Bundler::ConnectionPool 2.4+ calls `checkin(force: true)` after fork.
# When this happens, we should remove all connections from Thread.current
if stacks = Thread.current[@key]
stacks.each do |http_args, connections|
connections.each do |conn|
@available.push conn, connection_args: http_args
end
connections.clear
end
end
else
stack = Thread.current[@key][net_http_args] ||= []

raise Bundler::ConnectionPool::Error, 'no connections are checked out' if
stack.empty?
raise Bundler::ConnectionPool::Error, 'no connections are checked out' if
stack.empty?

conn = stack.pop
conn = stack.pop

if stack.empty?
@available.push conn, connection_args: net_http_args
if stack.empty?
@available.push conn, connection_args: net_http_args

Thread.current[@key].delete(net_http_args)
Thread.current[@key] = nil if Thread.current[@key].empty?
Thread.current[@key].delete(net_http_args)
Thread.current[@key] = nil if Thread.current[@key].empty?
end
end

nil
end

Expand Down

0 comments on commit 41779fe

Please sign in to comment.