From 3bcfc68e0d158b272e0ef87bf585f79a570136ba Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 24 Sep 2005 06:49:28 +0000 Subject: r10468: - terminate tdbtorture quickly when an error is detected - more workarounds for aix not handling malloc of size 0 (This used to be commit c2b1739c6389503854f55fa8407c55071781eff4) --- source4/lib/tdb/common/io.c | 4 +++ source4/lib/tdb/common/transaction.c | 4 +++ source4/lib/tdb/tools/tdbtorture.c | 64 +++++++++++++++++++++++------------- 3 files changed, 49 insertions(+), 23 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/tdb/common/io.c b/source4/lib/tdb/common/io.c index e9d4e87ac8..355f76962f 100644 --- a/source4/lib/tdb/common/io.c +++ b/source4/lib/tdb/common/io.c @@ -97,6 +97,10 @@ static int tdb_oob(struct tdb_context *tdb, tdb_off_t len, int probe) static int tdb_write(struct tdb_context *tdb, tdb_off_t off, const void *buf, tdb_len_t len) { + if (len == 0) { + return 0; + } + if (tdb->read_only || tdb->traverse_read) { tdb->ecode = TDB_ERR_RDONLY; return -1; diff --git a/source4/lib/tdb/common/transaction.c b/source4/lib/tdb/common/transaction.c index a01f8307e9..73c0587a40 100644 --- a/source4/lib/tdb/common/transaction.c +++ b/source4/lib/tdb/common/transaction.c @@ -196,6 +196,10 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off, const void *buf, tdb_len_t len) { struct tdb_transaction_el *el; + + if (len == 0) { + return 0; + } /* if the write is to a hash head, then update the transaction hash heads */ diff --git a/source4/lib/tdb/tools/tdbtorture.c b/source4/lib/tdb/tools/tdbtorture.c index 3fc395ba98..eded561106 100644 --- a/source4/lib/tdb/tools/tdbtorture.c +++ b/source4/lib/tdb/tools/tdbtorture.c @@ -50,7 +50,7 @@ static struct tdb_context *db; static int in_transaction; -static int log_count; +static int error_count; #ifdef PRINTF_ATTRIBUTE static void tdb_log(struct tdb_context *tdb, int level, const char *format, ...) PRINTF_ATTRIBUTE(3,4); @@ -59,7 +59,7 @@ static void tdb_log(struct tdb_context *tdb, int level, const char *format, ...) { va_list ap; - log_count++; + error_count++; va_start(ap, format); vfprintf(stdout, format, ap); @@ -78,7 +78,7 @@ static void tdb_log(struct tdb_context *tdb, int level, const char *format, ...) static void fatal(const char *why) { perror(why); - exit(1); + error_count++; } static char *randbuf(int len) @@ -283,37 +283,55 @@ static void usage(void) srand(seed + i); srandom(seed + i); - for (i=0;i