X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/blobdiff_plain/8b4052ad6015aa9f54c9c824f28655f230d09d8d..23817f46df40d242f476a82f677bd8aa22f22aca:/keydb_db4.c diff --git a/keydb_db4.c b/keydb_db4.c index 899cd87..0163ed5 100644 --- a/keydb_db4.c +++ b/keydb_db4.c @@ -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 ; }