diff options
author | Werner Koch <wk@gnupg.org> | 2019-08-23 15:51:13 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2019-08-23 15:51:43 +0200 |
commit | e64f0dfd72de548837f630bccd249a87451b89c5 (patch) | |
tree | 55c282ab9ea9ad9b210a3c38981986ec37bb749c | |
parent | kbx: Include deleted records into the --stats output. (diff) | |
download | gnupg2-e64f0dfd72de548837f630bccd249a87451b89c5.tar.xz gnupg2-e64f0dfd72de548837f630bccd249a87451b89c5.zip |
gpg,sm: Implement keybox compression run and release lock in gpgsm
* g10/keydb.c (keydb_add_resource): Call keybox_compress.
* sm/keydb.c (keydb_add_resource): Release the lock after a compress.
--
Note that in gpgsm we already did the compress run but we didn't
released the lock on the file. This might have been a reason for some
strange hangs.
GnuPG-bug-id: 4644
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to '')
-rw-r--r-- | g10/keydb.c | 17 | ||||
-rw-r--r-- | sm/keydb.c | 5 |
2 files changed, 19 insertions, 3 deletions
diff --git a/g10/keydb.c b/g10/keydb.c index a7691bbe2..92e5faae8 100644 --- a/g10/keydb.c +++ b/g10/keydb.c @@ -805,14 +805,27 @@ keydb_add_resource (const char *url, unsigned int flags) err = gpg_error (GPG_ERR_RESOURCE_LIMIT); else { + KEYBOX_HANDLE kbxhd; + if ((flags & KEYDB_RESOURCE_FLAG_PRIMARY)) primary_keydb = token; all_resources[used_resources].type = rt; all_resources[used_resources].u.kb = NULL; /* Not used here */ all_resources[used_resources].token = token; - /* FIXME: Do a compress run if needed and no other - user is currently using the keybox. */ + /* Do a compress run if needed and no other user is + * currently using the keybox. */ + kbxhd = keybox_new_openpgp (token, 0); + if (kbxhd) + { + if (!keybox_lock (kbxhd, 1, 0)) + { + keybox_compress (kbxhd); + keybox_lock (kbxhd, 0, 0); + } + + keybox_release (kbxhd); + } used_resources++; } diff --git a/sm/keydb.c b/sm/keydb.c index 53e3cf887..16ed85be5 100644 --- a/sm/keydb.c +++ b/sm/keydb.c @@ -362,7 +362,10 @@ keydb_add_resource (ctrl_t ctrl, const char *url, int force, int *auto_created) if (kbxhd) { if (!keybox_lock (kbxhd, 1, 0)) - keybox_compress (kbxhd); + { + keybox_compress (kbxhd); + keybox_lock (kbxhd, 0, 0); + } keybox_release (kbxhd); } |