diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-30 11:45:34 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-30 11:45:34 -0800 |
commit | df9de6fc6c2e950303088500cb4f4660d89a71b6 (patch) | |
tree | 0f1c6f22060d399e8d8f8a059d311b36b0c02dc5 /activerecord/lib | |
parent | 6769293988c0d7733138a562aaa683375cbdcb78 (diff) | |
download | rails-df9de6fc6c2e950303088500cb4f4660d89a71b6.tar.gz rails-df9de6fc6c2e950303088500cb4f4660d89a71b6.tar.bz2 rails-df9de6fc6c2e950303088500cb4f4660d89a71b6.zip |
infinite loop is no longer necessary
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb | 31 |
1 files changed, 11 insertions, 20 deletions
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 0d8efa60c2..ee2e419a56 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -186,30 +186,21 @@ module ActiveRecord def checkout # Checkout an available connection synchronize do - loop do - conn = @connections.find { |c| c.lease } - - unless conn - if @connections.size < @size - conn = checkout_new_connection - conn.lease - end - end - - if conn - checkout_and_verify conn - return conn - end + conn = @connections.find { |c| c.lease } - if(active_connections.size < @connections.size) - next - else - if @size == active_connections.size - raise ConnectionTimeoutError, "could not obtain a database connection#{" within #{@timeout} seconds" if @timeout}. The max pool size is currently #{@size}; consider increasing it." - end + unless conn + if @connections.size < @size + conn = checkout_new_connection + conn.lease end + end + if conn + checkout_and_verify conn + else + raise ConnectionTimeoutError, "could not obtain a database connection#{" within #{@timeout} seconds" if @timeout}. The max pool size is currently #{@size}; consider increasing it." end + end end |