Merge pull request #53 from rapid7/bug/MSP-9994/framework-db-driver

Set `framework.db.driver` when connection already established.
bug/bundler_fix
jvennix-r7 2014-06-10 10:49:00 -05:00
commit 92414d3688
2 changed files with 7 additions and 6 deletions

View File

@ -11,7 +11,7 @@ GIT
PATH
remote: .
specs:
metasploit-framework (4.9.2.pre.dev)
metasploit-framework (4.9.3.pre.dev)
activesupport (>= 3.0.0, < 4.0.0)
bcrypt
json
@ -69,12 +69,12 @@ GEM
activerecord (>= 3.2.13, < 4.0.0)
activesupport
pg
mini_portile (0.5.3)
mini_portile (0.6.0)
msgpack (0.5.8)
multi_json (1.0.4)
network_interface (0.0.1)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
nokogiri (1.6.2.1)
mini_portile (= 0.6.0)
packetfu (1.1.9)
pcaprub (0.11.3)
pg (0.17.1)

View File

@ -129,7 +129,7 @@ class DBManager
ActiveRecord::Base.connection_pool.with_connection {
ActiveRecord::Base.connection.active?
}
rescue PG::ConnectionBad => error
rescue ActiveRecord::ConnectionNotEstablished, PG::ConnectionBad => error
elog("Connection not established: #{error.class} #{error}:\n#{error.backtrace.join("\n")}")
false
@ -144,6 +144,8 @@ class DBManager
if connection_established? && ActiveRecord::Base.connection_config[:adapter] == ADAPTER
dlog("Already established connection to #{ADAPTER}, so reusing active connection.")
self.drivers << ADAPTER
self.driver = ADAPTER
else
begin
ActiveRecord::Base.establish_connection(adapter: ADAPTER)
@ -151,7 +153,6 @@ class DBManager
rescue Exception => error
@adapter_error = error
else
# @deprecated Use in RPC_Db, but only postgresql is supported, so useless otherwise
self.drivers << ADAPTER
self.driver = ADAPTER
end