From 62c4e4d3856b38ee9869f4ad6342e712788c8635 Mon Sep 17 00:00:00 2001 From: Edgars Beigarts Date: Tue, 22 Jun 2010 11:48:11 +0300 Subject: Fix connection reloading in development mode. [#4929 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- .../active_record/connection_adapters/abstract/connection_pool.rb | 4 +++- .../lib/active_record/connection_adapters/abstract_adapter.rb | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb index 979ed52f4a..c2d79a421d 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -144,7 +144,9 @@ module ActiveRecord @connections.each do |conn| conn.disconnect! if conn.requires_reloading? end - @connections = [] + @connections.delete_if do |conn| + conn.requires_reloading? + end end # Verify active connections and remove and disconnect connections diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 4ee9fee4a9..4567539566 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -142,9 +142,10 @@ module ActiveRecord # this should be overridden by concrete adapters end - # Returns true if its safe to reload the connection between requests for development mode. + # Returns true if its required to reload the connection between requests for development mode. + # This is not the case for Ruby/MySQL and it's not necessary for any adapters except SQLite. def requires_reloading? - true + false end # Checks whether the connection to the database is still active (i.e. not stale). -- cgit v1.2.3