diff --git a/c_src/bdberl_drv.c b/c_src/bdberl_drv.c index d61c016..8b53950 100644 --- a/c_src/bdberl_drv.c +++ b/c_src/bdberl_drv.c @@ -193,11 +193,17 @@ static TPool* G_TPOOL_TXNS = NULL; }} #define FAIL_IF_TXN_OPEN(d, outbuf) { \ - if (d->txn) \ + if (NULL != d->txn) \ { \ send_rc(d->port, d->port_owner, ERROR_TXN_OPEN); \ RETURN_INT(0, outbuf); \ }} +#define FAIL_IF_NO_TXN(d, outbuf) { \ + if (NULL == d->txn) \ + { \ + send_rc(d->port, d->port_owner, ERROR_NO_TXN); \ + RETURN_INT(0, outbuf); \ + }} #ifdef DEBUG # define DBG printf @@ -554,13 +560,7 @@ static int bdberl_drv_control(ErlDrvData handle, unsigned int cmd, case CMD_TXN_ABORT: { FAIL_IF_ASYNC_PENDING(d, outbuf); - - // If we don't already have a txn open, fail - if (d->txn == 0) - { - send_rc(d->port, d->port_owner, ERROR_NO_TXN); - RETURN_INT(0, outbuf); - } + FAIL_IF_NO_TXN(d, outbuf); // Setup async command and schedule it on the txns threadpool d->async_op = cmd; diff --git a/include/bdberl.hrl b/include/bdberl.hrl index e3f9ff8..4836c56 100644 --- a/include/bdberl.hrl +++ b/include/bdberl.hrl @@ -37,9 +37,9 @@ -define(CMD_TXN_STAT, 29). -define(CMD_TXN_STAT_PRINT, 30). --define(DB_TYPE_UNKNOWN, 0). -define(DB_TYPE_BTREE, 1). -define(DB_TYPE_HASH, 2). +-define(DB_TYPE_UNKNOWN, 5). -define(SYSP_CACHESIZE_GET, 1). -define(SYSP_TXN_TIMEOUT_GET, 2).