[git] GnuPG - branch, master, updated. gnupg-2.1.15-26-g268f6b7

by Neal H. Walfield cvs at cvs.gnupg.org
Wed Aug 31 10:47:07 CEST 2016


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  268f6b7a3403d036882b4af384ba7ab2f8c8355f (commit)
      from  b8184d2d74e5ddd5eb68836b53fe5568110e14dd (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 268f6b7a3403d036882b4af384ba7ab2f8c8355f
Author: Neal H. Walfield <neal at g10code.com>
Date:   Wed Aug 31 10:47:05 2016 +0200

    gpg: Move state local to tofu.c to a private structure.
    
    * g10/gpg.h (struct server_control_s.tofu): Move fields in_transaction
    and batch_update_started from here...
    * g10/tofu.c (struct tofu_dbs_s): ... to here.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>

diff --git a/g10/gpg.h b/g10/gpg.h
index 33a3af6..90a8866 100644
--- a/g10/gpg.h
+++ b/g10/gpg.h
@@ -82,9 +82,7 @@ struct server_control_s
   /* Local data for tofu.c  */
   struct {
     tofu_dbs_t dbs;
-    int    in_transaction;
-    int    batch_updated_wanted;
-    time_t batch_update_started;
+    int batch_updated_wanted;
   } tofu;
 
 };
diff --git a/g10/tofu.c b/g10/tofu.c
index e1f2851..88833cd 100644
--- a/g10/tofu.c
+++ b/g10/tofu.c
@@ -82,6 +82,8 @@ struct tofu_dbs_s
   } s;
 
   int in_batch_transaction;
+  int in_transaction;
+  time_t batch_update_started;
 };
 
 
@@ -176,11 +178,11 @@ begin_transaction (ctrl_t ctrl, int only_batch)
    * Note: if we wanted higher resolution, we could use
    * npth_clock_gettime.  */
   if (/* No real transactions.  */
-      ctrl->tofu.in_transaction == 0
+      dbs->in_transaction == 0
       /* There is an open batch transaction.  */
       && dbs->in_batch_transaction
       /* And some time has gone by since it was started.  */
-      && ctrl->tofu.batch_update_started != gnupg_get_time ())
+      && dbs->batch_update_started != gnupg_get_time ())
     {
       /* If we are in a batch update, then batch updates better have
          been enabled.  */
@@ -200,7 +202,7 @@ begin_transaction (ctrl_t ctrl, int only_batch)
       /* We are in batch mode, but we don't have an open batch
        * transaction.  Since the batch save point must be the outer
        * save point, it must be taken before the inner save point.  */
-      log_assert (ctrl->tofu.in_transaction == 0);
+      log_assert (dbs->in_transaction == 0);
 
       rc = gpgsql_stepx (dbs->db, &dbs->s.savepoint_batch,
                           NULL, NULL, &err,
@@ -214,18 +216,18 @@ begin_transaction (ctrl_t ctrl, int only_batch)
         }
 
       dbs->in_batch_transaction = 1;
-      ctrl->tofu.batch_update_started = gnupg_get_time ();
+      dbs->batch_update_started = gnupg_get_time ();
     }
 
   if (only_batch)
     return 0;
 
-  log_assert(ctrl->tofu.in_transaction >= 0);
-  ctrl->tofu.in_transaction ++;
+  log_assert(dbs->in_transaction >= 0);
+  dbs->in_transaction ++;
 
   rc = gpgsql_exec_printf (dbs->db, NULL, NULL, &err,
                            "savepoint inner%d;",
-                           ctrl->tofu.in_transaction);
+                           dbs->in_transaction);
   if (rc)
     {
       log_error (_("error beginning transaction on TOFU database: %s\n"),
@@ -256,7 +258,7 @@ end_transaction (ctrl_t ctrl, int only_batch)
 
       /* If we are releasing the batch transaction, then we better not
          be in a normal transaction.  */
-      log_assert (ctrl->tofu.in_transaction == 0);
+      log_assert (dbs->in_transaction == 0);
 
       if (/* Batch mode disabled?  */
           (!ctrl->tofu.batch_updated_wanted || only_batch == 2)
@@ -285,10 +287,10 @@ end_transaction (ctrl_t ctrl, int only_batch)
     }
 
   log_assert (dbs);
-  log_assert (ctrl->tofu.in_transaction > 0);
+  log_assert (dbs->in_transaction > 0);
 
   rc = gpgsql_exec_printf (dbs->db, NULL, NULL, &err,
-                           "release inner%d;", ctrl->tofu.in_transaction);
+                           "release inner%d;", dbs->in_transaction);
   if (rc)
     {
       log_error (_("error committing transaction on TOFU database: %s\n"),
@@ -297,7 +299,7 @@ end_transaction (ctrl_t ctrl, int only_batch)
       return gpg_error (GPG_ERR_GENERAL);
     }
 
-  ctrl->tofu.in_transaction --;
+  dbs->in_transaction --;
 
   return 0;
 }
@@ -311,15 +313,15 @@ rollback_transaction (ctrl_t ctrl)
   char *err = NULL;
 
   log_assert (dbs);
-  log_assert (ctrl->tofu.in_transaction > 0);
+  log_assert (dbs->in_transaction > 0);
 
   /* Be careful to not any progress made by closed transactions in
      batch mode.  */
   rc = gpgsql_exec_printf (dbs->db, NULL, NULL, &err,
                            "rollback to inner%d;",
-                           ctrl->tofu.in_transaction);
+                           dbs->in_transaction);
 
-  ctrl->tofu.in_transaction --;
+  dbs->in_transaction --;
 
   if (rc)
     {
@@ -712,12 +714,12 @@ tofu_closedbs (ctrl_t ctrl)
   tofu_dbs_t dbs;
   sqlite3_stmt **statements;
 
-  log_assert (ctrl->tofu.in_transaction == 0);
-
   dbs = ctrl->tofu.dbs;
   if (!dbs)
     return;  /* Not initialized.  */
 
+  log_assert (dbs->in_transaction == 0);
+
   end_transaction (ctrl, 2);
 
   /* Arghh, that is a surprising use of the struct.  */

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

Summary of changes:
 g10/gpg.h  |  4 +---
 g10/tofu.c | 34 ++++++++++++++++++----------------
 2 files changed, 19 insertions(+), 19 deletions(-)


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




More information about the Gnupg-commits mailing list