2013-04-17 00:00:36 -04:00
|
|
|
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
|
|
// vim: expandtab:ts=8:sw=4:softtabstop=4:
|
2007-12-18 20:39:02 +00:00
|
|
|
#include <db_cxx.h>
|
2007-12-18 19:37:59 +00:00
|
|
|
|
|
|
|
DbTxn::DbTxn(DB_TXN *txn)
|
|
|
|
: the_txn(txn)
|
|
|
|
{
|
|
|
|
txn->api_internal = this;
|
|
|
|
}
|
|
|
|
|
2007-12-22 18:40:22 +00:00
|
|
|
DbTxn::~DbTxn()
|
|
|
|
{
|
|
|
|
if (the_txn) {
|
|
|
|
the_txn->abort(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-20 23:49:10 +00:00
|
|
|
int DbTxn::commit (u_int32_t flags) {
|
2007-12-22 18:40:22 +00:00
|
|
|
DbEnv *env = (DbEnv*)the_txn->mgrp->api1_internal; // Must grab the env before committing the txn (because that releases the txn memory.)
|
|
|
|
int ret = the_txn->commit(the_txn, flags);
|
|
|
|
the_txn=0; // So we don't touch it my mistake.
|
2007-12-21 19:59:31 +00:00
|
|
|
return env->maybe_throw_error(ret);
|
2007-12-20 23:49:10 +00:00
|
|
|
}
|
2007-12-31 13:27:49 +00:00
|
|
|
|
|
|
|
int DbTxn::abort () {
|
|
|
|
DbEnv *env = (DbEnv*)the_txn->mgrp->api1_internal; // Must grab the env before committing the txn (because that releases the txn memory.)
|
|
|
|
int ret = the_txn->abort(the_txn);
|
|
|
|
the_txn=0; // So we don't touch it my mistake.
|
|
|
|
return env->maybe_throw_error(ret);
|
|
|
|
}
|