diff --git a/c_src/bdberl_drv.c b/c_src/bdberl_drv.c index 58b7098..1b30514 100644 --- a/c_src/bdberl_drv.c +++ b/c_src/bdberl_drv.c @@ -27,7 +27,7 @@ static int open_database(const char* name, DBTYPE type, unsigned int flags, Port static int close_database(int dbref, unsigned flags, PortData* data); static int delete_database(const char* name); -static void tune_system(int target, void* values, BinHelper* bh); +static void get_info(int target, void* values, BinHelper* bh); static void do_async_put(void* arg); static void do_async_get(void* arg); @@ -539,7 +539,7 @@ static int bdberl_drv_control(ErlDrvData handle, unsigned int cmd, RETURN_INT(ERROR_INVALID_DBREF, outbuf); } } - case CMD_TUNE: + case CMD_GETINFO: { // Inbuf is: << Target:32, Values/binary >> int target = UNPACK_INT(inbuf, 0); @@ -548,7 +548,7 @@ static int bdberl_drv_control(ErlDrvData handle, unsigned int cmd, // Execute the tuning -- the result to send back to the caller is wrapped // up in the provided binhelper BinHelper bh; - tune_system(target, values, &bh); + get_info(target, values, &bh); RETURN_BH(bh, outbuf); } case CMD_CURSOR_OPEN: @@ -851,9 +851,9 @@ static int delete_database(const char* name) } /** - * Given a target system parameter/action adjust/return the requested value + * Given a target system parameter, return the requested value */ -static void tune_system(int target, void* values, BinHelper* bh) +static void get_info(int target, void* values, BinHelper* bh) { switch(target) { @@ -870,14 +870,6 @@ static void tune_system(int target, void* values, BinHelper* bh) bin_helper_push_int32(bh, caches); break; } - case SYSP_TXN_TIMEOUT_SET: - { - unsigned int timeout = UNPACK_INT(values, 0); - int rc = G_DB_ENV->set_timeout(G_DB_ENV, timeout, DB_SET_TXN_TIMEOUT); - bin_helper_init(bh); - bin_helper_push_int32(bh, rc); - break; - } case SYSP_TXN_TIMEOUT_GET: { unsigned int timeout = 0; diff --git a/c_src/bdberl_drv.h b/c_src/bdberl_drv.h index 0c8eaa4..46611f1 100644 --- a/c_src/bdberl_drv.h +++ b/c_src/bdberl_drv.h @@ -36,7 +36,7 @@ static int bdberl_drv_control(ErlDrvData handle, unsigned int cmd, #define CMD_TXN_ABORT 5 #define CMD_GET 6 #define CMD_PUT 7 -#define CMD_TUNE 8 +#define CMD_GETINFO 8 #define CMD_CURSOR_OPEN 9 #define CMD_CURSOR_CURR 10 #define CMD_CURSOR_NEXT 11 @@ -77,12 +77,11 @@ static int bdberl_drv_control(ErlDrvData handle, unsigned int cmd, /** - * Tunable system parameters/actions + * System information ids */ #define SYSP_CACHESIZE_GET 1 -#define SYSP_TXN_TIMEOUT_SET 2 -#define SYSP_TXN_TIMEOUT_GET 3 -#define SYSP_DATA_DIR_GET 4 +#define SYSP_TXN_TIMEOUT_GET 2 +#define SYSP_DATA_DIR_GET 3 /** * Driver Entry diff --git a/include/bdberl.hrl b/include/bdberl.hrl index d444944..5c86a80 100644 --- a/include/bdberl.hrl +++ b/include/bdberl.hrl @@ -13,7 +13,7 @@ -define(CMD_TXN_ABORT, 5). -define(CMD_GET, 6). -define(CMD_PUT, 7). --define(CMD_TUNE, 8). +-define(CMD_GETINFO, 8). -define(CMD_CURSOR_OPEN, 9). -define(CMD_CURSOR_CURR, 10). -define(CMD_CURSOR_NEXT, 11). @@ -27,9 +27,8 @@ -define(DB_TYPE_HASH, 2). -define(SYSP_CACHESIZE_GET, 1). --define(SYSP_TXN_TIMEOUT_SET, 2). --define(SYSP_TXN_TIMEOUT_GET, 3). --define(SYSP_DATA_DIR_GET, 4). +-define(SYSP_TXN_TIMEOUT_GET, 2). +-define(SYSP_DATA_DIR_GET, 3). -define(STATUS_OK, 0). -define(STATUS_ERROR, 1). diff --git a/src/bdberl.erl b/src/bdberl.erl index e174031..56f502a 100644 --- a/src/bdberl.erl +++ b/src/bdberl.erl @@ -10,8 +10,9 @@ close/1, close/2, txn_begin/0, txn_begin/1, txn_commit/0, txn_commit/1, txn_abort/0, - get_cache_size/0, get_data_dirs/0, - get_txn_timeout/0, set_txn_timeout/1, + get_cache_size/0, + get_data_dirs/0, + get_txn_timeout/0, transaction/1, transaction/2, put/3, put/4, put_r/3, put_r/4, @@ -277,7 +278,7 @@ delete_database(Filename) -> get_data_dirs() -> %% Call into the BDB library and get a list of configured data directories Cmd = <>, - <> = erlang:port_control(get_port(), ?CMD_TUNE, Cmd), + <> = erlang:port_control(get_port(), ?CMD_GETINFO, Cmd), case decode_rc(Result) of ok -> Dirs = [binary_to_list(D) || D <- split_bin(0, Rest, <<>>, [])], @@ -295,7 +296,7 @@ get_data_dirs() -> get_cache_size() -> Cmd = <>, <> = - erlang:port_control(get_port(), ?CMD_TUNE, Cmd), + erlang:port_control(get_port(), ?CMD_GETINFO, Cmd), case Result of 0 -> {ok, Gbytes, Bytes, Ncaches}; @@ -305,7 +306,7 @@ get_cache_size() -> get_txn_timeout() -> Cmd = <>, - <> = erlang:port_control(get_port(), ?CMD_TUNE, Cmd), + <> = erlang:port_control(get_port(), ?CMD_GETINFO, Cmd), case Result of 0 -> {ok, Timeout}; @@ -313,17 +314,6 @@ get_txn_timeout() -> {error, Result} end. -set_txn_timeout(Timeout) -> - Cmd = <>, - <> = erlang:port_control(get_port(), ?CMD_TUNE, Cmd), - case Result of - 0 -> - ok; - _ -> - {error, Result} - end. - - %% ==================================================================== %% Internal functions diff --git a/test/bdberl_SUITE.erl b/test/bdberl_SUITE.erl index a3bb70f..c656b3e 100644 --- a/test/bdberl_SUITE.erl +++ b/test/bdberl_SUITE.erl @@ -24,7 +24,7 @@ all() -> transaction_error_should_return_error, update_should_save_value_if_successful, update_should_accept_args_for_fun, - port_should_tune_transaction_timeouts, + port_should_return_transaction_timeouts, cursor_should_iterate, cursor_should_fail_if_not_open, put_commit_should_end_txn, data_dir_should_be_priv_dir, @@ -157,11 +157,9 @@ update_should_accept_args_for_fun(Config) -> {ok, newvalue} = bdberl:update(Db, mykey, F, look_at_me). -port_should_tune_transaction_timeouts(_Config) -> +port_should_return_transaction_timeouts(_Config) -> %% Test transaction timeouts - {ok, 500000} = bdberl:get_txn_timeout(), - ok = bdberl:set_txn_timeout(250000), - {ok, 250000} = bdberl:get_txn_timeout(). + {ok, 500000} = bdberl:get_txn_timeout(). cursor_should_iterate(Config) -> Db = ?config(db, Config),