summaryrefslogtreecommitdiff
path: root/source3/passdb/secrets.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-10-04 22:53:30 +0000
committerJeremy Allison <jra@samba.org>2002-10-04 22:53:30 +0000
commit9c94d1a2f72b6fcbbd056804837fc8719806491b (patch)
tree71d5b825cc8bebd43bf319b604a003bcddf3cdd7 /source3/passdb/secrets.c
parentfac6a13fd3cee8f3f4f7f8e3a2dbb700181c67c3 (diff)
downloadsamba-9c94d1a2f72b6fcbbd056804837fc8719806491b.tar.gz
samba-9c94d1a2f72b6fcbbd056804837fc8719806491b.tar.bz2
samba-9c94d1a2f72b6fcbbd056804837fc8719806491b.zip
Add a timeout to tdb_lock_bystring(). Ensure we never have more than
MAX_PRINT_JOBS in a queue. Jeremy. (This used to be commit bb58a08af459b4abae9d53ab98c15f40638ce52b)
Diffstat (limited to 'source3/passdb/secrets.c')
-rw-r--r--source3/passdb/secrets.c60
1 files changed, 11 insertions, 49 deletions
diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c
index 4b2c76d8b0..ad56fcedd1 100644
--- a/source3/passdb/secrets.c
+++ b/source3/passdb/secrets.c
@@ -215,7 +215,7 @@ BOOL secrets_lock_trust_account_password(char *domain, BOOL dolock)
return False;
if (dolock)
- return (tdb_lock_bystring(tdb, trust_keystr(domain)) == 0);
+ return (tdb_lock_bystring(tdb, trust_keystr(domain),0) == 0);
else
tdb_unlock_bystring(tdb, trust_keystr(domain));
return True;
@@ -579,69 +579,31 @@ NTSTATUS secrets_get_trusted_domains(TALLOC_CTX* ctx, int* enum_ctx, int max_num
return status;
}
-static SIG_ATOMIC_T gotalarm;
+/*******************************************************************************
+ Lock the secrets tdb based on a string - this is used as a primitive form of mutex
+ between smbd instances.
+*******************************************************************************/
-/***************************************************************
- Signal function to tell us we timed out.
-****************************************************************/
-
-static void gotalarm_sig(void)
-{
- gotalarm = 1;
-}
-
-/*
- lock the secrets tdb based on a string - this is used as a primitive form of mutex
- between smbd instances.
-*/
BOOL secrets_named_mutex(const char *name, unsigned int timeout)
{
- TDB_DATA key;
int ret;
if (!message_init())
return False;
- key.dptr = (char *)name;
- key.dsize = strlen(name)+1;
-
- /* Allow tdb_chainlock to be interrupted by an alarm. */
- gotalarm = 0;
- tdb_set_lock_alarm(&gotalarm);
-
- if (timeout) {
- CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
- alarm(timeout);
- }
-
- ret = tdb_chainlock(tdb, key);
-
- /* Prevent tdb_chainlock from being interrupted by an alarm. */
- tdb_set_lock_alarm(NULL);
-
- if (timeout) {
- alarm(0);
- CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN);
- if (gotalarm)
- return False;
- }
-
+ ret = tdb_lock_bystring(tdb, name, timeout);
if (ret == 0)
DEBUG(10,("secrets_named_mutex: got mutex for %s\n", name ));
return (ret == 0);
}
-/*
- unlock a named mutex
-*/
+/*******************************************************************************
+ Unlock a named mutex.
+*******************************************************************************/
+
void secrets_named_mutex_release(char *name)
{
- TDB_DATA key;
-
- key.dptr = name;
- key.dsize = strlen(name)+1;
-
- tdb_chainunlock(tdb, key);
+ tdb_unlock_bystring(tdb, name);
DEBUG(10,("secrets_named_mutex: released mutex for %s\n", name ));
}