add support for DB_THREAD in preparation for replication
This commit is contained in:
parent
597fbb963c
commit
5667b6bfff
12
ext/bdb.c
12
ext/bdb.c
|
@ -616,20 +616,22 @@ VALUE db_get(VALUE obj, VALUE vtxn, VALUE vkey, VALUE vdata, VALUE vflags)
|
||||||
|
|
||||||
StringValue(vkey);
|
StringValue(vkey);
|
||||||
|
|
||||||
key.data = RSTRING_PTR(vkey);
|
key.data = RSTRING_PTR(vkey);
|
||||||
key.size = RSTRING_LEN(vkey);
|
key.size = RSTRING_LEN(vkey);
|
||||||
key.flags = LMEMFLAG;
|
key.flags = LMEMFLAG;
|
||||||
|
|
||||||
if ( ! NIL_P(vdata) ) {
|
if ( ! NIL_P(vdata) ) {
|
||||||
StringValue(vdata);
|
StringValue(vdata);
|
||||||
data.data = RSTRING_PTR(vdata);
|
data.data = RSTRING_PTR(vdata);
|
||||||
data.size = RSTRING_LEN(vdata);
|
data.size = RSTRING_LEN(vdata);
|
||||||
data.flags = LMEMFLAG;
|
|
||||||
}
|
}
|
||||||
|
data.flags = DB_DBT_MALLOC;
|
||||||
|
|
||||||
rv = dbh->db->get(dbh->db,txn?txn->txn:NULL,&key,&data,flags);
|
rv = dbh->db->get(dbh->db,txn?txn->txn:NULL,&key,&data,flags);
|
||||||
if ( rv == 0 ) {
|
if ( rv == 0 ) {
|
||||||
return rb_str_new(data.data,data.size);
|
str = rb_str_new(data.data,data.size);
|
||||||
|
if (data.data) free(data.data);
|
||||||
|
return str;
|
||||||
} else if (rv == DB_NOTFOUND) {
|
} else if (rv == DB_NOTFOUND) {
|
||||||
return Qnil;
|
return Qnil;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -61,7 +61,7 @@ class Bdb::Database < Bdb::Base
|
||||||
set = Bdb::ResultSet.new(opts, &block)
|
set = Bdb::ResultSet.new(opts, &block)
|
||||||
flags = opts[:modify] ? Bdb::DB_RMW : 0
|
flags = opts[:modify] ? Bdb::DB_RMW : 0
|
||||||
flags = 0 if environment.disable_transactions?
|
flags = 0 if environment.disable_transactions?
|
||||||
|
|
||||||
keys.each do |key|
|
keys.each do |key|
|
||||||
key = get_key(key, opts)
|
key = get_key(key, opts)
|
||||||
if key == :all
|
if key == :all
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
class Bdb::Environment
|
class Bdb::Environment
|
||||||
@@env = {}
|
@@env = {}
|
||||||
def self.new(path, database)
|
def self.new(path, database = nil)
|
||||||
|
path = File.expand_path(path)
|
||||||
@@env[path] ||= super(path)
|
@@env[path] ||= super(path)
|
||||||
@@env[path].databases << database
|
@@env[path].databases << database if database
|
||||||
@@env[path]
|
@@env[path]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ class Bdb::Environment
|
||||||
env_flags = Bdb::DB_CREATE | Bdb::DB_INIT_MPOOL
|
env_flags = Bdb::DB_CREATE | Bdb::DB_INIT_MPOOL
|
||||||
else
|
else
|
||||||
env_flags = Bdb::DB_CREATE | Bdb::DB_INIT_TXN | Bdb::DB_INIT_LOCK |
|
env_flags = Bdb::DB_CREATE | Bdb::DB_INIT_TXN | Bdb::DB_INIT_LOCK |
|
||||||
Bdb::DB_REGISTER | Bdb::DB_RECOVER | Bdb::DB_INIT_MPOOL
|
Bdb::DB_REGISTER | Bdb::DB_RECOVER | Bdb::DB_INIT_MPOOL | Bdb::DB_THREAD
|
||||||
end
|
end
|
||||||
|
|
||||||
@env.cachesize = config[:cache_size] if config[:cache_size]
|
@env.cachesize = config[:cache_size] if config[:cache_size]
|
||||||
|
|
Loading…
Reference in a new issue