diff options
author | Gerald Carter <jerry@samba.org> | 2002-09-25 15:19:00 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2002-09-25 15:19:00 +0000 |
commit | 65e7b5273bb58802bf0c389b77f7fcae0a1f6139 (patch) | |
tree | 672f59370f72efa2b3f4471bf311e0159e004a13 /source/tdb/tdb.c | |
parent | b5d03c7b55fb2f34fa4d0228abe4389020e5ed5f (diff) | |
download | samba-65e7b5273bb58802bf0c389b77f7fcae0a1f6139.tar.gz samba-65e7b5273bb58802bf0c389b77f7fcae0a1f6139.tar.xz samba-65e7b5273bb58802bf0c389b77f7fcae0a1f6139.zip |
sync'ing up for 3.0alpha20 release
Diffstat (limited to 'source/tdb/tdb.c')
-rw-r--r-- | source/tdb/tdb.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/tdb/tdb.c b/source/tdb/tdb.c index ed75a55e3e9..5bb75ffe077 100644 --- a/source/tdb/tdb.c +++ b/source/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; } |