summaryrefslogtreecommitdiff
path: root/source3/tdb/tdb.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-09-17 23:45:21 +0000
committerJeremy Allison <jra@samba.org>2002-09-17 23:45:21 +0000
commit8b46126a076075aeed31dae1c80eca1ed9f5a251 (patch)
treef562440e4e262cf8c91b4892c7a4375394dd27a2 /source3/tdb/tdb.c
parentfe92e9caedbb68756f9d4fcb8ee20c2573e9c4ae (diff)
downloadsamba-8b46126a076075aeed31dae1c80eca1ed9f5a251.tar.gz
samba-8b46126a076075aeed31dae1c80eca1ed9f5a251.tar.bz2
samba-8b46126a076075aeed31dae1c80eca1ed9f5a251.zip
Never, *ever* hold a mutex lock in the message database where there may
be traversals being attempted. Yes, this was from bitter experience (and an out of control server :-). Also allow callers to break out of a tdb_chainlock with sigalarm if desired. Jeremy. (This used to be commit a7781f91d8c1177210bffc199cd2f3b7ff993eaf)
Diffstat (limited to 'source3/tdb/tdb.c')
-rw-r--r--source3/tdb/tdb.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c
index 40e7dcd42c..5bb75ffe07 100644
--- a/source3/tdb/tdb.c
+++ b/source3/tdb/tdb.c
@@ -34,6 +34,7 @@
#include <errno.h>
#include <sys/mman.h>
#include <sys/stat.h>
+#include <signal.h>
#include "tdb.h"
#include "spinlock.h"
#else
@@ -160,6 +161,18 @@ struct list_struct {
*/
};
+/***************************************************************
+ Allow a caller to set a "alarm" flag that tdb can check to abort
+ a blocking lock on SIGALRM.
+***************************************************************/
+
+static sig_atomic_t *palarm_fired;
+
+void tdb_set_lock_alarm(sig_atomic_t *palarm)
+{
+ palarm_fired = palarm;
+}
+
/* a byte range locking function - return 0 on success
this functions locks/unlocks 1 byte at the specified offset.
@@ -186,6 +199,8 @@ static int tdb_brlock(TDB_CONTEXT *tdb, tdb_off offset,
do {
ret = fcntl(tdb->fd,lck_type,&fl);
+ if (ret == -1 && errno == EINTR && palarm_fired && *palarm_fired)
+ break;
} while (ret == -1 && errno == EINTR);
if (ret == -1) {