diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-01-31 23:33:05 +0000 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-01-31 23:33:05 +0000 |
commit | 33f8ef66084bbfb61bf0b4e0f53e1da5e7cc84dc (patch) | |
tree | a013b6696b33c21beb89209f5fa2a7861d090539 /vendor | |
parent | 30f180b38ab46ca1f754bb796c65132a8ffbe010 (diff) |
Close xapian db before opening it again
This *ought* to fix the problem with the alert-tracks daemon
opening more and more copies of the xapian db till it exhausts
the available file descriptors.
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb index ebb3b1cbd..157bdcff2 100644 --- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb +++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb @@ -116,17 +116,20 @@ module ActsAsXapian raise NoXapianRubyBindingsError.new("Xapian Ruby bindings not installed") unless ActsAsXapian.bindings_available raise "acts_as_xapian hasn't been called in any models" if @@init_values.empty? - # if DB is not nil, then we're already initialised, so don't do it again - # XXX we need to reopen the database each time, so Xapian gets changes to it. - # Hopefully in later version of Xapian it will autodetect this, and this can - # be commented back in again. - # return unless @@db.nil? - prepare_environment + # We need to reopen the database each time, so Xapian gets changes to it. + # Calling reopen() does not always pick up changes for reasons that I can + # only speculate about at the moment. (It is easy to reproduce this by + # changing the code below to use reopen() rather than open() followed by + # close(), and running rake spec.) + if !@@db.nil? + @@db.close + end + @@db = Xapian::Database.new(@@db_path) + # basic Xapian objects begin - @@db = Xapian::Database.new(@@db_path) @@enquire = Xapian::Enquire.new(@@db) rescue IOError => e raise "Failed to open Xapian database #{@@db_path}: #{e.message}" |