s3:dbwrap_torture: convert to using wrapper functions only
authorMichael Adam <obnox@samba.org>
Fri, 19 Aug 2011 08:55:22 +0000 (10:55 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 11 Oct 2011 12:17:56 +0000 (14:17 +0200)
source3/utils/dbwrap_torture.c

index 2542a2b8d329071956151fbc6bf20347858e8c5d..c48f09afb582c9cdb077f6261a89a25c2843af0b 100644 (file)
@@ -136,12 +136,13 @@ static void test_store_records(struct db_context *db, struct tevent_context *ev)
        while ((timelimit == 0) || (timeval_elapsed(&start) < timelimit)) {
                struct db_record *rec;
                TDB_DATA data;
+               TDB_DATA value;
                int ret;
                NTSTATUS status;
 
                if (!no_trans) {
                        if (verbose) DEBUG(1, ("starting transaction\n"));
-                       ret = db->transaction_start(db);
+                       ret = dbwrap_transaction_start(db);
                        if (ret != 0) {
                                DEBUG(0, ("Failed to start transaction on node "
                                          "%d\n", pnn));
@@ -152,22 +153,23 @@ static void test_store_records(struct db_context *db, struct tevent_context *ev)
                }
 
                if (verbose) DEBUG(1, ("calling fetch_lock\n"));
-               rec = db->fetch_locked(db, tmp_ctx, key);
+               rec = dbwrap_fetch_locked(db, tmp_ctx, key);
                if (rec == NULL) {
                        DEBUG(0, ("Failed to fetch record\n"));
                        goto fail;
                }
                if (verbose) DEBUG(1, ("fetched record ok\n"));
                do_sleep(torture_delay);
+               value = dbwrap_record_get_value(rec);
 
-               data.dsize = MAX(rec->value.dsize, sizeof(uint32_t) * (pnn+1));
+               data.dsize = MAX(value.dsize, sizeof(uint32_t) * (pnn+1));
                data.dptr = (unsigned char *)talloc_zero_size(tmp_ctx,
                                                              data.dsize);
                if (data.dptr == NULL) {
                        DEBUG(0, ("Failed to allocate data\n"));
                        goto fail;
                }
-               memcpy(data.dptr, rec->value.dptr,rec->value.dsize);
+               memcpy(data.dptr, value.dptr, value.dsize);
 
                counters = (uint32_t *)data.dptr;
 
@@ -175,11 +177,11 @@ static void test_store_records(struct db_context *db, struct tevent_context *ev)
                counters[pnn]++;
 
                if (verbose) DEBUG(1, ("storing data\n"));
-               status = rec->store(rec, data, TDB_REPLACE);
+               status = dbwrap_record_store(rec, data, TDB_REPLACE);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0, ("Failed to store record\n"));
                        if (!no_trans) {
-                               ret = db->transaction_cancel(db);
+                               ret = dbwrap_transaction_cancel(db);
                                if (ret != 0) {
                                        DEBUG(0, ("Error cancelling transaction.\n"));
                                }
@@ -192,7 +194,7 @@ static void test_store_records(struct db_context *db, struct tevent_context *ev)
 
                if (!no_trans) {
                        if (verbose) DEBUG(1, ("calling transaction_commit\n"));
-                       ret = db->transaction_commit(db);
+                       ret = dbwrap_transaction_commit(db);
                        if (ret != 0) {
                                DEBUG(0, ("Failed to commit transaction\n"));
                                goto fail;