Fix sequence numbers when tracing transaction.
[ccan] / ccan / tdb / transaction.c
index de653cd0e3f1ffcd7f38f59989ddb24380b8e07e..a23bb60427c574a5ac9c7f25ef7c82f32c9c6e0c 100644 (file)
@@ -457,8 +457,6 @@ int tdb_transaction_cancel_internal(struct tdb_context *tdb)
 */
 int tdb_transaction_start(struct tdb_context *tdb)
 {
-       tdb_trace(tdb, "tdb_transaction_start\n");
-
        /* some sanity checks */
        if (tdb->read_only || (tdb->flags & TDB_INTERNAL) || tdb->traverse_read) {
                TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_start: cannot start a transaction on a read-only or internal db\n"));
@@ -468,6 +466,7 @@ int tdb_transaction_start(struct tdb_context *tdb)
 
        /* cope with nested tdb_transaction_start() calls */
        if (tdb->transaction != NULL) {
+               tdb_trace(tdb, "tdb_transaction_start");
                if (!tdb->flags & TDB_NO_NESTING) {
                        tdb->transaction->nesting++;
                        TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: nesting %d\n", 
@@ -549,6 +548,8 @@ int tdb_transaction_start(struct tdb_context *tdb)
        tdb->transaction->io_methods = tdb->methods;
        tdb->methods = &transaction_methods;
 
+       /* Trace at the end, so we get sequence number correct. */
+       tdb_trace(tdb, "tdb_transaction_start");
        return 0;
        
 fail:
@@ -566,7 +567,7 @@ fail:
 */
 int tdb_transaction_cancel(struct tdb_context *tdb)
 {      
-       tdb_trace(tdb, "tdb_transaction_cancel\n");
+       tdb_trace(tdb, "tdb_transaction_cancel");
        return tdb_transaction_cancel_internal(tdb);
 }
 /*
@@ -851,7 +852,7 @@ int tdb_transaction_commit(struct tdb_context *tdb)
        uint32_t zero = 0;
        int i;
 
-       tdb_trace(tdb, "tdb_transaction_commit\n");
+       tdb_trace(tdb, "tdb_transaction_commit");
        if (tdb->transaction == NULL) {
                TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_commit: no transaction\n"));
                return -1;