aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-01-20 18:17:36 +0000
committerJon Leighton <j@jonathanleighton.com>2012-01-20 18:32:27 +0000
commit30b0e5848c5a91c0bfd1ef33ec4b9bc36bcead0b (patch)
tree2e8b9f966ce39701ee3b2d1905209acec1f0cc85 /activerecord/lib/active_record
parentde41f5a9799cbce276ca9c439c99f4377191b36d (diff)
downloadrails-30b0e5848c5a91c0bfd1ef33ec4b9bc36bcead0b.tar.gz
rails-30b0e5848c5a91c0bfd1ef33ec4b9bc36bcead0b.tar.bz2
rails-30b0e5848c5a91c0bfd1ef33ec4b9bc36bcead0b.zip
Fix another race condition.
From 2c667f69aa2daac5ee6c29ca9679616e2a71532a. Thanks @pwnall for the heads-up.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/attribute_methods.rb3
-rw-r--r--activerecord/lib/active_record/core.rb3
2 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb
index f8815fefc9..a1e34a3aa1 100644
--- a/activerecord/lib/active_record/attribute_methods.rb
+++ b/activerecord/lib/active_record/attribute_methods.rb
@@ -1,6 +1,5 @@
require 'active_support/core_ext/enumerable'
require 'active_support/deprecation'
-require 'thread'
module ActiveRecord
# = Active Record Attribute Methods
@@ -38,8 +37,6 @@ module ActiveRecord
def define_attribute_methods
# Use a mutex; we don't want two thread simaltaneously trying to define
# attribute methods.
- @attribute_methods_mutex ||= Mutex.new
-
@attribute_methods_mutex.synchronize do
return if attribute_methods_generated?
superclass.define_attribute_methods unless self == base_class
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index c0722e5eeb..e90503d173 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -1,4 +1,5 @@
require 'active_support/concern'
+require 'thread'
module ActiveRecord
module Core
@@ -80,6 +81,8 @@ module ActiveRecord
end
def initialize_generated_modules
+ @attribute_methods_mutex = Mutex.new
+
# force attribute methods to be higher in inheritance hierarchy than other generated methods
generated_attribute_methods
generated_feature_methods