Rev 774: merge from samba4 in http://samba.org/~tridge/ctdb
tridge at samba.org
tridge at samba.org
Fri Jan 18 04:48:37 GMT 2008
------------------------------------------------------------
revno: 774
revision-id:tridge at samba.org-20080118044836-breaxa1j2sdox553
parent: tridge at samba.org-20080118023254-ub38q3s5eqfbhu74
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge.stable
timestamp: Fri 2008-01-18 15:48:36 +1100
message:
merge from samba4
modified:
lib/tdb/common/open.c open.c-20070220022425-m1wibgjq7n5hahs6-8
lib/tdb/common/tdb.c tdb.c-20070220022425-m1wibgjq7n5hahs6-9
lib/tdb/common/tdb_private.h tdb_private.h-20070220022425-m1wibgjq7n5hahs6-10
lib/tdb/common/transaction.c transaction.c-20070220022425-m1wibgjq7n5hahs6-11
lib/tdb/common/traverse.c traverse.c-20070220022425-m1wibgjq7n5hahs6-12
lib/tdb/docs/README readme-20070125040949-7t3f5zdl1q4z9hyv-98
lib/tdb/include/tdb.h tdb.h-20070125040949-7t3f5zdl1q4z9hyv-101
lib/tdb/tools/tdbtool.c tdbtool.c-20070125040949-7t3f5zdl1q4z9hyv-108
=== modified file 'lib/tdb/common/open.c'
--- a/lib/tdb/common/open.c 2008-01-05 06:41:41 +0000
+++ b/lib/tdb/common/open.c 2008-01-18 04:48:36 +0000
@@ -179,9 +179,7 @@
tdb->page_size = 0x2000;
}
- if (open_flags & TDB_VOLATILE) {
- tdb->max_dead_records = 5;
- }
+ tdb->max_dead_records = (tdb_flags & TDB_VOLATILE) ? 5 : 0;
if ((open_flags & O_ACCMODE) == O_WRONLY) {
TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: can't open tdb %s write-only\n",
@@ -229,6 +227,7 @@
/* we need to zero database if we are the only one with it open */
if ((tdb_flags & TDB_CLEAR_IF_FIRST) &&
+ (!tdb->read_only) &&
(locked = (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_WRLCK, F_SETLK, 0, 1) == 0))) {
open_flags |= O_CREAT;
if (ftruncate(tdb->fd, 0) == -1) {
@@ -288,7 +287,6 @@
tdb->map_size = st.st_size;
tdb->device = st.st_dev;
tdb->inode = st.st_ino;
- tdb->max_dead_records = 0;
tdb_mmap(tdb);
if (locked) {
if (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_UNLCK, F_SETLK, 0, 1) == -1) {
=== modified file 'lib/tdb/common/tdb.c'
--- a/lib/tdb/common/tdb.c 2008-01-14 04:11:10 +0000
+++ b/lib/tdb/common/tdb.c 2008-01-18 04:48:36 +0000
@@ -743,45 +743,3 @@
tdb_unlockall(tdb);
return -1;
}
-
-
-/*
- validate the integrity of all tdb hash chains. Useful when debugging
- */
-int tdb_validate(struct tdb_context *tdb)
-{
- int h;
- for (h=-1;h<(int)tdb->header.hash_size;h++) {
- tdb_off_t rec_ptr;
- uint32_t count = 0;
- if (tdb_ofs_read(tdb, TDB_HASH_TOP(h), &rec_ptr) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_validate: failed ofs_read at top of hash %d\n", h));
- return -1;
- }
- while (rec_ptr) {
- struct list_struct r;
- tdb_off_t size;
-
- if (tdb_rec_read(tdb, rec_ptr, &r) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_validate: failed rec_read h=%d rec_ptr=%u count=%u\n",
- h, rec_ptr, count));
- return -1;
- }
- if (tdb_ofs_read(tdb, rec_ptr + sizeof(r) + r.rec_len - sizeof(tdb_off_t), &size) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_validate: failed ofs_read h=%d rec_ptr=%u count=%u\n",
- h, rec_ptr, count));
- return -1;
- }
- if (size != r.rec_len + sizeof(r)) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_validate: failed size check size=%u h=%d rec_ptr=%u count=%u\n",
- size, h, rec_ptr, count));
- return -1;
- }
- rec_ptr = r.next;
- count++;
- }
- }
- return 0;
-}
-
-
=== modified file 'lib/tdb/common/tdb_private.h'
--- a/lib/tdb/common/tdb_private.h 2008-01-18 02:32:54 +0000
+++ b/lib/tdb/common/tdb_private.h 2008-01-18 04:48:36 +0000
@@ -177,6 +177,7 @@
int tdb_munmap(struct tdb_context *tdb);
void tdb_mmap(struct tdb_context *tdb);
int tdb_lock(struct tdb_context *tdb, int list, int ltype);
+int tdb_lock_nonblock(struct tdb_context *tdb, int list, int ltype);
int tdb_unlock(struct tdb_context *tdb, int list, int ltype);
int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset, int rw_type, int lck_type, int probe, size_t len);
int tdb_transaction_lock(struct tdb_context *tdb, int ltype);
=== modified file 'lib/tdb/common/transaction.c'
--- a/lib/tdb/common/transaction.c 2008-01-15 04:28:07 +0000
+++ b/lib/tdb/common/transaction.c 2008-01-18 04:48:36 +0000
@@ -219,9 +219,12 @@
uint8_t **new_blocks;
/* expand the blocks array */
if (tdb->transaction->blocks == NULL) {
- new_blocks = malloc((blk+1)*sizeof(uint8_t *));
+ new_blocks = (uint8_t **)malloc(
+ (blk+1)*sizeof(uint8_t *));
} else {
- new_blocks = realloc(tdb->transaction->blocks, (blk+1)*sizeof(uint8_t *));
+ new_blocks = (uint8_t **)realloc(
+ tdb->transaction->blocks,
+ (blk+1)*sizeof(uint8_t *));
}
if (new_blocks == NULL) {
tdb->ecode = TDB_ERR_OOM;
=== modified file 'lib/tdb/common/traverse.c'
--- a/lib/tdb/common/traverse.c 2008-01-05 06:41:41 +0000
+++ b/lib/tdb/common/traverse.c 2008-01-18 04:48:36 +0000
@@ -223,6 +223,9 @@
/*
a write style traverse - needs to get the transaction lock to
prevent deadlocks
+
+ WARNING: The data buffer given to the callback fn does NOT meet the
+ alignment restrictions malloc gives you.
*/
int tdb_traverse(struct tdb_context *tdb,
tdb_traverse_func fn, void *private_data)
=== modified file 'lib/tdb/docs/README'
--- a/lib/tdb/docs/README 2007-01-25 04:10:40 +0000
+++ b/lib/tdb/docs/README 2008-01-18 04:48:36 +0000
@@ -130,6 +130,9 @@
a non-zero return value from fn() indicates that the traversal
should stop. Traversal callbacks may not start transactions.
+ WARNING: The data buffer given to the callback fn does NOT meet the
+ alignment restrictions malloc gives you.
+
----------------------------------------------------------------------
int tdb_traverse_read(TDB_CONTEXT *tdb, int (*fn)(TDB_CONTEXT *tdb,
TDB_DATA key, TDB_DATA dbuf, void *state), void *state);
=== modified file 'lib/tdb/include/tdb.h'
--- a/lib/tdb/include/tdb.h 2008-01-14 04:11:10 +0000
+++ b/lib/tdb/include/tdb.h 2008-01-18 04:48:36 +0000
@@ -32,9 +32,9 @@
/* flags to tdb_store() */
-#define TDB_REPLACE 1
-#define TDB_INSERT 2
-#define TDB_MODIFY 3
+#define TDB_REPLACE 1 /* Unused */
+#define TDB_INSERT 2 /* Don't overwrite an existing entry */
+#define TDB_MODIFY 3 /* Don't create an existing entry */
/* flags for tdb_open() */
#define TDB_DEFAULT 0 /* just a readability place holder */
@@ -157,7 +157,6 @@
int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries);
int tdb_wipe_all(struct tdb_context *tdb);
int tdb_freelist_size(struct tdb_context *tdb);
-int tdb_validate(struct tdb_context *tdb);
extern TDB_DATA tdb_null;
=== modified file 'lib/tdb/tools/tdbtool.c'
--- a/lib/tdb/tools/tdbtool.c 2008-01-05 06:41:41 +0000
+++ b/lib/tdb/tools/tdbtool.c 2008-01-18 04:48:36 +0000
@@ -135,7 +135,7 @@
if (len<=0) return;
printf("[%03X] ",i);
for (i=0;i<len;) {
- printf("%02X ",(int)buf[i]);
+ printf("%02X ",(int)((unsigned char)buf[i]));
i++;
if (i%8 == 0) printf(" ");
if (i%16 == 0) {
More information about the samba-cvs
mailing list