exclusive transaction instead of locking_mode - still not sure it does anything, but... ENGINE-581
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Tue, 25 Jun 2019 14:33:14 +0200
branchENGINE-581
changeset 3870018251280dbf
parent 3869 48fe5cb98a93
child 3871 d1d515455192
child 3872 156454dd1b99
exclusive transaction instead of locking_mode - still not sure it does anything, but...
src/pEp_internal.h
src/pgp_sequoia.c
     1.1 --- a/src/pEp_internal.h	Tue Jun 25 13:26:54 2019 +0200
     1.2 +++ b/src/pEp_internal.h	Tue Jun 25 14:33:14 2019 +0200
     1.3 @@ -17,7 +17,7 @@
     1.4  #define PARMS_MAX 32768
     1.5  
     1.6  // maximum busy wait time in ms
     1.7 -#define BUSY_WAIT_TIME 5000
     1.8 +#define BUSY_WAIT_TIME 10000
     1.9  
    1.10  // maximum line length for reading gpg.conf
    1.11  #define MAX_LINELENGTH 1024
    1.12 @@ -131,6 +131,7 @@
    1.13      sqlite3 *key_db;
    1.14      struct {
    1.15          sqlite3_stmt *begin_transaction;
    1.16 +        sqlite3_stmt *begin_transaction_excl;
    1.17          sqlite3_stmt *commit_transaction;
    1.18          sqlite3_stmt *rollback_transaction;
    1.19          sqlite3_stmt *tpk_find;
    1.20 @@ -486,4 +487,3 @@
    1.21      } while (rc == SQLITE_BUSY || rc == SQLITE_LOCKED);
    1.22      return rc;
    1.23  }
    1.24 -
     2.1 --- a/src/pgp_sequoia.c	Tue Jun 25 13:26:54 2019 +0200
     2.2 +++ b/src/pgp_sequoia.c	Tue Jun 25 14:33:14 2019 +0200
     2.3 @@ -219,6 +219,8 @@
     2.4          ERROR_OUT(NULL, PEP_INIT_CANNOT_OPEN_DB,
     2.5                    "opening keys DB: %s", sqlite3_errmsg(session->key_db));
     2.6  
     2.7 +    sqlite3_busy_timeout(session->key_db, BUSY_WAIT_TIME);
     2.8 +
     2.9      sqlite_result = sqlite3_exec(session->key_db,
    2.10                                   "PRAGMA secure_delete=true;\n"
    2.11                                   "PRAGMA foreign_keys=true;\n"
    2.12 @@ -296,6 +298,11 @@
    2.13      assert(sqlite_result == SQLITE_OK);
    2.14  
    2.15      sqlite_result
    2.16 +        = sqlite3_prepare_v2(session->key_db, "begin transaction exclusive",
    2.17 +                             -1, &session->sq_sql.begin_transaction_excl, NULL);
    2.18 +    assert(sqlite_result == SQLITE_OK);
    2.19 +
    2.20 +    sqlite_result
    2.21          = sqlite3_prepare_v2(session->key_db, "commit transaction",
    2.22                               -1, &session->sq_sql.commit_transaction, NULL);
    2.23      assert(sqlite_result == SQLITE_OK);
    2.24 @@ -697,18 +704,7 @@
    2.25      char *email = NULL;
    2.26      char *name = NULL;
    2.27  
    2.28 -    int int_result = sqlite3_exec(
    2.29 -        session->key_db,
    2.30 -        "PRAGMA locking_mode=EXCLUSIVE;\n"
    2.31 -        ,
    2.32 -        NULL,
    2.33 -        NULL,
    2.34 -        NULL
    2.35 -    );
    2.36 -    if (int_result != SQLITE_OK)
    2.37 -        status = PEP_UNKNOWN_DB_ERROR;
    2.38 -
    2.39 -    sqlite3_stmt *stmt = session->sq_sql.begin_transaction;
    2.40 +    sqlite3_stmt *stmt = session->sq_sql.begin_transaction_excl;
    2.41      int sqlite_result = Sqlite3_step(stmt);
    2.42      sqlite3_reset(stmt);
    2.43      if (sqlite_result != SQLITE_DONE)
    2.44 @@ -863,17 +859,6 @@
    2.45                        sqlite3_errmsg(session->key_db));
    2.46      }
    2.47  
    2.48 -    int int_result = sqlite3_exec(
    2.49 -        session->key_db,
    2.50 -        "PRAGMA locking_mode=NORMAL;\n"
    2.51 -        ,
    2.52 -        NULL,
    2.53 -        NULL,
    2.54 -        NULL
    2.55 -    );
    2.56 -    // FIXME: what to do here? Don't want to override status.
    2.57 -    // if (int_result != SQLITE_OK)
    2.58 -    //     status = PEP_UNKNOWN_DB_ERROR;
    2.59  
    2.60      T("(%s) -> %s", fpr, pEp_status_to_string(status));
    2.61