diff options
author | Jeremy Allison <jra@samba.org> | 2007-11-07 06:59:02 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2007-12-21 05:44:42 +0100 |
commit | 2cb22d93ae0eef86a4bcf0fe5f7fb138e43db880 (patch) | |
tree | 3e49b118d890235da51b85a9b2175a13fa5be936 /source4/lib/tdb/common | |
parent | 27c9f6c235c3c625f4c4e60a73d8f2e86bd4a186 (diff) | |
download | samba-2cb22d93ae0eef86a4bcf0fe5f7fb138e43db880.tar.gz samba-2cb22d93ae0eef86a4bcf0fe5f7fb138e43db880.tar.bz2 samba-2cb22d93ae0eef86a4bcf0fe5f7fb138e43db880.zip |
r25892: Keep the tdb code in sync between 3.2.x and 4.0.
Add in the alarm fix to allow locks to exit on
alarm signal.
Sync up the changes in tools.
Jeremy.
(This used to be commit cb6c663fa8818f49cc36f196bb5f4dea47edd69e)
Diffstat (limited to 'source4/lib/tdb/common')
-rw-r--r-- | source4/lib/tdb/common/io.c | 8 | ||||
-rw-r--r-- | source4/lib/tdb/common/lock.c | 12 | ||||
-rw-r--r-- | source4/lib/tdb/common/tdb_private.h | 2 |
3 files changed, 19 insertions, 3 deletions
diff --git a/source4/lib/tdb/common/io.c b/source4/lib/tdb/common/io.c index 3b7e712cfe..c963e66ad4 100644 --- a/source4/lib/tdb/common/io.c +++ b/source4/lib/tdb/common/io.c @@ -94,7 +94,7 @@ static int tdb_write(struct tdb_context *tdb, tdb_off_t off, /* try once more */ TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_write: wrote only " "%d of %d bytes at %d, trying once more\n", - written, len, off)); + (int)written, len, off)); errno = ENOSPC; written = pwrite(tdb->fd, (void *)((char *)buf+written), len-written, @@ -274,11 +274,13 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad return -1; } else if (written == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file write of " - "%d bytes failed (%s)\n", n, strerror(errno))); + "%d bytes failed (%s)\n", (int)n, + strerror(errno))); return -1; } else if (written != n) { TDB_LOG((tdb, TDB_DEBUG_WARNING, "expand_file: wrote " - "only %d of %d bytes - retrying\n", written,n)); + "only %d of %d bytes - retrying\n", (int)written, + (int)n)); } addition -= written; size += written; diff --git a/source4/lib/tdb/common/lock.c b/source4/lib/tdb/common/lock.c index c0cb9c8766..e3fe888c46 100644 --- a/source4/lib/tdb/common/lock.c +++ b/source4/lib/tdb/common/lock.c @@ -29,6 +29,11 @@ #define TDB_MARK_LOCK 0x80000000 +void tdb_setalarm_sigptr(struct tdb_context *tdb, volatile sig_atomic_t *ptr) +{ + tdb->interrupt_sig_ptr = ptr; +} + /* a byte range locking function - return 0 on success this functions locks/unlocks 1 byte at the specified offset. @@ -60,6 +65,13 @@ int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset, do { ret = fcntl(tdb->fd,lck_type,&fl); + + /* Check for a sigalarm break. */ + if (ret == -1 && errno == EINTR && + tdb->interrupt_sig_ptr && + *tdb->interrupt_sig_ptr) { + break; + } } while (ret == -1 && errno == EINTR); if (ret == -1) { diff --git a/source4/lib/tdb/common/tdb_private.h b/source4/lib/tdb/common/tdb_private.h index 99fa4434c0..00bd0eb537 100644 --- a/source4/lib/tdb/common/tdb_private.h +++ b/source4/lib/tdb/common/tdb_private.h @@ -28,6 +28,7 @@ #include "system/time.h" #include "system/shmem.h" #include "system/select.h" +#include "system/wait.h" #include "tdb.h" #ifndef HAVE_GETPAGESIZE @@ -162,6 +163,7 @@ struct tdb_context { int page_size; int max_dead_records; bool have_transaction_lock; + volatile sig_atomic_t *interrupt_sig_ptr; }; |