summaryrefslogtreecommitdiffstats
path: root/g10/keydb.h
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2017-10-18 18:28:52 +0200
committerWerner Koch <wk@gnupg.org>2017-10-18 18:28:52 +0200
commit645f30ad310a518a863eb7bd3e11251a7e7f2eca (patch)
tree5e40963b60cf50eb7169d09624ae4be4401a2035 /g10/keydb.h
parentgpg: Improve keydb handling in the main import function. (diff)
downloadgnupg2-645f30ad310a518a863eb7bd3e11251a7e7f2eca.tar.xz
gnupg2-645f30ad310a518a863eb7bd3e11251a7e7f2eca.zip
gpg: Keep a lock during the read-update/insert cycle in import.
* g10/keydb.c (keydb_handle): New field 'keep_lock'. (keydb_release): Clear that flag. (keydb_lock): New function. (unlock_all): Skip if KEEP_LOCK is set. * g10/getkey.c (get_keyblock_byfprint_fast): Call keep_lock if requested. -- That change is straightforward. It helps to avoid the race condition that another gpg process inserts a key while the first process is between the search and the insert. A similar change is due for gpgsm. Note that the key edit operations may still suffer from a race. GnuPG-bug-id: 3446
Diffstat (limited to 'g10/keydb.h')
-rw-r--r--g10/keydb.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/g10/keydb.h b/g10/keydb.h
index b173751ca..739376838 100644
--- a/g10/keydb.h
+++ b/g10/keydb.h
@@ -154,6 +154,10 @@ KEYDB_HANDLE keydb_new (void);
/* Free all resources owned by the database handle. */
void keydb_release (KEYDB_HANDLE hd);
+/* Take a lock on the files immediately and not only during insert or
+ * update. This lock is released with keydb_release. */
+gpg_error_t keydb_lock (KEYDB_HANDLE hd);
+
/* Set a flag on the handle to suppress use of cached results. This
is required for updating a keyring and for key listings. Fixme:
Using a new parameter for keydb_new might be a better solution. */