diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-12-01 05:56:51 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-12-01 05:56:51 +0000 |
commit | 2e2bf2d1494aa8b4efc4ff9e132dde4afd15ece1 (patch) | |
tree | bf2110842dc41d39e76c6dddf671a8e6d5ac9fd2 /activerecord/lib | |
parent | e8eb743ba679ccfe13e3cd15f140b539f1562340 (diff) | |
download | rails-2e2bf2d1494aa8b4efc4ff9e132dde4afd15ece1.tar.gz rails-2e2bf2d1494aa8b4efc4ff9e132dde4afd15ece1.tar.bz2 rails-2e2bf2d1494aa8b4efc4ff9e132dde4afd15ece1.zip |
If only life was that simple (it didnt help)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5658 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
4 files changed, 20 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb index ae59176fa3..31c288b932 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb @@ -86,6 +86,14 @@ module ActiveRecord conn.disconnect! end end + + # Clears the cache which maps classes + def clear_reloadable_connections! + @@active_connections.each do |name, conn| + conn.disconnect! if conn.supports_reloading? + @@active_connections.delete(name) + end + end # Verify active connections. def verify_active_connections! #:nodoc: diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 949b8f7951..07e3182761 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -79,6 +79,12 @@ module ActiveRecord @active = false end + # Returns true if its safe 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 supports_reloading? + false + end + # Lazily verify this connection, calling +active?+ only if it hasn't # been called for +timeout+ seconds. def verify!(timeout) diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index b0c86f51a5..341e546084 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -102,6 +102,10 @@ module ActiveRecord true end + def supports_reloading? + true + end + def supports_count_distinct? #:nodoc: sqlite_version >= '3.2.6' end diff --git a/activerecord/lib/active_record/vendor/mysql.rb b/activerecord/lib/active_record/vendor/mysql.rb index 58ebed7d4f..0d8cc2efd8 100644 --- a/activerecord/lib/active_record/vendor/mysql.rb +++ b/activerecord/lib/active_record/vendor/mysql.rb @@ -1173,14 +1173,8 @@ class << Mysql def finalizer(net) proc { - begin - net.clear - net.write Mysql::COM_QUIT.chr - net.close - rescue Error => error - # Swallow lost connection errors if connection is already closed. - raise unless error.errno == Error::CR_SERVER_LOST - end + net.clear + net.write Mysql::COM_QUIT.chr } end |