diff options
author | Neal H. Walfield <[email protected]> | 2015-12-15 12:09:27 +0000 |
---|---|---|
committer | Neal H. Walfield <[email protected]> | 2015-12-15 12:09:50 +0000 |
commit | f369efd6712148dc7ed40dba6d1ff5b0e169431a (patch) | |
tree | 49ee59d35181b65a7f7062b6235db207870020d7 /kbx/keybox-search.c | |
parent | gpg: Improve the keyblock cache's transparency. (diff) | |
download | gnupg-f369efd6712148dc7ed40dba6d1ff5b0e169431a.tar.gz gnupg-f369efd6712148dc7ed40dba6d1ff5b0e169431a.zip |
gpg: Improve the keyblock cache's transparency.
* kbx/keybox-search.c (keybox_seek): New function.
* g10/keydb.c (keydb_search): When reading from the cache, seek to
just after the cached record.
--
Signed-off-by: Neal H. Walfield <[email protected]>
Diffstat (limited to 'kbx/keybox-search.c')
-rw-r--r-- | kbx/keybox-search.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/kbx/keybox-search.c b/kbx/keybox-search.c index df959b67d..1edb4ae38 100644 --- a/kbx/keybox-search.c +++ b/kbx/keybox-search.c @@ -1196,3 +1196,32 @@ keybox_offset (KEYBOX_HANDLE hd) return 0; return ftello (hd->fp); } + +gpg_error_t +keybox_seek (KEYBOX_HANDLE hd, off_t offset) +{ + int err; + + if (hd->error) + return hd->error; /* still in error state */ + + if (! hd->fp) + { + if (offset == 0) + /* No need to open the file. An unopened file is effectively at + offset 0. */ + return 0; + + hd->fp = fopen (hd->kb->fname, "rb"); + if (!hd->fp) + { + hd->error = gpg_error_from_syserror (); + return hd->error; + } + } + + err = fseeko (hd->fp, offset, SEEK_SET); + hd->error = gpg_error_from_errno (err); + + return hd->error; +} |