From 2abc1addd4d9edac5d9415d583de1f9571fdfd0e Mon Sep 17 00:00:00 2001 From: Justin Balthrop Date: Mon, 21 Sep 2009 11:32:38 -0700 Subject: [PATCH] add mutex_set_max --- bdb.gemspec | 2 +- ext/bdb.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/bdb.gemspec b/bdb.gemspec index 8f86a78..73f28d2 100644 --- a/bdb.gemspec +++ b/bdb.gemspec @@ -2,7 +2,7 @@ BDB_SPEC = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.required_ruby_version = '>=1.8.4' s.name = "bdb" - s.version = "0.0.8" + s.version = "0.0.9" s.authors = ["Matt Bauer", "Dan Janowski"] s.email = "bauer@pedalbrain.com" s.summary = "A Ruby interface to BerkeleyDB" diff --git a/ext/bdb.c b/ext/bdb.c index 02865f6..b7c3c8e 100644 --- a/ext/bdb.c +++ b/ext/bdb.c @@ -2315,6 +2315,54 @@ VALUE env_get_tx_max(VALUE obj) return INT2FIX(max); } +/* + * call-seq: + * env.mutex_set_max(max) -> max + * + * Set the maximum number of mutexes with the environment + */ +VALUE env_mutex_set_max(VALUE obj, VALUE vmax) +{ + t_envh *eh; + u_int32_t max; + int rv; + + max=FIX2UINT(vmax); + + Data_Get_Struct(obj,t_envh,eh); + if (!eh->env) + raise(0, "env is closed"); + rv=eh->env->mutex_set_max(eh->env,max); + if ( rv != 0 ) { + raise_error(rv, "env_mutex_set_max: %s",db_strerror(rv)); + } + + return vmax; +} + +/* + * call-seq + * env.mutex_get_max -> Fixnum + * + * Get current maximum number of mutexes. + */ +VALUE env_mutex_get_max(VALUE obj) +{ + t_envh *eh; + u_int32_t max; + int rv; + + Data_Get_Struct(obj,t_envh,eh); + if (!eh->env) + raise(0, "env is closed"); + rv=eh->env->mutex_get_max(eh->env,&max); + if ( rv != 0 ) { + raise_error(rv, "env_mutex_get_max: %s",db_strerror(rv)); + } + + return INT2FIX(max); +} + /* * call-seq: * env.set_shm_key(key) -> max @@ -2935,6 +2983,8 @@ void Init_bdb() { rb_define_method(cEnv,"set_timeout",env_set_timeout,2); rb_define_method(cEnv,"get_timeout",env_get_timeout,1); rb_define_method(cEnv,"set_tx_max",env_set_tx_max,1); + rb_define_method(cEnv,"mutex_get_max",env_mutex_get_max,0); + rb_define_method(cEnv,"mutex_set_max",env_mutex_set_max,1); rb_define_method(cEnv,"get_tx_max",env_get_tx_max,0); rb_define_method(cEnv,"report_stderr",env_report_stderr,0); rb_define_method(cEnv,"set_lk_detect",env_set_lk_detect,1);