summaryrefslogtreecommitdiff
path: root/source3/tdb
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-09-25 15:19:00 +0000
committerGerald Carter <jerry@samba.org>2002-09-25 15:19:00 +0000
commita834a73e341059be154426390304a42e4a011f72 (patch)
tree7f53b0f7819238e0ee0396daccf5d924cb9b8d29 /source3/tdb
parent115a39775cb923d026dde58633b6ba6aef3a1943 (diff)
downloadsamba-a834a73e341059be154426390304a42e4a011f72.tar.gz
samba-a834a73e341059be154426390304a42e4a011f72.tar.bz2
samba-a834a73e341059be154426390304a42e4a011f72.zip
sync'ing up for 3.0alpha20 release
(This used to be commit 65e7b5273bb58802bf0c389b77f7fcae0a1f6139)
Diffstat (limited to 'source3/tdb')
-rw-r--r--source3/tdb/spinlock.c1
-rw-r--r--source3/tdb/tdb.c18
-rw-r--r--source3/tdb/tdb.h1
-rw-r--r--source3/tdb/tdbbackup.c1
-rw-r--r--source3/tdb/tdbdump.c1
-rw-r--r--source3/tdb/tdbtest.c1
-rw-r--r--source3/tdb/tdbtool.c1
7 files changed, 24 insertions, 0 deletions
diff --git a/source3/tdb/spinlock.c b/source3/tdb/spinlock.c
index 74472854cf..2370ce3bdd 100644
--- a/source3/tdb/spinlock.c
+++ b/source3/tdb/spinlock.c
@@ -30,6 +30,7 @@
#include <errno.h>
#include <sys/stat.h>
#include <time.h>
+#include <signal.h>
#include "tdb.h"
#include "spinlock.h"
diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c
index ed75a55e3e..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) {
@@ -517,17 +532,20 @@ int tdb_printfreelist(TDB_CONTEXT *tdb)
/* read in the freelist top */
if (ofs_read(tdb, offset, &rec_ptr) == -1) {
+ tdb_unlock(tdb, -1, F_WRLCK);
return 0;
}
printf("freelist top=[0x%08x]\n", rec_ptr );
while (rec_ptr) {
if (tdb_read(tdb, rec_ptr, (char *)&rec, sizeof(rec), DOCONV()) == -1) {
+ tdb_unlock(tdb, -1, F_WRLCK);
return -1;
}
if (rec.magic != TDB_FREE_MAGIC) {
printf("bad magic 0x%08x in free list\n", rec.magic);
+ tdb_unlock(tdb, -1, F_WRLCK);
return -1;
}
diff --git a/source3/tdb/tdb.h b/source3/tdb/tdb.h
index 8cc908703f..42b88aeb16 100644
--- a/source3/tdb/tdb.h
+++ b/source3/tdb/tdb.h
@@ -126,6 +126,7 @@ int tdb_lockall(TDB_CONTEXT *tdb);
void tdb_unlockall(TDB_CONTEXT *tdb);
/* Low level locking functions: use with care */
+void tdb_set_lock_alarm(sig_atomic_t *palarm);
int tdb_chainlock(TDB_CONTEXT *tdb, TDB_DATA key);
int tdb_chainunlock(TDB_CONTEXT *tdb, TDB_DATA key);
diff --git a/source3/tdb/tdbbackup.c b/source3/tdb/tdbbackup.c
index f59f98a90f..36ba7db918 100644
--- a/source3/tdb/tdbbackup.c
+++ b/source3/tdb/tdbbackup.c
@@ -53,6 +53,7 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <ctype.h>
+#include <signal.h>
#include "tdb.h"
static int failed;
diff --git a/source3/tdb/tdbdump.c b/source3/tdb/tdbdump.c
index 6664213209..9c1dc2761b 100644
--- a/source3/tdb/tdbdump.c
+++ b/source3/tdb/tdbdump.c
@@ -30,6 +30,7 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <ctype.h>
+#include <signal.h>
#include "tdb.h"
static void print_data(TDB_DATA d)
diff --git a/source3/tdb/tdbtest.c b/source3/tdb/tdbtest.c
index 0741073ce1..89295a3291 100644
--- a/source3/tdb/tdbtest.c
+++ b/source3/tdb/tdbtest.c
@@ -8,6 +8,7 @@
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/time.h>
+#include <signal.h>
#include "tdb.h"
#include <gdbm.h>
diff --git a/source3/tdb/tdbtool.c b/source3/tdb/tdbtool.c
index ba0fb48957..f529c6e6ee 100644
--- a/source3/tdb/tdbtool.c
+++ b/source3/tdb/tdbtool.c
@@ -33,6 +33,7 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <ctype.h>
+#include <signal.h>
#include "tdb.h"
/* a tdb tool for manipulating a tdb database */