[rubygems] Backport from 2.1.x branch to fix concurrent requires issue

Mamoru Tasaka mtasaka at fedoraproject.org
Wed Oct 16 02:13:20 UTC 2013


commit fb6646ac150dee728caccfe215d469134535f7d1
Author: Mamoru TASAKA <mtasaka at fedoraproject.org>
Date:   Wed Oct 16 11:13:14 2013 +0900

    Backport from 2.1.x branch to fix concurrent requires issue
    
      (ref:bug 989574)

 rubygem-2.0.12-concurrent-requires.patch |   83 ++++++++++++++++++++++++++++++
 rubygems.spec                            |   13 ++++-
 2 files changed, 95 insertions(+), 1 deletions(-)
---
diff --git a/rubygem-2.0.12-concurrent-requires.patch b/rubygem-2.0.12-concurrent-requires.patch
new file mode 100644
index 0000000..f929cec
--- /dev/null
+++ b/rubygem-2.0.12-concurrent-requires.patch
@@ -0,0 +1,83 @@
+From 16fc8e8b90830644cf5eed6b71c7ec2dac4ec5fc Mon Sep 17 00:00:00 2001
+From: Eric Hodel <drbrain at segment7.net>
+Date: Tue, 10 Sep 2013 16:15:34 -0700
+Subject: [PATCH] Restore concurrent requires
+
+When #8374 was fixed all requires were serialized, so one thread would
+be blocked waiting for gem resolution (if any) and require in another
+thread.  This is undesirable for JRuby, in particular.
+
+The monitor protecting the RubyGems internals only needs to cover gem
+activation and modifying $LOAD_PATH, not requiring files.
+
+Now the monitor is released before calling the original Kernel#require
+which allows other threads to require files without waiting for
+RubyGems.
+
+Fixes #640
+
+See also #637
+---
+ History.txt                             |  7 +++++++
+ lib/rubygems/core_ext/kernel_require.rb | 28 ++++++++++++++++++++++++----
+ 2 files changed, 31 insertions(+), 4 deletions(-)
+
+diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
+index 3619f3f..0416644 100755
+--- a/lib/rubygems/core_ext/kernel_require.rb
++++ b/lib/rubygems/core_ext/kernel_require.rb
+@@ -48,7 +48,12 @@ def require path
+     # normal require handle loading a gem from the rescue below.
+ 
+     if Gem::Specification.unresolved_deps.empty? then
+-      return gem_original_require(path)
++      begin
++        RUBYGEMS_ACTIVATION_MONITOR.exit
++        return gem_original_require(path)
++      ensure
++        RUBYGEMS_ACTIVATION_MONITOR.enter
++      end
+     end
+ 
+     # If +path+ is for a gem that has already been loaded, don't
+@@ -61,7 +66,12 @@ def require path
+       s.activated? and s.contains_requirable_file? path
+     }
+ 
+-    return gem_original_require(path) if spec
++    begin
++      RUBYGEMS_ACTIVATION_MONITOR.exit
++      return gem_original_require(path)
++    ensure
++      RUBYGEMS_ACTIVATION_MONITOR.enter
++    end if spec
+ 
+     # Attempt to find +path+ in any unresolved gems...
+ 
+@@ -109,11 +119,21 @@ def require path
+       valid.activate
+     end
+ 
+-    gem_original_require path
++    begin
++      RUBYGEMS_ACTIVATION_MONITOR.exit
++      return gem_original_require(path)
++    ensure
++      RUBYGEMS_ACTIVATION_MONITOR.enter
++    end
+   rescue LoadError => load_error
+     if load_error.message.start_with?("Could not find") or
+         (load_error.message.end_with?(path) and Gem.try_activate(path)) then
+-      return gem_original_require(path)
++      begin
++        RUBYGEMS_ACTIVATION_MONITOR.exit
++        return gem_original_require(path)
++      ensure
++        RUBYGEMS_ACTIVATION_MONITOR.enter
++      end
+     end
+ 
+     raise load_error
+-- 
+1.8.4
+
diff --git a/rubygems.spec b/rubygems.spec
index e47e85a..2a07ebe 100644
--- a/rubygems.spec
+++ b/rubygems.spec
@@ -25,7 +25,7 @@
 Summary:	The Ruby standard for packaging ruby libraries
 Name:		rubygems
 Version:	2.0.12
-Release:	109%{?dist}
+Release:	110%{?dist}
 Group:		Development/Libraries
 License:	Ruby or MIT
 
@@ -55,6 +55,12 @@ Source100:	operating_system.rb
 # Fix Gem.all_load_paths (although it is deprecated and will be removed
 # on 2011-10-01)
 
+# https://github.com/rubygems/rubygems/issues/640
+# From https://github.com/rubygems/rubygems/commit/16fc8e8b90830644cf5eed6b71c7ec2dac4ec5fc.patch
+# https://github.com/geemus/shindo/issues/12
+# ref:bug 989574
+Patch4:   rubygem-2.0.12-concurrent-requires.patch
+
 # Add support for installing binary extensions according to FHS.
 # https://github.com/rubygems/rubygems/issues/210
 # Note that 8th patch might be resolved by
@@ -126,6 +132,7 @@ Documentation for %{name}
 #%%patch3 -p1 -b .rdoc_v
 #%%patch6 -p1 -b .load_path
 %endif
+%patch4 -p1 -b .concurrent
 %patch109 -p1 -b .109
 %patch113 -p1 -b .113
 %patch114 -p1 -b .114
@@ -283,6 +290,10 @@ ruby -Ilib %{SOURCE11}
 
 
 %changelog
+* Tue Oct 15 2013 Mamoru TASAKA <mtasaka at fedoraproject.org> - 2.0.12-110
+- Backport from 2.1.x branch to fix concurrent requires issue
+  (ref:bug 989574)
+
 * Tue Oct 15 2013 Mamoru TASAKA <mtasaka at fedoraproject.org> - 2.0.12-109
 - Update to 2.0.12
 - Un-unlink %%{_sysconfdir}/pki/tls/cert.pem with discussion with


More information about the scm-commits mailing list