summaryrefslogtreecommitdiffstats
path: root/g10/tdbio.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1999-01-07 18:05:48 +0100
committerWerner Koch <wk@gnupg.org>1999-01-07 18:05:48 +0100
commit7d0efec7cf5ae110c99511abc32587ff0c45b14f (patch)
treec25f43c0b175ca31c84da4e9a256b259ea070fc7 /g10/tdbio.c
parentSee ChangeLog: Sun Jan 3 15:28:44 CET 1999 Werner Koch (diff)
downloadgnupg2-7d0efec7cf5ae110c99511abc32587ff0c45b14f.tar.xz
gnupg2-7d0efec7cf5ae110c99511abc32587ff0c45b14f.zip
See ChangeLog: Thu Jan 7 18:00:58 CET 1999 Werner Koch
Diffstat (limited to 'g10/tdbio.c')
-rw-r--r--g10/tdbio.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/g10/tdbio.c b/g10/tdbio.c
index 094f23c87..b69d6c3f0 100644
--- a/g10/tdbio.c
+++ b/g10/tdbio.c
@@ -389,11 +389,25 @@ tdbio_cancel_transaction()
**************** cached I/O functions ******************
********************************************************/
+static void
+cleanup(void)
+{
+ if( lockname ) {
+ release_dotlock(lockname);
+ lockname = NULL;
+ }
+}
+
int
tdbio_set_dbname( const char *new_dbname, int create )
{
char *fname;
+ static int initialized = 0;
+ if( !initialized ) {
+ atexit( cleanup );
+ initialized = 1;
+ }
fname = new_dbname? m_strdup( new_dbname )
: make_filename(opt.homedir, "trustdb.gpg", NULL );
@@ -480,14 +494,6 @@ tdbio_get_dbname()
}
-static void
-cleanup(void)
-{
- if( lockname ) {
- release_dotlock(lockname);
- lockname = NULL;
- }
-}
static void
open_db()
@@ -504,7 +510,6 @@ open_db()
log_fatal( _("%s: can't open: %s\n"), db_name, strerror(errno) );
if( tdbio_read_record( 0, &rec, RECTYPE_VER ) )
log_fatal( _("%s: invalid trustdb\n"), db_name );
- atexit( cleanup );
}