mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-30 16:17:02 +01:00
common: New function dotlock_is_locked.
* common/dotlock.c (dotlock_is_locked): New. (dotlock_take): Set locked flag also in disabled mode. No more warning if the lock has already been taken. (dotlock_release): Clear locked flag also in disabled mode. No more warning if the lock has not been taken. -- This allow to use dotlock_take and dotlock_release even if they have already been called. Before this changes this worked too but a diagnostic was printed.
This commit is contained in:
parent
677245ba0e
commit
67b82a9c60
@ -1012,6 +1012,14 @@ dotlock_destroy (dotlock_t h)
|
||||
}
|
||||
|
||||
|
||||
/* Return true if H has been taken. */
|
||||
int
|
||||
dotlock_is_locked (dotlock_t h)
|
||||
{
|
||||
return h && !!h->locked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef HAVE_POSIX_SYSTEM
|
||||
/* Unix specific code of make_dotlock. Returns 0 on success and -1 on
|
||||
@ -1250,11 +1258,14 @@ dotlock_take (dotlock_t h, long timeout)
|
||||
int ret;
|
||||
|
||||
if ( h->disable )
|
||||
return 0; /* Locks are completely disabled. Return success. */
|
||||
{
|
||||
h->locked = 1;
|
||||
return 0; /* Locks are completely disabled. Return success. */
|
||||
}
|
||||
|
||||
if ( h->locked )
|
||||
{
|
||||
my_debug_1 ("Oops, '%s' is already locked\n", h->lockname);
|
||||
/* my_debug_1 ("'%s' is already locked (%s)\n", h->lockname); */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1346,11 +1357,14 @@ dotlock_release (dotlock_t h)
|
||||
return 0;
|
||||
|
||||
if ( h->disable )
|
||||
return 0;
|
||||
{
|
||||
h->locked = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( !h->locked )
|
||||
{
|
||||
my_debug_1 ("Oops, '%s' is not locked\n", h->lockname);
|
||||
/* my_debug_1 ("Oops, '%s' is not locked (%s)\n", h->lockname); */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -102,6 +102,7 @@ dotlock_t dotlock_create (const char *file_to_lock, unsigned int flags);
|
||||
void dotlock_set_fd (dotlock_t h, int fd);
|
||||
int dotlock_get_fd (dotlock_t h);
|
||||
void dotlock_destroy (dotlock_t h);
|
||||
int dotlock_is_locked (dotlock_t h);
|
||||
int dotlock_take (dotlock_t h, long timeout);
|
||||
int dotlock_release (dotlock_t h);
|
||||
void dotlock_remove_lockfiles (void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user