diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-03-17 17:13:00 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-03-17 17:13:00 -0700 |
commit | 8f218266bb4fa4ef2a07904b106c72fda9e182a6 (patch) | |
tree | 3065ab1e65e9577c11e04d51f12c56e4da4dba69 /activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | |
parent | 4a69c933cf07ee296a4ae1e2612c31922019eeab (diff) | |
parent | 9e457a8654fa89fe329719f88ae3679aefb21e56 (diff) | |
download | rails-8f218266bb4fa4ef2a07904b106c72fda9e182a6.tar.gz rails-8f218266bb4fa4ef2a07904b106c72fda9e182a6.tar.bz2 rails-8f218266bb4fa4ef2a07904b106c72fda9e182a6.zip |
Merge pull request #14360 from matthewd/thread_aware_reaper
Track owning thread for connection pool
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 496153af83..c7e5a18f02 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -71,8 +71,8 @@ module ActiveRecord define_callbacks :checkout, :checkin attr_accessor :visitor, :pool - attr_reader :schema_cache, :last_use, :in_use, :logger - alias :in_use? :in_use + attr_reader :schema_cache, :owner, :logger + alias :in_use? :owner def self.type_cast_config_to_integer(config) if config =~ SIMPLE_INT @@ -94,9 +94,8 @@ module ActiveRecord super() @connection = connection - @in_use = false + @owner = nil @instrumenter = ActiveSupport::Notifications.instrumenter - @last_use = false @logger = logger @pool = pool @schema_cache = SchemaCache.new self @@ -114,9 +113,8 @@ module ActiveRecord def lease synchronize do - unless in_use - @in_use = true - @last_use = Time.now + unless in_use? + @owner = Thread.current end end end @@ -127,7 +125,7 @@ module ActiveRecord end def expire - @in_use = false + @owner = nil end def unprepared_visitor @@ -262,12 +260,6 @@ module ActiveRecord def active? end - # Adapter should redefine this if it needs a threadsafe way to approximate - # if the connection is active - def active_threadsafe? - active? - end - # Disconnects from the database if already connected, and establishes a # new connection with the database. Implementors should call super if they # override the default implementation. |