gnupg/g10
Neal H. Walfield 7a634e48b1 g10: Avoid gratuitious SQLite aborts and starving writers.
* g10/tofu.c: Include <time.h>, <utime.h>, <fcntl.h> and <unistd.h>.
(tofu_dbs_s): Add fields want_lock_file and want_lock_file_ctime.
(begin_transaction): Only yield if DBS->WANT_LOCK_FILE_CTIME has
changed since we took the lock.  Don't use gpgrt_yield to yield, but
sleep for 100ms.  After taking the batch lock, update
DBS->WANT_LOCK_FILE_CTIME.  Also take the batch lock the first time we
take the real lock.  When taking the real lock, use immediate not
deferred mode to avoid gratuitious aborts.
(end_transaction): When dropping the outermost real lock, drop the
batch lock.
(busy_handler): New function.
(opendbs): Set the busy handler to it when opening the DB.  Initialize
CTRL->TOFU.DBS->WANT_LOCK_FILE.
(tofu_closedbs): Free DBS->WANT_LOCK_FILE.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>

By default, SQLite defers transactions until they are actually needed.
A consequence of this is that if we have two readers and both decide
to do a write, then one has to abort.  To avoid this problem, we can
make the outermost transaction an immediate transaction.  This has the
disadvantage that we only allow a single reader at a time, but at
least we don't have gratuitous aborts anymore.

A second problem is that SQLite apparently doesn't actually create a
queue of waiters.  The result is that doing a sched_yield between
dropping and retaking the batch transaction is not enough to allow the
other process to make progress.  Instead, we need to wait a
while (emperically: 100ms seems reasonable).  To avoid waiting when
there is no contention, we use a new file's timestamp to signal that
there is a waiter.
2016-10-30 19:10:42 -07:00
..
ChangeLog-2011 Generate the ChangeLog from commit logs. 2011-12-01 11:09:02 +01:00
Makefile.am g10: Add missing sqrtu32.h and sqrtu32.c. 2016-09-07 08:55:17 +02:00
OPTIONS See ChangeLog: Mon Jul 31 10:04:47 CEST 2000 Werner Koch 2000-07-31 08:04:16 +00:00
armor.c Fix more spelling 2016-09-17 16:00:37 +09:00
build-packet.c gpg: Enable the Issuer Fingerprint from rfc4880bis 2016-10-28 21:01:51 +02:00
call-agent.c scd: Use canonical curve name of libgcrypt. 2016-10-24 11:22:44 +09:00
call-agent.h g10: smartcard keygen change. 2016-10-20 13:30:47 +09:00
call-dirmngr.c gpg: Convey --quick option to dirmngr for --auto-key-retrieve. 2016-10-27 09:06:10 +02:00
call-dirmngr.h gpg: Convey --quick option to dirmngr for --auto-key-retrieve. 2016-10-27 09:06:10 +02:00
card-util.c gpg: Convey --quick option to dirmngr for --auto-key-retrieve. 2016-10-27 09:06:10 +02:00
cipher.c gpg: Remove all assert.h and s/assert/log_assert/. 2016-04-29 11:05:24 +02:00
compress-bz2.c common: Fix iobuf API of filter function for alignment. 2016-01-12 10:32:20 +09:00
compress.c g10: Fix memory leak. 2016-06-30 18:50:16 +02:00
cpr.c Fix use cases of snprintf. 2016-10-21 12:04:46 +09:00
dearmor.c gpg: Remove all assert.h and s/assert/log_assert/. 2016-04-29 11:05:24 +02:00
decrypt-data.c gpg: Remove all assert.h and s/assert/log_assert/. 2016-04-29 11:05:24 +02:00
decrypt.c gpg: Remove all assert.h and s/assert/log_assert/. 2016-04-29 11:05:24 +02:00
dek.h gpg: Improve API documentation. 2016-02-14 14:46:30 +01:00
delkey.c gpg: Allow unattended deletion of secret keys. 2016-05-10 11:01:42 +02:00
dirmngr-conf.skel dirmngr: Change the Onion keyserver in the conf template. 2015-12-23 20:06:49 +01:00
distsigkey.gpg Add more signing keys. 2014-10-31 14:21:34 +01:00
ecdh.c g10: Fix ECDH, clarifying the format. 2016-10-27 13:04:45 +09:00
encrypt.c gpg: Cleanup of dek_to_passphrase function (part 2). 2016-08-08 20:32:08 +02:00
exec.c gpg: Replace remaining old error code macros by GPG_ERR_. 2015-01-22 12:06:11 +01:00
exec.h Changed to GPLv3. 2007-07-04 19:49:40 +00:00
export.c gpg: New export filter drop-subkey. 2016-09-05 09:52:04 +02:00
filter.h gpg: Remove PGP-2 related cruft. 2014-11-13 12:01:42 +01:00
free-packet.c gpg: Allow to cache the mbox in a user id struct. 2016-07-01 16:27:43 +02:00
getkey.c g10: Fix iteration over getkey results. 2016-10-27 15:31:30 +02:00
gpg-w32info.rc w32: Add manifest to gpg. 2015-02-04 09:15:34 +01:00
gpg.c gpg: Put extra parens around bit tests. 2016-10-07 07:54:38 +02:00
gpg.h gpg: Move state local to tofu.c to a private structure. 2016-08-31 10:47:05 +02:00
gpg.w32-manifest.in w32: Add manifest to gpg. 2015-02-04 09:15:34 +01:00
gpgcompose.c Fix symbol conflict. 2016-09-10 13:42:09 -04:00
gpgsql.c gpg: Avoid name spaces clash with future sqlite versions (2). 2016-08-31 10:14:19 +02:00
gpgsql.h gpg: Avoid name spaces clash with future sqlite versions (2). 2016-08-31 10:14:19 +02:00
gpgv.c gpg: Convey --quick option to dirmngr for --auto-key-retrieve. 2016-10-27 09:06:10 +02:00
helptext.c Change all quotes in strings and comments to the new GNU standard. 2012-06-05 19:29:22 +02:00
import.c Fix typos. 2016-10-27 14:59:56 +02:00
kbnode.c g10: Fix build with disabled kbnode cache. 2016-07-01 12:50:29 +02:00
keydb.c g10: Write first keybox record in binary mode 2016-10-21 15:02:19 +02:00
keydb.h gpg: Cleanup of dek_to_passphrase function (part 2). 2016-08-08 20:32:08 +02:00
keyedit.c g10: When adding a user id, make sure the keyblock has been prepared. 2016-09-22 21:32:31 +02:00
keygen.c gpg: Replace two sprintf calls. 2016-10-24 13:12:05 +02:00
keyid.c gpg: Fix regression in gpgv's printing of the keyid. 2016-08-31 08:48:28 +02:00
keylist.c gpg: Fix regression in fingerprint printing. 2016-09-19 17:48:04 +02:00
keyring.c gpg,gpgsm: Block signals during keyring/keybox update. 2016-08-03 15:31:27 +02:00
keyring.h gpg: Change keydb_search to not return legacy keys. 2015-11-17 14:53:05 +01:00
keyserver-internal.h gpg: Convey --quick option to dirmngr for --auto-key-retrieve. 2016-10-27 09:06:10 +02:00
keyserver.c gpg: Convey --quick option to dirmngr for --auto-key-retrieve. 2016-10-27 09:06:10 +02:00
main.h gpg: Make import filter data object more flexible. 2016-09-28 13:47:34 +02:00
mainproc.c gpg: Enable the Issuer Fingerprint from rfc4880bis 2016-10-28 21:01:51 +02:00
mdfilter.c gpg: Remove all assert.h and s/assert/log_assert/. 2016-04-29 11:05:24 +02:00
migrate.c Replace use of opt.homedir by accessor functions. 2016-06-07 10:59:46 +02:00
misc.c gpg: Remove all assert.h and s/assert/log_assert/. 2016-04-29 11:05:24 +02:00
openfile.c Fix use cases of snprintf. 2016-10-21 12:04:46 +09:00
options.h gpg: Put extra parens around bit tests. 2016-10-07 07:54:38 +02:00
options.skel gpg: Rework gpg-conf.skel 2016-01-22 10:54:10 +01:00
packet.h gpg: Fix printing of pubkey algo in --verbose signature verify. 2016-09-01 16:39:41 +02:00
parse-packet.c gpg: Put extra parens around bit tests. 2016-10-07 07:54:38 +02:00
passphrase.c Fix use cases of snprintf. 2016-10-21 12:04:46 +09:00
photoid.c gpg: Pass CTRL object down to the trust functions 2016-05-21 11:41:49 +02:00
photoid.h gpg: Pass CTRL object down to the trust functions 2016-05-21 11:41:49 +02:00
pkclist.c Fix typos. 2016-10-27 14:59:56 +02:00
pkglue.c gpg: Fix false negatives in Ed25519 signature verification. 2016-08-25 16:18:00 +02:00
pkglue.h gpg: Use only OpenPGP public key algo ids and add the EdDSA algo id. 2014-01-30 18:48:37 +01:00
plaintext.c gpg: New option --mimemode. 2016-07-13 13:31:12 +02:00
progress.c gpg: New option --input-size-hint. 2016-08-11 21:32:55 +02:00
pubkey-enc.c gpg: Remove all assert.h and s/assert/log_assert/. 2016-04-29 11:05:24 +02:00
pubring.asc See ChangeLog: Mon Jul 31 10:04:47 CEST 2000 Werner Koch 2000-07-31 08:04:16 +00:00
revoke.c g10: Implement gpg --quick-revuid 2016-06-30 11:45:13 +02:00
rmd160.c Nuked almost all trailing white space. 2011-02-04 12:57:53 +01:00
rmd160.h Add missing header file. 2008-12-12 08:54:50 +00:00
seckey-cert.c gpg: Remove all assert.h and s/assert/log_assert/. 2016-04-29 11:05:24 +02:00
server.c gpg: New options --recipient-file and --hidden-recipient-file. 2016-07-06 15:35:19 +02:00
seskey.c gpg: Do not abort on certain invalid packets. 2016-06-02 15:57:59 +02:00
sig-check.c gpg: Fix printing of pubkey algo in --verbose signature verify. 2016-09-01 16:39:41 +02:00
sign.c gpg: New option --sender 2016-08-18 10:08:34 +02:00
skclist.c gpg: Remove all assert.h and s/assert/log_assert/. 2016-04-29 11:05:24 +02:00
sqrtu32.c g10: Add missing sqrtu32.h and sqrtu32.c. 2016-09-07 08:55:17 +02:00
sqrtu32.h g10: Add missing sqrtu32.h and sqrtu32.c. 2016-09-07 08:55:17 +02:00
t-keydb-get-keyblock.c g10: Fix memory leaks. 2016-06-28 18:21:50 +02:00
t-keydb-get-keyblock.gpg gpg: Correctly handle keyblocks followed by legacy keys. 2015-11-17 14:53:03 +01:00
t-keydb-keyring.kbx g10: Add test for keydb as well as new testing infrastructure. 2015-09-02 15:08:57 +02:00
t-keydb.c g10: Fix memory leaks. 2016-06-28 18:21:50 +02:00
t-rmd160.c Nuked almost all trailing white space. 2011-02-04 12:57:53 +01:00
t-stutter-data.asc gpg: Add a new test. 2016-03-08 14:08:49 +01:00
t-stutter.c Fix trivial memory leaks in tests. 2016-07-01 09:47:48 +02:00
tdbdump.c gpg: Remove all assert.h and s/assert/log_assert/. 2016-04-29 11:05:24 +02:00
tdbio.c g10: Fix opening of trust database. 2016-08-10 16:50:29 +02:00
tdbio.h gpg: Replace -1 by GPG_ERR_NOT_FOUND in tdbio.c 2015-06-04 18:08:26 +02:00
test-stubs.c gpg: Convey --quick option to dirmngr for --auto-key-retrieve. 2016-10-27 09:06:10 +02:00
test.c tests: Silence output of some tests. 2016-05-03 11:26:06 +02:00
textfilter.c common: Fix memory leak. 2016-06-30 18:50:16 +02:00
tofu.c g10: Avoid gratuitious SQLite aborts and starving writers. 2016-10-30 19:10:42 -07:00
tofu.h g10: Record and show statistics for encrypted messages when using TOFU 2016-09-06 21:37:48 +02:00
trust.c gpg: Pass CTRL object down to the trust functions 2016-05-21 11:41:49 +02:00
trustdb.c g10: Add missing header. 2016-09-15 14:46:06 +02:00
trustdb.h gpg: Pass CTRL object down to the trust functions 2016-05-21 11:41:49 +02:00
verify.c gpg: Remove all assert.h and s/assert/log_assert/. 2016-04-29 11:05:24 +02:00
zlib-riscos.h include: Remove this directory. 2014-01-29 17:45:05 +01:00