]> the.earth.li Git - onak.git/blobdiff - keydb_db4.c
Fix maxpath to initialise the logging infrastructure.
[onak.git] / keydb_db4.c
index 899cd878467735ae8a57d5543a773c200334aa6d..0163ed53ea5bfdfb9cfb72c6e8a0b50d0cf7d6ca 100644 (file)
@@ -224,17 +224,25 @@ void cleanupdb(void)
 {
        int i = 0;
 
-       dbenv->txn_checkpoint(dbenv, 0, 0, 0);
-       id32db->close(id32db, 0);
-       id32db = NULL;
-       worddb->close(worddb, 0);
-       worddb = NULL;
-       for (i = 0; i < numdbs; i++) {
-               dbconns[i]->close(dbconns[i], 0);
-               dbconns[i] = NULL;
+       if (dbenv != NULL) {
+               dbenv->txn_checkpoint(dbenv, 0, 0, 0);
+               if (id32db != NULL) {
+                       id32db->close(id32db, 0);
+                       id32db = NULL;
+               }
+               if (worddb != NULL) {
+                       worddb->close(worddb, 0);
+                       worddb = NULL;
+               }
+               for (i = 0; i < numdbs; i++) {
+                       if (dbconns[i] != NULL) {
+                               dbconns[i]->close(dbconns[i], 0);
+                               dbconns[i] = NULL;
+                       }
+               }
+               dbenv->close(dbenv, 0);
+               dbenv = NULL;
        }
-       dbenv->close(dbenv, 0);
-       dbenv = NULL;
 }
 
 /**
@@ -630,10 +638,6 @@ int store_key(struct openpgp_publickey *publickey, bool intrans, bool update)
                uids = NULL;
        }
 
-       if (!intrans) {
-               endtrans();
-       }
-
        /*
         * Write the truncated 32 bit keyid so we can lookup the full id for
         * queries.
@@ -696,6 +700,10 @@ int store_key(struct openpgp_publickey *publickey, bool intrans, bool update)
                }
        }
 
+       if (!intrans) {
+               endtrans();
+       }
+
        return deadlock ? -1 : 0 ;
 }