Files
metasploit-gs/lib/msf/core/db_objects.rb
T
HD Moore 10364dc70d Fixes #1915. Only clear the connection pool if it exists
git-svn-id: file:///home/svn/framework3/trunk@9301 4d416f70-5f16-0410-b530-b9f4589650da
2010-05-14 15:55:01 +00:00

46 lines
810 B
Ruby

module Msf
##
#
# This module defines all of the DB database tables
# and creates ActiveRecord objects for each one of them
#
##
class DBManager
class Lock
@@mutex = Mutex.new
def self.mutex
@@mutex
end
end
# ActiveRecord/sqlite3 has locking issues when you update a table with a pending select
# This set of instance/class wrappers should prevent a table lock
# Straight up gangsta from spoon (ripped from BION)
module DBSave
def self.included(mod)
class << mod
def find(*args)
ActiveRecord::Base.connection_pool.clear_stale_cached_connections! if ActiveRecord::Base.connection_pool
super(*args)
end
def save(*args)
ActiveRecord::Base.connection_pool.clear_stale_cached_connections! if ActiveRecord::Base.connection_pool
super(*args)
end
end
end
end
end
end