summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2016-11-29 20:42:05 +0000
committerThe Bundler Bot <bot@bundler.io>2016-11-29 20:42:05 +0000
commitae4f036d9536ae926421a24667ba68149eb13399 (patch)
treed07fad86343af23ffbfe040f33186ce3cad3837a
parent73f2b99bd391a9e355b6f1d1fd8ca9dcf1372fd1 (diff)
parentcdc772c374aa8b8cc4daadaf59c09e2055d7c705 (diff)
downloadbundler-ae4f036d9536ae926421a24667ba68149eb13399.tar.gz
Auto merge of #5213 - bundler:seg-compact-index-client-threadsafe, r=indirect
[CompactIndexClient] Synchronize access to the list of fetched endpoints Should fix #5142.
-rw-r--r--lib/bundler/compact_index_client.rb7
-rw-r--r--lib/bundler/fetcher/compact_index.rb2
-rw-r--r--spec/bundler/bundler_spec.rb2
3 files changed, 8 insertions, 3 deletions
diff --git a/lib/bundler/compact_index_client.rb b/lib/bundler/compact_index_client.rb
index c3a1b69c6f..3ed05ca484 100644
--- a/lib/bundler/compact_index_client.rb
+++ b/lib/bundler/compact_index_client.rb
@@ -29,6 +29,7 @@ module Bundler
@endpoints = Set.new
@info_checksums_by_name = {}
@parsed_checksums = false
+ @mutex = Mutex.new
@in_parallel = lambda do |inputs, &blk|
inputs.map(&blk)
end
@@ -73,7 +74,7 @@ module Bundler
def update(local_path, remote_path)
Bundler::CompactIndexClient.debug { "update(#{local_path}, #{remote_path})" }
- unless @endpoints.add?(remote_path)
+ unless synchronize { @endpoints.add?(remote_path) }
Bundler::CompactIndexClient.debug { "already fetched #{remote_path}" }
return
end
@@ -99,5 +100,9 @@ module Bundler
def url(path)
path
end
+
+ def synchronize
+ @mutex.synchronize { yield }
+ end
end
end
diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb
index 38105a3f8f..5d703a3a78 100644
--- a/lib/bundler/fetcher/compact_index.rb
+++ b/lib/bundler/fetcher/compact_index.rb
@@ -95,7 +95,7 @@ module Bundler
def bundle_worker(func = nil)
@bundle_worker ||= begin
worker_name = "Compact Index (#{display_uri.host})"
- Bundler::Worker.new(25, worker_name, func)
+ Bundler::Worker.new(Bundler.current_ruby.rbx? ? 1 : 25, worker_name, func)
end
@bundle_worker.tap do |worker|
worker.instance_variable_set(:@func, func) if func
diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb
index cf6de26ac3..1b72f7fd42 100644
--- a/spec/bundler/bundler_spec.rb
+++ b/spec/bundler/bundler_spec.rb
@@ -156,7 +156,7 @@ describe Bundler do
describe "#rm_rf" do
context "the directory is world writable" do
let(:bundler_ui) { Bundler.ui }
- it "should show a fridenly error" do
+ it "should raise a friendly error" do
allow(File).to receive(:exist?).and_return(true)
allow(FileUtils).to receive(:remove_entry_secure).and_raise(ArgumentError)
allow(File).to receive(:world_writable?).and_return(true)