Commit 95ba9175 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Add deadlock exception. Addresses #215.

git-svn-id: file:///svn/tokudb@1310 c7de825b-a66e-492c-adef-691d508d4ae1
parent 4c90d3a8
......@@ -64,12 +64,17 @@ void DbEnv::set_errpfx(const char *errpfx) {
the_env->set_errpfx(the_env, errpfx);
}
int DbEnv::maybe_throw_error(int err) {
int DbEnv::maybe_throw_error(int err) throw (DbException) {
if (err==0) return 0;
if (do_no_exceptions) return err;
DbException e(err);
e.set_env(this);
throw e;
if (err==DB_LOCK_DEADLOCK) {
DbDeadlockException e(this);
throw e;
} else {
DbException e(err);
e.set_env(this);
throw e;
}
}
extern "C" {
......
......@@ -41,3 +41,9 @@ void DbException::set_env(DbEnv *new_env)
{
the_env = new_env;
}
DbDeadlockException::DbDeadlockException (DbEnv *env)
: DbException(DB_LOCK_DEADLOCK)
{
this->set_env(env);
}
......@@ -7,6 +7,40 @@ class Dbt;
class DbEnv;
class DbTxn;
class Dbc;
class DbException;
class DbException : public std::exception
{
friend class DbEnv;
public:
~DbException() throw();
DbException(int err);
int get_errno() const;
const char *what() const throw();
DbEnv *get_env() const;
void set_env(DbEnv *);
private:
char *the_what;
int the_err;
DbEnv *the_env;
void FillTheWhat(void);
};
class DbDeadlockException : public DbException
{
public:
DbDeadlockException(DbEnv*);
};
class DbLockNotGrantedException
{
};
class DbMemoryException
{
};
class DbRunRecoveryException
{
};
// DBT and Dbt objects are the same pointers. So watch out if you use Dbt to make other classes (e.g., with subclassing).
class Dbt : private DBT
......@@ -107,7 +141,7 @@ class DbEnv {
DB_ENV *the_env;
DbEnv(DB_ENV *, u_int32_t /*flags*/);
int maybe_throw_error(int /*err*/);
int maybe_throw_error(int /*err*/) throw (DbException);
};
......@@ -133,21 +167,3 @@ class Dbc : protected DBC
int get(Dbt*, Dbt *, u_int32_t);
};
class DbException : public std::exception
{
friend class DbEnv;
public:
~DbException() throw();
DbException(int err);
int get_errno() const;
const char *what() const throw();
DbEnv *get_env() const;
private:
char *the_what;
int the_err;
DbEnv *the_env;
void FillTheWhat(void);
void set_env(DbEnv *);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment