Skip to content

Instantly share code, notes, and snippets.

@nicksieger
Created September 4, 2008 08:43
Show Gist options
  • Save nicksieger/8739 to your computer and use it in GitHub Desktop.
Save nicksieger/8739 to your computer and use it in GitHub Desktop.
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 838b043..c7f04de 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -201,7 +201,7 @@ module ActiveRecord
def checkout_and_verify(c)
c.run_callbacks :checkout
- c.verify!(verification_timeout)
+ c.verify_now!
@checked_out << c
c
end
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
index 005be9d..da67662 100755
--- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -128,11 +128,15 @@ module ActiveRecord
def verify!(timeout)
now = Time.now.to_i
if (now - @last_verification) > timeout
- reconnect! unless active?
- @last_verification = now
+ verify_now! now
end
end
+ def verify_now!(now = Time.now.to_i)
+ reconnect! unless active?
+ @last_verification = now
+ end
+
# Provides access to the underlying database connection. Useful for
# when you need to call a proprietary method such as postgresql's lo_*
# methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment