]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/registry/bdb.rb
bdb: restore errors should be logged as errors
[user/henk/code/ruby/rbot.git] / lib / rbot / registry / bdb.rb
index 200e38ee6532c1d287bc82e5ae82a4be269a6ee5..8410d8aced93dd9a82e9c52e39809d97b0155e8f 100644 (file)
@@ -6,7 +6,7 @@
 begin
   require 'bdb'
 rescue LoadError
-  fatal "rbot couldn't load the bdb module, perhaps you need to install it? try: http://www.ruby-lang.org/en/raa-list.rhtml?name=bdb"
+  fatal "rbot couldn't load the bdb module, perhaps you need to install it? try http://www.ruby-lang.org/en/raa-list.rhtml?name=bdb or http://github.com/knu/ruby-bdb"
 rescue Exception => e
   fatal "rbot couldn't load the bdb module: #{e.pretty_inspect}"
 end
@@ -15,6 +15,10 @@ if not defined? BDB
   exit 2
 end
 
+module Irc
+  DBFatal = BDB::Fatal
+end
+
 if BDB::VERSION_MAJOR < 4
   fatal "Your bdb (Berkeley DB) version #{BDB::VERSION} is too old!"
   fatal "rbot will only run with bdb version 4 or higher, please upgrade."
@@ -32,7 +36,7 @@ module BDB
   class CIBtree < Btree
     def bdb_bt_compare(a, b)
       if a == nil || b == nil
-        warning "CIBTree: comparing #{a.inspect} (#{self[a].inspect}) with #{b.inspect} (#{self[b].inspect})"
+        warning "CIBTree: comparing key #{a.inspect} with #{b.inspect}"
       end
       (a||'').downcase <=> (b||'').downcase
     end
@@ -142,6 +146,10 @@ module Irc
     end
 
     def DBTree.cleanup_logs()
+      if @@env.nil?
+        debug "No BDB environment, skipping checkpoint"
+        return
+      end
       begin
         debug "DBTree: checkpointing ..."
         @@env.checkpoint
@@ -162,6 +170,10 @@ module Irc
     end
 
     def DBTree.stats()
+      if @@env.nil?
+        debug "No BDB environment, no stats"
+        return
+      end
       begin
         debug "General stats:"
         debug @@env.stat
@@ -177,6 +189,10 @@ module Irc
     end
 
     def DBTree.cleanup_env()
+      if @@env.nil?
+        debug "No BDB environment, skipping cleanup"
+        return
+      end
       begin
         debug "DBTree: checking transactions ..."
         has_active_txn = @@env.txn_stat["st_nactive"] > 0
@@ -361,6 +377,7 @@ class Bot
       # debug "closing registry #{registry}"
       return if !@registry
       registry.close
+      @registry = nil
     end
 
     # convert value to string form for storing in the registry
@@ -392,7 +409,7 @@ class Bot
             return @recovery.call(val)
           rescue Exception => ee
             error _("marshal recovery failed, trying default")
-            debug ee
+            error ee
           end
         end
         return default