diff options
Diffstat (limited to 'ext/tdb/tdb.c')
-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; |