]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
tdbtorture: No transaction with mutexes
authorVolker Lendecke <vl@samba.org>
Mon, 22 Oct 2018 15:18:43 +0000 (17:18 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 25 Oct 2018 15:58:24 +0000 (17:58 +0200)
Right now we don't do transactions with mutexed tdbs. tdbtorture -m
locks up. I haven't really investigated why that is the case. The lockup
confused me quite a bit until I figured out it works fine as long as it
does not do transactions, which is all we need right now.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
lib/tdb/tools/tdbtorture.c

index 3640dc7ed6cd592fcc21d1f3cb4d82d037c54b8c..1655c28dfc83430fe35835c5ff8f28dd9fd28698 100644 (file)
@@ -93,6 +93,19 @@ static int cull_traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf,
        return 0;
 }
 
+static bool do_transaction(void)
+{
+#if TRANSACTION_PROB
+       if (mutex) {
+               return false;
+       }
+       if (random() % TRANSACTION_PROB == 0) {
+               return true;
+       }
+#endif
+       return false;
+}
+
 static void addrec_db(void)
 {
        int klen, dlen;
@@ -118,16 +131,15 @@ static void addrec_db(void)
        }
 #endif
 
-#if TRANSACTION_PROB
        if (in_transaction == 0 &&
-           (always_transaction || random() % TRANSACTION_PROB == 0)) {
+           (always_transaction || do_transaction())) {
                if (tdb_transaction_start(db) != 0) {
                        fatal("tdb_transaction_start failed");
                }
                in_transaction++;
                goto next;
        }
-       if (in_transaction && random() % TRANSACTION_PROB == 0) {
+       if (in_transaction && do_transaction()) {
                if (random() % TRANSACTION_PREPARE_PROB == 0) {
                        if (tdb_transaction_prepare_commit(db) != 0) {
                                fatal("tdb_transaction_prepare_commit failed");
@@ -139,14 +151,13 @@ static void addrec_db(void)
                in_transaction--;
                goto next;
        }
-       if (in_transaction && random() % TRANSACTION_PROB == 0) {
+       if (in_transaction && do_transaction()) {
                if (tdb_transaction_cancel(db) != 0) {
                        fatal("tdb_transaction_cancel failed");
                }
                in_transaction--;
                goto next;
        }
-#endif
 
 #if DELETE_PROB
        if (random() % DELETE_PROB == 0) {