Update Debian Vcs-* fields to point to git repository
[onak.git] / keydb_db4.c
index 638be28dc2583afe5932cdceeb5df0c785882f5a..d582eaaf8334c4618c8962d0c5bcd40271468cde 100644 (file)
@@ -887,7 +887,7 @@ static int db4_delete_key(uint64_t keyid, bool intrans)
                        worddb_data[ 8] = (keyid >> 24) & 0xFF;
                        worddb_data[ 9] = (keyid >> 16) & 0xFF;
                        worddb_data[10] = (keyid >>  8) & 0xFF;
-                       worddb_data[11] = keyid & 0xFF; 
+                       worddb_data[11] = keyid & 0xFF;
 
                        ret = cursor->c_get(cursor,
                                &key,
@@ -896,17 +896,14 @@ static int db4_delete_key(uint64_t keyid, bool intrans)
 
                        if (ret == 0) {
                                ret = cursor->c_del(cursor, 0);
-                               if (ret != 0) {
-                                       logthing(LOGTHING_ERROR,
-                                               "Problem deleting word: %s",
-                                               db_strerror(ret));
-                               }
                        }
 
                        if (ret != 0) {
                                logthing(LOGTHING_ERROR,
-                                       "Problem deleting word: %s",
-                                       db_strerror(ret));
+                                       "Problem deleting word: %s "
+                                       "(0x%016" PRIX64 ")",
+                                       db_strerror(ret),
+                                       keyid);
                                if (ret == DB_LOCK_DEADLOCK) {
                                        deadlock = true;
                                }
@@ -915,6 +912,42 @@ static int db4_delete_key(uint64_t keyid, bool intrans)
                ret = cursor->c_close(cursor);
                cursor = NULL;
 
+               ret = skshashdb->cursor(skshashdb,
+                       txn,
+                       &cursor,
+                       0);   /* flags */
+               get_skshash(publickey, &hash);
+
+               memset(&key, 0, sizeof(key));
+               memset(&data, 0, sizeof(data));
+               key.data = hash.hash;
+               key.size = sizeof(hash.hash);
+               data.data = &keyid;
+               data.size = sizeof(keyid);
+
+               ret = cursor->c_get(cursor,
+                       &key,
+                       &data,
+                       DB_GET_BOTH);
+
+               if (ret == 0) {
+                       ret = cursor->c_del(cursor, 0);
+               }
+
+               if (ret != 0) {
+                       logthing(LOGTHING_ERROR,
+                               "Problem deleting skshash: %s "
+                               "(0x%016" PRIX64 ")",
+                               db_strerror(ret),
+                               keyid);
+                       if (ret == DB_LOCK_DEADLOCK) {
+                               deadlock = true;
+                       }
+               }
+
+               ret = cursor->c_close(cursor);
+               cursor = NULL;
+
                /*
                 * Free our UID and word lists.
                 */
@@ -951,17 +984,14 @@ static int db4_delete_key(uint64_t keyid, bool intrans)
 
                if (ret == 0) {
                        ret = cursor->c_del(cursor, 0);
-                       if (ret != 0) {
-                               logthing(LOGTHING_ERROR,
-                                       "Problem deleting short keyid: %s",
-                                       db_strerror(ret));
-                       }
                }
 
                if (ret != 0) {
                        logthing(LOGTHING_ERROR,
-                               "Problem deleting short keyid: %s",
-                               db_strerror(ret));
+                               "Problem deleting short keyid: %s "
+                               "(0x%016" PRIX64 ")",
+                               db_strerror(ret),
+                               keyid);
                        if (ret == DB_LOCK_DEADLOCK) {
                                deadlock = true;
                        }
@@ -986,18 +1016,14 @@ static int db4_delete_key(uint64_t keyid, bool intrans)
 
                        if (ret == 0) {
                                ret = cursor->c_del(cursor, 0);
-                               if (ret != 0) {
-                                       logthing(LOGTHING_ERROR,
-                                               "Problem deleting short"
-                                               " keyid: %s",
-                                               db_strerror(ret));
-                               }
                        }
 
                        if (ret != 0) {
                                logthing(LOGTHING_ERROR,
-                                       "Problem deleting short keyid: %s",
-                                       db_strerror(ret));
+                                       "Problem deleting short keyid: %s "
+                                       "(0x%016" PRIX64 ")",
+                                       db_strerror(ret),
+                                       keyid);
                                if (ret == DB_LOCK_DEADLOCK) {
                                        deadlock = true;
                                }
@@ -1012,38 +1038,6 @@ static int db4_delete_key(uint64_t keyid, bool intrans)
 
        }
 
-       if (!deadlock) {
-               get_skshash(publickey, &hash);
-
-               memset(&key, 0, sizeof(key));
-               memset(&data, 0, sizeof(data));
-               key.data = hash.hash;
-               key.size = sizeof(hash.hash);
-               data.data = &keyid;
-               data.size = sizeof(keyid);
-
-               ret = cursor->c_get(cursor,
-                       &key,
-                       &data,
-                       DB_GET_BOTH);
-
-               if (ret == 0) {
-                       ret = cursor->c_del(cursor, 0);
-               }
-
-               if (ret != 0) {
-                       logthing(LOGTHING_ERROR,
-                               "Problem deleting skshash: %s",
-                               db_strerror(ret));
-                       if (ret == DB_LOCK_DEADLOCK) {
-                               deadlock = true;
-                       }
-               }
-
-               ret = cursor->c_close(cursor);
-               cursor = NULL;
-       }
-
        if (!deadlock) {
                key.data = &keyid;
                key.size = sizeof(keyid);
@@ -1095,7 +1089,7 @@ static int db4_store_key(struct openpgp_publickey *publickey, bool intrans,
        bool       deadlock = false;
        struct skshash hash;
 
-       keyid = get_keyid(publickey);
+       get_keyid(publickey, &keyid);
 
        if (!intrans) {
                db4_starttrans();