diff options
author | Werner Koch <[email protected]> | 2017-03-31 18:44:05 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2017-03-31 19:27:16 +0000 |
commit | 5556eca5acd46983bff0b38a1ffbc2f07fbaba9f (patch) | |
tree | 5bf542ac76662ed10a5b7bf9d4d7db69c7656ae3 /kbx/keybox-search.c | |
parent | gpg: Pass CTRL also to getkey_end. (diff) | |
download | gnupg-5556eca5acd46983bff0b38a1ffbc2f07fbaba9f.tar.gz gnupg-5556eca5acd46983bff0b38a1ffbc2f07fbaba9f.zip |
gpg: Avoid multiple open calls to the keybox file.
* g10/keydb.h (KEYDB_HANDLE): Move typedef to ...
* g10/gpg.h: here.
(struct server_control_s): Add field 'cached_getkey_kdb'.
* g10/gpg.c (gpg_deinit_default_ctrl): Release that keydb handle.
* g10/getkey.c (getkey_end): Cache keydb handle.
(get_pubkey): Use cached keydb handle.
* kbx/keybox-search.c (keybox_search_reset): Use lseek instead of
closing the file.
--
Before this patch a "gpg --check-sigs" opened and closed the keybox
file for almost every signature check. By caching the keydb handle
and using lseek(2) this can be limited to just 2 times. This might
speed up things on Windows.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'kbx/keybox-search.c')
-rw-r--r-- | kbx/keybox-search.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/kbx/keybox-search.c b/kbx/keybox-search.c index 56515d16a..0bd4e0182 100644 --- a/kbx/keybox-search.c +++ b/kbx/keybox-search.c @@ -746,8 +746,13 @@ keybox_search_reset (KEYBOX_HANDLE hd) if (hd->fp) { - fclose (hd->fp); - hd->fp = NULL; + if (fseeko (hd->fp, 0, SEEK_SET)) + { + /* Ooops. Seek did not work. Close so that the search will + * open the file again. */ + fclose (hd->fp); + hd->fp = NULL; + } } hd->error = 0; hd->eof = 0; |