[git] GnuPG - branch, master, updated. gnupg-2.1.9-67-gc18fb0d

by Neal H. Walfield cvs at cvs.gnupg.org
Mon Oct 26 13:42:14 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  c18fb0d99b633bb267dead6e7c46229f4b780bc3 (commit)
       via  5b0ed7674dc718ee98e0c80aa93ce014f2b51411 (commit)
      from  5e7ac031f513ad3b60e4f092fa72b3bec0676515 (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 c18fb0d99b633bb267dead6e7c46229f4b780bc3
Author: Neal H. Walfield <neal at g10code.com>
Date:   Mon Oct 26 13:41:07 2015 +0100

    gpg: Make sure we only have a single SQL statement.
    
    * g10/tofu.c (sqlite3_stepx): Make sure SQL only contains a single SQL
    statement.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>

diff --git a/g10/tofu.c b/g10/tofu.c
index 4eab487..43a6224 100644
--- a/g10/tofu.c
+++ b/g10/tofu.c
@@ -289,10 +289,25 @@ sqlite3_stepx (sqlite3 *db,
     }
   else
     {
-      rc = sqlite3_prepare_v2 (db, sql, -1, &stmt, NULL);
+      const char *tail = NULL;
+
+      rc = sqlite3_prepare_v2 (db, sql, -1, &stmt, &tail);
       if (rc)
         log_fatal ("failed to prepare SQL: %s", sql);
 
+      /* We can only process a single statement.  */
+      if (tail)
+        {
+          while (*tail == ' ' || *tail == ';')
+            tail ++;
+
+          if (*tail)
+            log_fatal
+              ("sqlite3_stepx can only process a single SQL statement."
+               "  Second statement starts with: '%s'\n",
+               tail);
+        }
+
       if (stmtp)
         *stmtp = stmt;
     }

commit 5b0ed7674dc718ee98e0c80aa93ce014f2b51411
Author: Neal H. Walfield <neal at g10code.com>
Date:   Mon Oct 26 13:36:12 2015 +0100

    gpg: When the TOFU DB is in batch mode, periodically drop the locks.
    
    * g10/tofu.c: Include <sched.h>.
    (batch_update_started): New variable.
    (begin_transaction): If we've been in batch mode for a while, then
    commit any extant batch transactions.
    (tofu_begin_batch_update): If we are not in batch mode, initialize
    batch_update_started.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>

diff --git a/g10/tofu.c b/g10/tofu.c
index ad61536..4eab487 100644
--- a/g10/tofu.c
+++ b/g10/tofu.c
@@ -28,6 +28,7 @@
 #include <sys/stat.h>
 #include <assert.h>
 #include <stdarg.h>
+#include <sched.h>
 #include <sqlite3.h>
 
 #include "gpg.h"
@@ -422,6 +423,9 @@ sqlite3_stepx (sqlite3 *db,
 }
 

 static int batch_update;
+static time_t batch_update_started;
+
+static gpg_error_t end_transaction (struct db *db, int only_batch);
 
 /* Start a transaction on DB.  */
 static gpg_error_t
@@ -430,6 +434,29 @@ begin_transaction (struct db *db, int only_batch)
   int rc;
   char *err = NULL;
 
+  if (batch_update && batch_update_started != gnupg_get_time ())
+    /* We've been in batch update mode for a while (on average, more
+       than 500 ms).  To prevent starving other gpg processes, we drop
+       and retake the batch lock.
+
+       Note: if we wanted higher resolution, we could use
+       npth_clock_gettime.  */
+    {
+      struct db *t;
+
+      for (t = db_cache; t; t = t->next)
+        if (t->batch_update)
+          end_transaction (t, 1);
+      for (t = db; t; t = t->next)
+        if (t->batch_update)
+          end_transaction (t, 1);
+
+      batch_update_started = gnupg_get_time ();
+
+      /* Yield to allow another process a chance to run.  */
+      sched_yield ();
+    }
+
   /* XXX: In split mode, this can end in deadlock.
 
      Consider: we have two gpg processes running simultaneously and
@@ -556,6 +583,9 @@ rollback_transaction (struct db *db)
 void
 tofu_begin_batch_update (void)
 {
+  if (! batch_update)
+    batch_update_started = gnupg_get_time ();
+
   batch_update ++;
 }
 

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

Summary of changes:
 g10/tofu.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)


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




More information about the Gnupg-commits mailing list