From 9a975a868e949e61cb011422363cd07b4ec0ce43 Mon Sep 17 00:00:00 2001 From: James Peach Date: Tue, 20 May 2008 10:54:45 -0700 Subject: smbtorture: Add RAW-BENCH-TCON benchmark. Add a simple test to benchmark the rate at which a server can accept new tree connections. You can tune the length of time to run the benchmark for and the number of parallel connections to make. (This used to be commit ea3f4b93057e85c4ea516cc77dd0f293016d520c) --- source4/lib/util/time.c | 2 +- source4/lib/util/time.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/util/time.c b/source4/lib/util/time.c index a181885806..978d73cc0a 100644 --- a/source4/lib/util/time.c +++ b/source4/lib/util/time.c @@ -376,7 +376,7 @@ _PUBLIC_ NTTIME pull_nttime(uint8_t *base, uint16_t offset) /** return (tv1 - tv2) in microseconds */ -_PUBLIC_ int64_t usec_time_diff(struct timeval *tv1, struct timeval *tv2) +_PUBLIC_ int64_t usec_time_diff(const struct timeval *tv1, const struct timeval *tv2) { int64_t sec_diff = tv1->tv_sec - tv2->tv_sec; return (sec_diff * 1000000) + (int64_t)(tv1->tv_usec - tv2->tv_usec); diff --git a/source4/lib/util/time.h b/source4/lib/util/time.h index 1ab976ca78..e4008c5782 100644 --- a/source4/lib/util/time.h +++ b/source4/lib/util/time.h @@ -127,7 +127,7 @@ _PUBLIC_ NTTIME nttime_from_string(const char *s); /** return (tv1 - tv2) in microseconds */ -_PUBLIC_ int64_t usec_time_diff(struct timeval *tv1, struct timeval *tv2); +_PUBLIC_ int64_t usec_time_diff(const struct timeval *tv1, const struct timeval *tv2); /** return a zero timeval -- cgit From aa7e4b8e9cafaa5139b5111aa8ca042e6b6f65f4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 20 May 2008 21:54:36 +0200 Subject: Fix nesting tdb_traverse in a transaction Calling tdb_traverse inside a transaction led to the transaction lock being held indefinitely. This was caused by the tdb_transaction_lock/unlock inside tdb_traverse: The transaction code holds the global lock at offset TRANSACTION_LOCK. The call to tdb_transaction_lock does nothing because the transaction_lock is already being held. tdb_transaction_unlock inside tdb_wrap resets tdb->have_transaction_lock but does not release the kernel-level fcntl lock. transaction_commit later on does not release that fcntl lock either, because tdb->have_transaction_lock was already reset by tdb_transaction(). This patch does fix that problem for me. An alternative would be to make tdb->have_transaction_lock a counter that can cope with proper nesting, maybe in other places as well. Volker (This used to be commit 89543005fe2e4934b3c560c937d49304a32a7fc2) --- source4/lib/tdb/common/traverse.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/tdb/common/traverse.c b/source4/lib/tdb/common/traverse.c index 07b0c23858..5a31742e7b 100644 --- a/source4/lib/tdb/common/traverse.c +++ b/source4/lib/tdb/common/traverse.c @@ -232,20 +232,25 @@ int tdb_traverse(struct tdb_context *tdb, { struct tdb_traverse_lock tl = { NULL, 0, 0, F_WRLCK }; int ret; + int in_transaction = (tdb->transaction != NULL); if (tdb->read_only || tdb->traverse_read) { return tdb_traverse_read(tdb, fn, private_data); } - if (tdb_transaction_lock(tdb, F_WRLCK)) { - return -1; + if (!in_transaction) { + if (tdb_transaction_lock(tdb, F_WRLCK)) { + return -1; + } } tdb->traverse_write++; ret = tdb_traverse_internal(tdb, fn, private_data, &tl); tdb->traverse_write--; - tdb_transaction_unlock(tdb); + if (!in_transaction) { + tdb_transaction_unlock(tdb); + } return ret; } -- cgit From 6d4424cd45333c3029b0272528485dd2b3f8e620 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 20 May 2008 14:18:58 -0700 Subject: Convert in_transaction to a bool. Add the same fix Volker used for tdb_traverse() to tdb_traverse_read(). Jeremy. (This used to be commit e05ec3047c4fe0cc2e09a812830fc835dc35abea) --- source4/lib/tdb/common/traverse.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/tdb/common/traverse.c b/source4/lib/tdb/common/traverse.c index 5a31742e7b..69c81e6e98 100644 --- a/source4/lib/tdb/common/traverse.c +++ b/source4/lib/tdb/common/traverse.c @@ -204,18 +204,23 @@ int tdb_traverse_read(struct tdb_context *tdb, { struct tdb_traverse_lock tl = { NULL, 0, 0, F_RDLCK }; int ret; + bool in_transaction = (tdb->transaction != NULL); /* we need to get a read lock on the transaction lock here to cope with the lock ordering semantics of solaris10 */ - if (tdb_transaction_lock(tdb, F_RDLCK)) { - return -1; + if (!in_transaction) { + if (tdb_transaction_lock(tdb, F_RDLCK)) { + return -1; + } } tdb->traverse_read++; ret = tdb_traverse_internal(tdb, fn, private_data, &tl); tdb->traverse_read--; - tdb_transaction_unlock(tdb); + if (!in_transaction) { + tdb_transaction_unlock(tdb); + } return ret; } @@ -232,7 +237,7 @@ int tdb_traverse(struct tdb_context *tdb, { struct tdb_traverse_lock tl = { NULL, 0, 0, F_WRLCK }; int ret; - int in_transaction = (tdb->transaction != NULL); + bool in_transaction = (tdb->transaction != NULL); if (tdb->read_only || tdb->traverse_read) { return tdb_traverse_read(tdb, fn, private_data); -- cgit