gpg: Avoid multiple open calls to the keybox file.
authorWerner Koch <wk@gnupg.org>
Fri, 31 Mar 2017 18:44:05 +0000 (20:44 +0200)
committerWerner Koch <wk@gnupg.org>
Fri, 31 Mar 2017 19:27:16 +0000 (21:27 +0200)
commit5556eca5acd46983bff0b38a1ffbc2f07fbaba9f
tree5bf542ac76662ed10a5b7bf9d4d7db69c7656ae3
parentaca5f494a88776d4974bfa9b0b65cb60c1b42040
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 <wk@gnupg.org>
g10/getkey.c
g10/gpg.c
g10/gpg.h
g10/keydb.h
kbx/keybox-search.c