g10: Fix a race condition initially creating trustdb.
* g10/tdbio.c (take_write_lock, release_write_lock): New. (put_record_into_cache, tdbio_sync, tdbio_end_transaction): Use new lock functions. (tdbio_set_dbname): Fix the race. (open_db): Don't call create_dotlock.
(backported from commit fe5c6edaed78839303d67e01e141cfc6b5de9aec)
- GnuPG-bug-id: T1675