diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-12-03 17:27:53 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-12-03 17:27:53 -0800 |
commit | c6c2f7782e2270ee4684d2405376a186aa806fcd (patch) | |
tree | 14efa83fc750b24fa2213dd64f6ddc9fd1b3b915 /ext | |
parent | 2a31a29a3398b645722b9ce77a2987948289706e (diff) | |
download | ruby-tdb-c6c2f7782e2270ee4684d2405376a186aa806fcd.tar.gz |
Thread-safety is useful sometimes and needless overhead otherwise. Default to whatever TDB upstream defaults to.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/tdb/tdb.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/tdb/tdb.c b/ext/tdb/tdb.c index a68c360..373da17 100644 --- a/ext/tdb/tdb.c +++ b/ext/tdb/tdb.c @@ -158,7 +158,7 @@ static VALUE nogvl_open(void *ptr) return (VALUE)tdb; } -static void set_args(struct open_args *o, VALUE opts) +static void set_args(VALUE self, struct open_args *o, VALUE opts) { VALUE tmp; @@ -203,6 +203,10 @@ static void set_args(struct open_args *o, VALUE opts) o->hash_fn = (tdb_hash_func)NUM2ULONG(num); } + + tmp = rb_hash_aref(opts, ID2SYM(rb_intern("threadsafe"))); + if (RTEST(tmp)) + rb_funcall(self, rb_intern("threadsafe!"), 0); } /* @@ -242,7 +246,7 @@ static VALUE init(int argc, VALUE *argv, VALUE self) if (tdb) rb_raise(rb_eRuntimeError, "TDB already initialized"); rb_scan_args(argc, argv, "11", &path, &opts); - set_args(&o, opts); + set_args(self, &o, opts); if (NIL_P(path)) o.tdb_flags |= TDB_INTERNAL; |