aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2004-08-23 15:22:46 +0000
committerWerner Koch <[email protected]>2004-08-23 15:22:46 +0000
commit5b82342c90a68b513a3116f5844062f4131ea5ab (patch)
tree82278bd1d261cfafd723ae2b3768d9361a5ce178
parent* hkp.c (dehtmlize): Understand the quote character (i.e. "&quot;") in (diff)
downloadgnupg-5b82342c90a68b513a3116f5844062f4131ea5ab.tar.gz
gnupg-5b82342c90a68b513a3116f5844062f4131ea5ab.zip
(destroy_dotlock): Remove the handle from the list of
locks. (release_dotlock): Don't act if we don't have any locks at all.
-rw-r--r--util/ChangeLog10
-rw-r--r--util/dotlock.c31
2 files changed, 37 insertions, 4 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
index d31de6a59..35f4ad72b 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,13 @@
+2004-08-23 Werner Koch <[email protected]>
+
+ * dotlock.c (destroy_dotlock): Remove the handle from the list of
+ locks.
+ (release_dotlock): Don't act if we don't have any locks at all.
+
+2004-08-19 Werner Koch <[email protected]>
+
+ * dotlock.c (destroy_dotlock): Don't act on NULL filenames.
+
2004-08-19 David Shaw <[email protected]>
* http.c (insert_escapes): Fix encoding problem for non-URI-safe
diff --git a/util/dotlock.c b/util/dotlock.c
index f28b0e409..16eb4d005 100644
--- a/util/dotlock.c
+++ b/util/dotlock.c
@@ -204,15 +204,32 @@ destroy_dotlock ( DOTLOCK h )
#if !defined (HAVE_DOSISH_SYSTEM)
if ( h )
{
+ DOTLOCK hprev, htmp;
+
+ /* First remove the handle from our global list of all locks. */
+ for (hprev=NULL, htmp=all_lockfiles; htmp; hprev=htmp, htmp=htmp->next)
+ if (htmp == h)
+ {
+ if (hprev)
+ hprev->next = htmp->next;
+ else
+ all_lockfiles = htmp->next;
+ h->next = NULL;
+ break;
+ }
+
+ /* Second destroy the lock. */
if (!h->disable)
{
- if (h->locked)
+ if (h->locked && h->lockname)
unlink (h->lockname);
- unlink (h->tname);
+ if (h->tname)
+ unlink (h->tname);
m_free (h->tname);
m_free (h->lockname);
}
m_free(h);
+
}
#endif
}
@@ -339,9 +356,15 @@ release_dotlock( DOTLOCK h )
#else
int pid;
- if( h->disable ) {
+ /* To avoid atexit race conditions we first check whether there
+ are any locks left. It might happen that another atexit
+ handler tries to release the lock while the atexit handler of
+ this module already ran and thus H is undefined. */
+ if(!all_lockfiles)
+ return 0;
+
+ if( h->disable )
return 0;
- }
if( !h->locked ) {
log_debug("oops, `%s' is not locked\n", h->lockname );