From 5f26ce699f9e695c434cbff20626a9ff4d3114e4 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 12 Mar 2012 11:51:28 -0700 Subject: make sure connections returned after close are marked as in_use --- .../connection_adapters/abstract/connection_pool.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'activerecord/lib') 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 4787bd2cbf..f198be0802 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -269,11 +269,27 @@ connection. For example: ActiveRecord::Base.connection.close conn.expire @queue.signal end + + release conn end end private + def release(conn) + thread_id = nil + + if @reserved_connections[current_connection_id] == conn + thread_id = current_connection_id + else + thread_id = @reserved_connections.keys.find { |k| + @reserved_connections[k] == conn + } + end + + @reserved_connections.delete thread_id if thread_id + end + def new_connection ActiveRecord::Base.send(spec.adapter_method, spec.config) end -- cgit v1.2.3