[git] GnuPG - branch, master, updated. gnupg-2.1.10-35-gf369efd

by Neal H. Walfield cvs at cvs.gnupg.org
Tue Dec 15 13:09:58 CET 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  f369efd6712148dc7ed40dba6d1ff5b0e169431a (commit)
      from  2e4e10c1dcd8dfeafec51f44ebf26acfeb770c41 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f369efd6712148dc7ed40dba6d1ff5b0e169431a
Author: Neal H. Walfield <neal at g10code.com>
Date:   Tue Dec 15 13:09:27 2015 +0100

    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 <neal at g10code.com>

diff --git a/g10/keydb.c b/g10/keydb.c
index 860187f..b308199 100644
--- a/g10/keydb.c
+++ b/g10/keydb.c
@@ -1717,6 +1717,12 @@ keydb_search (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc,
       /* (DESCINDEX is already set).  */
       if (DBG_CLOCK)
         log_clock ("keydb_search leave (cached)");
+
+      hd->current = hd->keyblock_cache.resource;
+      /* HD->KEYBLOCK_CACHE.OFFSET is the last byte in the record.
+         Seek just beyond that.  */
+      keybox_seek (hd->active[hd->current].u.kb,
+                   hd->keyblock_cache.offset + 1);
       return 0;
     }
 
diff --git a/kbx/keybox-search.c b/kbx/keybox-search.c
index df959b6..1edb4ae 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;
+}
diff --git a/kbx/keybox.h b/kbx/keybox.h
index c91a282..8b75db4 100644
--- a/kbx/keybox.h
+++ b/kbx/keybox.h
@@ -77,8 +77,6 @@ int keybox_set_ephemeral (KEYBOX_HANDLE hd, int yes);
 
 int keybox_lock (KEYBOX_HANDLE hd, int yes);
 
-off_t keybox_offset (KEYBOX_HANDLE hd);
-
 /*-- keybox-file.c --*/
 /* Fixme: This function does not belong here: Provide a better
    interface to create a new keybox file.  */
@@ -97,6 +95,8 @@ int keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc,
                    keybox_blobtype_t want_blobtype,
                    size_t *r_descindex, unsigned long *r_skipped);
 
+off_t keybox_offset (KEYBOX_HANDLE hd);
+gpg_error_t keybox_seek (KEYBOX_HANDLE hd, off_t offset);
 
 /*-- keybox-update.c --*/
 gpg_error_t keybox_insert_keyblock (KEYBOX_HANDLE hd,

-----------------------------------------------------------------------

Summary of changes:
 g10/keydb.c         |  6 ++++++
 kbx/keybox-search.c | 29 +++++++++++++++++++++++++++++
 kbx/keybox.h        |  4 ++--
 3 files changed, 37 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list