summaryrefslogtreecommitdiff
path: root/source3/tdb
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2003-01-30 23:55:58 +0000
committerJeremy Allison <jra@samba.org>2003-01-30 23:55:58 +0000
commitbbf9f09ee5c58e348eef33448d2c38e588adb66a (patch)
tree69d4922f84219502a123dc29c52a5f96d5f048d2 /source3/tdb
parent920287bf6b6950abfac53e6430954aee7e76bd15 (diff)
downloadsamba-bbf9f09ee5c58e348eef33448d2c38e588adb66a.tar.gz
samba-bbf9f09ee5c58e348eef33448d2c38e588adb66a.tar.bz2
samba-bbf9f09ee5c58e348eef33448d2c38e588adb66a.zip
Add 3 second timeout when terminating server and sending print notify
messages. Stops build-up of large numbers of smbd's waiting to terminate on large print throughput. Jeremy. (This used to be commit 07efebb98473cb3d4adc6b2e0afef3f06dcc99b8)
Diffstat (limited to 'source3/tdb')
-rw-r--r--source3/tdb/tdbutil.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/source3/tdb/tdbutil.c b/source3/tdb/tdbutil.c
index da155de4d7..0d8f6128cc 100644
--- a/source3/tdb/tdbutil.c
+++ b/source3/tdb/tdbutil.c
@@ -51,7 +51,7 @@ static TDB_DATA make_tdb_data(const char *dptr, size_t dsize)
Lock a chain with timeout (in seconds).
****************************************************************************/
-static int tdb_chainlock_with_timeout( TDB_CONTEXT *tdb, TDB_DATA key, unsigned int timeout, int rw_type)
+static int tdb_chainlock_with_timeout_internal( TDB_CONTEXT *tdb, TDB_DATA key, unsigned int timeout, int rw_type)
{
/* Allow tdb_chainlock to be interrupted by an alarm. */
int ret;
@@ -72,7 +72,7 @@ static int tdb_chainlock_with_timeout( TDB_CONTEXT *tdb, TDB_DATA key, unsigned
alarm(0);
CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN);
if (gotalarm) {
- DEBUG(0,("tdb_chainlock_with_timeout: alarm (%u) timed out for key %s in tdb %s\n",
+ DEBUG(0,("tdb_chainlock_with_timeout_internal: alarm (%u) timed out for key %s in tdb %s\n",
timeout, key.dptr, tdb->name ));
/* TODO: If we time out waiting for a lock, it might
* be nice to use F_GETLK to get the pid of the
@@ -86,6 +86,15 @@ static int tdb_chainlock_with_timeout( TDB_CONTEXT *tdb, TDB_DATA key, unsigned
}
/****************************************************************************
+ Write lock a chain. Return -1 if timeout or lock failed.
+****************************************************************************/
+
+int tdb_chainlock_with_timeout( TDB_CONTEXT *tdb, TDB_DATA key, unsigned int timeout)
+{
+ return tdb_chainlock_with_timeout_internal(tdb, key, timeout, F_WRLCK);
+}
+
+/****************************************************************************
Lock a chain by string. Return -1 if timeout or lock failed.
****************************************************************************/
@@ -93,7 +102,7 @@ int tdb_lock_bystring(TDB_CONTEXT *tdb, const char *keyval, unsigned int timeout
{
TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1);
- return tdb_chainlock_with_timeout(tdb, key, timeout, F_WRLCK);
+ return tdb_chainlock_with_timeout_internal(tdb, key, timeout, F_WRLCK);
}
/****************************************************************************
@@ -115,7 +124,7 @@ int tdb_read_lock_bystring(TDB_CONTEXT *tdb, const char *keyval, unsigned int ti
{
TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1);
- return tdb_chainlock_with_timeout(tdb, key, timeout, F_RDLCK);
+ return tdb_chainlock_with_timeout_internal(tdb, key, timeout, F_RDLCK);
}
/****************************************************************************