class BDB::Env
Public Class Methods
allocate()
click to toggle source
static VALUE bdb_env_s_alloc(VALUE obj) { VALUE res; bdb_ENV *envst; res = Data_Make_Struct(obj, bdb_ENV, bdb_env_mark, bdb_env_free, envst); envst->options |= BDB_ENV_NOT_OPEN; return res; }
create(*args)
click to toggle source
static VALUE bdb_env_s_new(int argc, VALUE *argv, VALUE obj) { bdb_ENV *envst; VALUE res; int flags = 0; #ifdef HAVE_RB_DEFINE_ALLOC_FUNC res = rb_obj_alloc(obj); #else res = rb_funcall2(obj, rb_intern("allocate"), 0, 0); #endif Data_Get_Struct(res, bdb_ENV, envst); #if ! HAVE_DB_ENV_CREATE envst->envp = ALLOC(DB_ENV); MEMZERO(envst->envp, DB_ENV, 1); envst->envp->db_errpfx = "BDB::"; envst->envp->db_errcall = bdb_env_errcall; #else if (argc && TYPE(argv[argc - 1]) == T_HASH) { rb_iterate(rb_each, argv[argc - 1], bdb_env_s_i_options, (VALUE)&flags); } bdb_test_error(db_env_create(&(envst->envp), flags)); envst->envp->set_errpfx(envst->envp, "BDB::"); envst->envp->set_errcall(envst->envp, bdb_env_errcall); #if HAVE_ST_DB_ENV_SET_ALLOC bdb_test_error(envst->envp->set_alloc(envst->envp, malloc, realloc, free)); #endif #if HAVE_ST_DB_ENV_SET_ENV_NOTIFY if (argc && TYPE(argv[argc - 1]) == T_HASH) { VALUE value = Qnil; rb_iterate(rb_each, argv[argc - 1], bdb_env_s_j_options, (VALUE)&value); if (!NIL_P(value)) { if (!rb_respond_to(value, bdb_id_call)) { rb_raise(bdb_eFatal, "arg must respond to #call"); } envst->event_notify = value; envst->envp->set_event_notify(envst->envp, bdb_env_event_notify); } } #endif #endif rb_obj_call_init(res, argc, argv); return res; }
new(p1, p2 = v2, p3 = v3)
click to toggle source
VALUE bdb_env_init(int argc, VALUE *argv, VALUE obj) { DB_ENV *envp; bdb_ENV *envst; VALUE a, c, d; char *db_home, **db_config; int ret, mode, flags; VALUE st_config; VALUE envid; envid = 0; st_config = 0; db_config = 0; mode = flags = 0; if (!RDATA(obj)->dmark) { RDATA(obj)->dmark = (RUBY_DATA_FUNC)bdb_env_mark; } Data_Get_Struct(obj, bdb_ENV, envst); #if HAVE_ST_DB_ENV_SET_ERRCALL envst->envp->set_errcall(envst->envp, bdb_env_errcall); #endif envp = envst->envp; #if HAVE_ST_DB_ENV_SET_ENCRYPT if (rb_const_defined(CLASS_OF(obj), rb_intern("BDB_ENCRYPT"))) { char *passwd; int flags = DB_ENCRYPT_AES; VALUE value = rb_const_get(CLASS_OF(obj), rb_intern("BDB_ENCRYPT")); if (TYPE(value) == T_ARRAY) { if (RARRAY_LEN(value) != 2) { rb_raise(bdb_eFatal, "Expected an Array with 2 values"); } passwd = StringValuePtr(RARRAY_PTR(value)[0]); flags = NUM2INT(RARRAY_PTR(value)[1]); } else { passwd = StringValuePtr(value); } bdb_test_error(envp->set_encrypt(envp, passwd, flags)); envst->options |= BDB_ENV_ENCRYPT; } #endif if (argc && TYPE(argv[argc - 1]) == T_HASH) { int i; VALUE db_stobj; struct db_stoptions *db_st; st_config = rb_ary_new(); db_stobj = Data_Make_Struct(rb_cObject, struct db_stoptions, 0, free, db_st); db_st->env = envst; db_st->config = st_config; bdb_env_each_options(argv[argc - 1], db_stobj); if (RARRAY_LEN(st_config) > 0) { db_config = ALLOCA_N(char *, RARRAY_LEN(st_config) + 1); for (i = 0; i < RARRAY_LEN(st_config); i++) { db_config[i] = StringValuePtr(RARRAY_PTR(st_config)[i]); } db_config[RARRAY_LEN(st_config)] = 0; } argc--; } rb_scan_args(argc, argv, "12", &a, &c, &d); SafeStringValue(a); db_home = StringValuePtr(a); switch (argc) { case 3: mode = NUM2INT(d); case 2: flags = NUM2INT(c); break; } if (flags & DB_CREATE) { rb_secure(4); } if (flags & DB_USE_ENVIRON) { rb_secure(1); } #ifndef BDB_NO_THREAD_COMPILE if (!(envst->options & BDB_NO_THREAD)) { bdb_set_func(envst); flags |= DB_THREAD; } #endif #if HAVE_DB_APPINIT if ((ret = db_appinit(db_home, db_config, envp, flags)) != 0) { if (envst->envp) { free(envst->envp); } envst->envp = NULL; if (bdb_errcall) { bdb_errcall = 0; rb_raise(bdb_eFatal, "%s -- %s", StringValuePtr(bdb_errstr), db_strerror(ret)); } else rb_raise(bdb_eFatal, "%s", db_strerror(ret)); } #else #if HAVE_ST_DB_ENV_SET_EVENT_NOTIFY if (envst->event_notify == 0 && rb_respond_to(obj, id_event_notify) == Qtrue) { envp->set_event_notify(envp, bdb_env_event_notify); } #endif #if HAVE_ST_DB_ENV_SET_REP_TRANSPORT || HAVE_ST_DB_ENV_REP_SET_TRANSPORT if (envst->rep_transport == 0 && rb_respond_to(obj, rb_intern("bdb_rep_transport")) == Qtrue) { if (!rb_const_defined(CLASS_OF(obj), rb_intern("ENVID"))) { rb_raise(bdb_eFatal, "ENVID must be defined to use rep_transport"); } envid = rb_const_get(CLASS_OF(obj), rb_intern("ENVID")); #if HAVE_ST_DB_ENV_REP_SET_TRANSPORT bdb_test_error(envp->rep_set_transport(envp, NUM2INT(envid), bdb_env_rep_transport)); #else bdb_test_error(envp->set_rep_transport(envp, NUM2INT(envid), bdb_env_rep_transport)); #endif envst->options |= BDB_REP_TRANSPORT; } #endif #if HAVE_ST_DB_ENV_SET_FEEDBACK if (envst->feedback == 0 && rb_respond_to(obj, id_feedback) == Qtrue) { envp->set_feedback(envp, bdb_env_feedback); envst->options |= BDB_FEEDBACK; } #endif #if HAVE_ST_DB_ENV_SET_APP_DISPATCH if (envst->app_dispatch == 0 && rb_respond_to(obj, id_app_dispatch) == Qtrue) { envp->set_app_dispatch(envp, bdb_env_app_dispatch); envst->options |= BDB_APP_DISPATCH; } #endif #if HAVE_ST_DB_ENV_SET_MSGCALL if (envst->msgcall == 0 && rb_respond_to(obj, id_msgcall) == Qtrue) { envp->set_msgcall(envp, bdb_env_msgcall); } #endif #if HAVE_ST_DB_ENV_SET_THREAD_ID if (envst->thread_id == 0 && rb_respond_to(obj, id_thread_id) == Qtrue) { envp->set_thread_id(envp, bdb_env_thread_id); } #endif #if HAVE_ST_DB_ENV_SET_THREAD_ID_STRING if (envst->thread_id_string == 0 && rb_respond_to(obj, id_thread_id_string) == Qtrue) { envp->set_thread_id_string(envp, bdb_env_thread_id_string); } #endif #if HAVE_ST_DB_ENV_SET_ISALIVE if (envst->isalive == 0 && rb_respond_to(obj, id_isalive) == Qtrue) { envp->set_isalive(envp, bdb_env_isalive); } #endif #if HAVE_ENV_OPEN_DB_CONFIG if ((ret = envp->open(envp, db_home, db_config, flags, mode)) != 0) #else if ((ret = envp->open(envp, db_home, flags, mode)) != 0) #endif { envp->close(envp, 0); envst->envp = NULL; if (bdb_errcall) { bdb_errcall = 0; rb_raise(bdb_eFatal, "%s -- %s", StringValuePtr(bdb_errstr), db_strerror(ret)); } else rb_raise(bdb_eFatal, "%s", db_strerror(ret)); } #endif envst->options &= ~BDB_ENV_NOT_OPEN; if (flags & DB_INIT_LOCK) { envst->options |= BDB_INIT_LOCK; } #if HAVE_CONST_DB_AUTO_COMMIT if (flags & DB_INIT_TXN) { envst->options |= BDB_AUTO_COMMIT; } #endif envst->home = rb_tainted_str_new2(db_home); OBJ_FREEZE(envst->home); #if HAVE_CONST_DB_INIT_REP if (flags & DB_INIT_REP) { envst->options |= BDB_REP_TRANSPORT; } #endif if (envst->options & BDB_NEED_ENV_CURRENT) { rb_thread_local_aset(rb_thread_current(), bdb_id_current_env, obj); } return obj; }
open(*args)
click to toggle source
static VALUE bdb_env_s_open(int argc, VALUE *argv, VALUE obj) { VALUE res = rb_funcall2(obj, rb_intern("new"), argc, argv); if (rb_block_given_p()) { return rb_ensure(rb_yield, res, bdb_env_internal_close, res); } return res; }
remove(p1, p2 = v2)
click to toggle source
static VALUE bdb_env_s_remove(int argc, VALUE *argv, VALUE obj) { DB_ENV *envp; VALUE a, b; char *db_home; int flag = 0; rb_secure(2); if (rb_scan_args(argc, argv, "11", &a, &b) == 2) { flag = NUM2INT(b); } db_home = StringValuePtr(a); #if ! HAVE_DB_ENV_CREATE envp = ALLOCA_N(DB_ENV, 1); MEMZERO(envp, DB_ENV, 1); envp->db_errpfx = "BDB::"; envp->db_errcall = bdb_env_errcall; if (lock_unlink(db_home, flag, envp) == EBUSY) { rb_raise(bdb_eFatal, "The shared memory region was in use"); } if (log_unlink(db_home, flag, envp) == EBUSY) { rb_raise(bdb_eFatal, "The shared memory region was in use"); } if (memp_unlink(db_home, flag, envp) == EBUSY) { rb_raise(bdb_eFatal, "The shared memory region was in use"); } if (txn_unlink(db_home, flag, envp) == EBUSY) { rb_raise(bdb_eFatal, "The shared memory region was in use"); } #else bdb_test_error(db_env_create(&envp, 0)); envp->set_errpfx(envp, "BDB::"); envp->set_errcall(envp, bdb_env_errcall); #if HAVE_ENV_REMOVE_4 bdb_test_error(envp->remove(envp, db_home, NULL, flag)); #else bdb_test_error(envp->remove(envp, db_home, flag)); #endif #endif return Qtrue; }
unlink(p1, p2 = v2)
click to toggle source
static VALUE bdb_env_s_remove(int argc, VALUE *argv, VALUE obj) { DB_ENV *envp; VALUE a, b; char *db_home; int flag = 0; rb_secure(2); if (rb_scan_args(argc, argv, "11", &a, &b) == 2) { flag = NUM2INT(b); } db_home = StringValuePtr(a); #if ! HAVE_DB_ENV_CREATE envp = ALLOCA_N(DB_ENV, 1); MEMZERO(envp, DB_ENV, 1); envp->db_errpfx = "BDB::"; envp->db_errcall = bdb_env_errcall; if (lock_unlink(db_home, flag, envp) == EBUSY) { rb_raise(bdb_eFatal, "The shared memory region was in use"); } if (log_unlink(db_home, flag, envp) == EBUSY) { rb_raise(bdb_eFatal, "The shared memory region was in use"); } if (memp_unlink(db_home, flag, envp) == EBUSY) { rb_raise(bdb_eFatal, "The shared memory region was in use"); } if (txn_unlink(db_home, flag, envp) == EBUSY) { rb_raise(bdb_eFatal, "The shared memory region was in use"); } #else bdb_test_error(db_env_create(&envp, 0)); envp->set_errpfx(envp, "BDB::"); envp->set_errcall(envp, bdb_env_errcall); #if HAVE_ENV_REMOVE_4 bdb_test_error(envp->remove(envp, db_home, NULL, flag)); #else bdb_test_error(envp->remove(envp, db_home, flag)); #endif #endif return Qtrue; }
Public Instance Methods
close()
click to toggle source
static VALUE bdb_env_close(VALUE obj) { bdb_ENV *envst; if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4) { rb_raise(rb_eSecurityError, "Insecure: can't close the environnement"); } GetEnvDB(obj, envst); bdb_final(envst); RDATA(obj)->dfree = free; return Qnil; }
conf(*args)
click to toggle source
static VALUE bdb_env_conf(int argc, VALUE *argv, VALUE obj) { int i, state; VALUE res, val; struct optst opt; if (argc > 1) { rb_raise(rb_eArgError, "invalid number of arguments (%d for 1)", argc); } if (argc == 1) { return bdb_env_i_conf(obj, argv[0]); } res = rb_hash_new(); opt.obj = obj; for (i = 0; options[i] != NULL; i++) { opt.str = rb_str_new2(options[i]); val = rb_protect((VALUE (*)(ANYARGS))bdb_env_intern_conf, (VALUE)&opt, &state); if (state == 0) { rb_hash_aset(res, opt.str, val); } } return res; }
configuration(*args)
click to toggle source
static VALUE bdb_env_conf(int argc, VALUE *argv, VALUE obj) { int i, state; VALUE res, val; struct optst opt; if (argc > 1) { rb_raise(rb_eArgError, "invalid number of arguments (%d for 1)", argc); } if (argc == 1) { return bdb_env_i_conf(obj, argv[0]); } res = rb_hash_new(); opt.obj = obj; for (i = 0; options[i] != NULL; i++) { opt.str = rb_str_new2(options[i]); val = rb_protect((VALUE (*)(ANYARGS))bdb_env_intern_conf, (VALUE)&opt, &state); if (state == 0) { rb_hash_aset(res, opt.str, val); } } return res; }
elect(p1, p2 = v2)
click to toggle source
static VALUE bdb_env_rep_elect(int argc, VALUE *argv, VALUE env) { VALUE nb, pri, ti, nvo; bdb_ENV *envst; int envid = 0, nvotes = 0; GetEnvDB(env, envst); #if (HAVE_DB_ENV_REP_ELECT_5 && !HAVE_DB_ENV_REP_ELECT_PRIO) || HAVE_DB_ENV_REP_ELECT_7 pri = ti = 0; if (rb_scan_args(argc, argv, "11", &nb, &nvo) == 2) { nvotes = NUM2INT(nvo); } #else if (rb_scan_args(argc, argv, "31", &nb, &pri, &ti, &nvo) == 4) { nvotes = NUM2INT(nvo); } #endif #if HAVE_DB_ENV_REP_ELECT_4 bdb_test_error(envst->envp->rep_elect(envst->envp, NUM2INT(nb), nvotes, 0)); #elif HAVE_DB_ENV_REP_ELECT_5 #if HAVE_DB_ENV_REP_ELECT_PRIO bdb_test_error(envst->envp->rep_elect(envst->envp, NUM2INT(nb), NUM2INT(pri), NUM2INT(ti), &envid)); #else bdb_test_error(envst->envp->rep_elect(envst->envp, NUM2INT(nb), nvotes, &envid, 0)); #endif #elif HAVE_DB_ENV_REP_ELECT_7 bdb_test_error(envst->envp->rep_elect(envst->envp, NUM2INT(nb), nvotes, NUM2INT(pri), NUM2INT(ti), &envid, 0)); #endif return INT2NUM(envid); }
event_notify=(p1)
click to toggle source
static VALUE bdb_env_set_notify(VALUE obj, VALUE a) { bdb_ENV *envst; GetEnvDB(obj, envst); if (!NIL_P(a)) { if (!rb_respond_to(a, bdb_id_call)) { rb_raise(rb_eArgError, "object must respond to #call"); } envst->envp->set_event_notify(envst->envp, bdb_env_event_notify); } envst->event_notify = a; return a; }
failcheck(p1 = v1)
click to toggle source
static VALUE bdb_env_failcheck(int argc, VALUE *argv, VALUE obj) { bdb_ENV *envst; int flags = 0; VALUE a; GetEnvDB(obj, envst); if (rb_scan_args(argc, argv, "01", &a)) { flags = NUM2INT(a); } bdb_test_error(flags = envst->envp->failchk(envst->envp, flags)); return INT2NUM(flags); }
feedback=(p1)
click to toggle source
static VALUE bdb_env_feedback_set(VALUE obj, VALUE a) { bdb_ENV *envst; GetEnvDB(obj, envst); if (NIL_P(a)) { envst->feedback = a; } else { if (!rb_respond_to(a, bdb_id_call)) { rb_raise(bdb_eFatal, "arg must respond to #call"); } envst->feedback = a; if (!(envst->options & BDB_NEED_ENV_CURRENT)) { envst->options |= BDB_FEEDBACK; rb_thread_local_aset(rb_thread_current(), bdb_id_current_env, obj); } } return a; }
fileid_reset(p1, p2 = v2)
click to toggle source
static VALUE bdb_env_fileid_reset(int argc, VALUE *argv, VALUE obj) { char *file; int flags; VALUE a, b; bdb_ENV *envst; GetEnvDB(obj, envst); flags = 0; if (rb_scan_args(argc, argv, "11", &a, &b) == 2) { flags = NUM2INT(b); } file = StringValuePtr(a); bdb_test_error(envst->envp->fileid_reset(envst->envp, file, flags)); return obj; }
home()
click to toggle source
static VALUE bdb_env_home(VALUE obj) { bdb_ENV *envst; GetEnvDB(obj, envst); return envst->home; }
intermediate_dir_mode()
click to toggle source
static VALUE bdb_env_dir_mode(VALUE obj) { bdb_ENV *envst; const char *dir; GetEnvDB(obj, envst); if (envst->envp->get_intermediate_dir_mode(envst->envp, &dir)) { rb_raise(rb_eArgError, "invalid environment"); } return rb_tainted_str_new2(dir); }
isalive=(p1)
click to toggle source
static VALUE bdb_env_set_isalive(VALUE obj, VALUE a) { bdb_ENV *envst; GetEnvDB(obj, envst); if (!rb_respond_to(a, bdb_id_call)) { rb_raise(rb_eArgError, "object must respond to #call"); } if (!RTEST(envst->isalive)) { envst->envp->set_isalive(envst->envp, bdb_env_isalive); } envst->isalive = a; return obj; }
log_config(p1)
click to toggle source
static VALUE bdb_env_log_config(VALUE obj, VALUE a) { bdb_ENV *envst; int onoff; GetEnvDB(obj, envst); if (envst->envp->log_get_config(envst->envp, NUM2INT(a), &onoff)) { rb_raise(rb_eArgError, "invalid argument"); } if (onoff) { return Qtrue; } return Qfalse; }
log_set_config(p1, p2)
click to toggle source
static VALUE bdb_env_log_set_config(VALUE obj, VALUE a, VALUE b) { bdb_ENV *envst; int onoff; GetEnvDB(obj, envst); onoff = RTEST(b)?1:0; if (envst->envp->log_set_config(envst->envp, NUM2INT(a), onoff)) { rb_raise(rb_eArgError, "invalid argument"); } return obj; }
lsn_reset(p1, p2 = v2)
click to toggle source
static VALUE bdb_env_lsn_reset(int argc, VALUE *argv, VALUE obj) { char *file; int flags; VALUE a, b; bdb_ENV *envst; GetEnvDB(obj, envst); flags = 0; if (rb_scan_args(argc, argv, "11", &a, &b) == 2) { flags = NUM2INT(b); } file = StringValuePtr(a); bdb_test_error(envst->envp->lsn_reset(envst->envp, file, flags)); return obj; }
msgcall=(p1)
click to toggle source
static VALUE bdb_env_set_msgcall(VALUE obj, VALUE a) { bdb_ENV *envst; GetEnvDB(obj, envst); if (NIL_P(a)) { envst->msgcall = Qnil; envst->envp->set_msgcall(envst->envp, NULL); return obj; } if (!rb_respond_to(a, bdb_id_call)) { rb_raise(rb_eArgError, "object must respond to #call"); } if (!RTEST(envst->msgcall)) { envst->envp->set_msgcall(envst->envp, bdb_env_msgcall); } envst->msgcall = a; return obj; }
open_db(*args)
click to toggle source
VALUE bdb_env_open_db(int argc, VALUE *argv, VALUE obj) { VALUE cl; if (argc < 1) rb_raise(bdb_eFatal, "Invalid number of arguments"); cl = argv[0]; if (FIXNUM_P(cl)) { switch (NUM2INT(cl)) { case DB_BTREE: cl = bdb_cBtree; break; case DB_HASH: cl = bdb_cHash; break; case DB_RECNO: cl = bdb_cRecno; break; #if HAVE_CONST_DB_QUEUE case DB_QUEUE: cl = bdb_cQueue; break; #endif case DB_UNKNOWN: cl = bdb_cUnknown; break; default: rb_raise(bdb_eFatal, "Unknown database type"); } } else if (TYPE(cl) != T_CLASS) { cl = CLASS_OF(cl); } MEMCPY(argv, argv + 1, VALUE, argc - 1); if (argc > 1 && TYPE(argv[argc - 2]) == T_HASH) { argc--; } else { argv[argc - 1] = rb_hash_new(); } if (rb_obj_is_kind_of(obj, bdb_cEnv)) { rb_hash_aset(argv[argc - 1], rb_tainted_str_new2("env"), obj); } else { rb_hash_aset(argv[argc - 1], rb_tainted_str_new2("txn"), obj); } return rb_funcall2(cl, rb_intern("new"), argc, argv); }
process_message(p1, p2, p3)
click to toggle source
static VALUE bdb_env_rep_process_message(VALUE env, VALUE av, VALUE bv, VALUE ev) { bdb_ENV *envst; DBT control, rec; int ret, envid; VALUE result; #if HAVE_DB_ENV_REP_PROCESS_MESSAGE_5 VALUE lsn; struct dblsnst *lsnst; #endif GetEnvDB(env, envst); av = rb_str_to_str(av); bv = rb_str_to_str(bv); MEMZERO(&control, DBT, 1); MEMZERO(&rec, DBT, 1); control.size = RSTRING_LEN(av); control.data = StringValuePtr(av); rec.size = RSTRING_LEN(bv); rec.data = StringValuePtr(bv); envid = NUM2INT(ev); #if HAVE_DB_ENV_REP_PROCESS_MESSAGE_5 lsn = bdb_makelsn(env); Data_Get_Struct(lsn, struct dblsnst, lsnst); #if HAVE_DB_ENV_REP_PROCESS_MESSAGE_ENVID ret = envst->envp->rep_process_message(envst->envp, &control, &rec, envid, lsnst->lsn); #else ret = envst->envp->rep_process_message(envst->envp, &control, &rec, &envid, lsnst->lsn); #endif #else ret = envst->envp->rep_process_message(envst->envp, &control, &rec, &envid); #endif if (ret == DB_RUNRECOVERY) { bdb_test_error(ret); } result = rb_ary_new(); rb_ary_push(result, INT2NUM(ret)); rb_ary_push(result, rb_str_new(rec.data, rec.size)); rb_ary_push(result, INT2NUM(envid)); #if DB_RET_NOTPERM || DB_RET_ISPERM if (ret == DB_REP_NOTPERM || ret == DB_REP_ISPERM) { rb_ary_push(result, lsn); } #endif return result; }
rep_clockskew()
click to toggle source
static VALUE bdb_env_rep_get_clockskew(VALUE obj, VALUE a) { bdb_ENV *envst; u_int32_t fast, slow; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_get_clockskew(envst->envp, &fast, &slow)); return rb_assoc_new(INT2NUM(fast), INT2NUM(slow)); }
rep_elect(p1, p2 = v2)
click to toggle source
static VALUE bdb_env_rep_elect(int argc, VALUE *argv, VALUE env) { VALUE nb, pri, ti, nvo; bdb_ENV *envst; int envid = 0, nvotes = 0; GetEnvDB(env, envst); #if (HAVE_DB_ENV_REP_ELECT_5 && !HAVE_DB_ENV_REP_ELECT_PRIO) || HAVE_DB_ENV_REP_ELECT_7 pri = ti = 0; if (rb_scan_args(argc, argv, "11", &nb, &nvo) == 2) { nvotes = NUM2INT(nvo); } #else if (rb_scan_args(argc, argv, "31", &nb, &pri, &ti, &nvo) == 4) { nvotes = NUM2INT(nvo); } #endif #if HAVE_DB_ENV_REP_ELECT_4 bdb_test_error(envst->envp->rep_elect(envst->envp, NUM2INT(nb), nvotes, 0)); #elif HAVE_DB_ENV_REP_ELECT_5 #if HAVE_DB_ENV_REP_ELECT_PRIO bdb_test_error(envst->envp->rep_elect(envst->envp, NUM2INT(nb), NUM2INT(pri), NUM2INT(ti), &envid)); #else bdb_test_error(envst->envp->rep_elect(envst->envp, NUM2INT(nb), nvotes, &envid, 0)); #endif #elif HAVE_DB_ENV_REP_ELECT_7 bdb_test_error(envst->envp->rep_elect(envst->envp, NUM2INT(nb), nvotes, NUM2INT(pri), NUM2INT(ti), &envid, 0)); #endif return INT2NUM(envid); }
rep_get_clockskew()
click to toggle source
static VALUE bdb_env_rep_get_clockskew(VALUE obj, VALUE a) { bdb_ENV *envst; u_int32_t fast, slow; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_get_clockskew(envst->envp, &fast, &slow)); return rb_assoc_new(INT2NUM(fast), INT2NUM(slow)); }
rep_get_config(p1)
click to toggle source
static VALUE bdb_env_rep_get_config(VALUE obj, VALUE a) { bdb_ENV *envst; int offon; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_get_config(envst->envp, NUM2UINT(a), &offon)); if (offon) { return Qtrue; } return Qfalse; }
rep_get_limit()
click to toggle source
static VALUE bdb_env_rep_get_limit(VALUE obj) { bdb_ENV *envst; u_int32_t gbytes, bytes; VALUE res; GetEnvDB(obj, envst); #if HAVE_ST_DB_ENV_REP_SET_LIMIT bdb_test_error(envst->envp->rep_get_limit(envst->envp, &gbytes, &bytes)); #else bdb_test_error(envst->envp->get_rep_limit(envst->envp, &gbytes, &bytes)); #endif res = rb_ary_new2(2); rb_ary_push(res, INT2NUM(gbytes)); rb_ary_push(res, INT2NUM(bytes)); return res; }
rep_get_nsites()
click to toggle source
static VALUE bdb_env_rep_get_nsites(VALUE obj, VALUE a) { bdb_ENV *envst; int offon; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_get_nsites(envst->envp, &offon)); return INT2NUM(offon); }
rep_get_priority()
click to toggle source
static VALUE bdb_env_rep_get_priority(VALUE obj, VALUE a) { bdb_ENV *envst; int offon; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_get_priority(envst->envp, &offon)); return INT2NUM(offon); }
rep_get_request()
click to toggle source
static VALUE bdb_env_rep_get_request(VALUE obj, VALUE a) { bdb_ENV *envst; u_int32_t frmin, frmax; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_get_request(envst->envp, &frmin, &frmax)); return rb_assoc_new(INT2NUM(frmin), INT2NUM(frmax)); }
rep_get_timeout(p1)
click to toggle source
static VALUE bdb_env_rep_get_timeout(VALUE obj, VALUE a) { bdb_ENV *envst; u_int32_t offon; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_get_timeout(envst->envp, NUM2UINT(a), &offon)); return INT2NUM(offon); }
rep_limit()
click to toggle source
static VALUE bdb_env_rep_get_limit(VALUE obj) { bdb_ENV *envst; u_int32_t gbytes, bytes; VALUE res; GetEnvDB(obj, envst); #if HAVE_ST_DB_ENV_REP_SET_LIMIT bdb_test_error(envst->envp->rep_get_limit(envst->envp, &gbytes, &bytes)); #else bdb_test_error(envst->envp->get_rep_limit(envst->envp, &gbytes, &bytes)); #endif res = rb_ary_new2(2); rb_ary_push(res, INT2NUM(gbytes)); rb_ary_push(res, INT2NUM(bytes)); return res; }
rep_limit=(p1, p2 = v2)
click to toggle source
static VALUE bdb_env_rep_limit(int argc, VALUE *argv, VALUE obj) { bdb_ENV *envst; VALUE a, b; u_int32_t gbytes, bytes; GetEnvDB(obj, envst); gbytes = bytes = 0; switch(rb_scan_args(argc, argv, "11", &a, &b)) { case 1: if (TYPE(a) == T_ARRAY) { if (RARRAY_LEN(a) != 2) { rb_raise(bdb_eFatal, "Expected an Array with 2 values"); } gbytes = NUM2UINT(RARRAY_PTR(a)[0]); bytes = NUM2UINT(RARRAY_PTR(a)[1]); } else { bytes = NUM2UINT(RARRAY_PTR(a)[1]); } break; case 2: gbytes = NUM2UINT(a); bytes = NUM2UINT(b); break; } #if HAVE_ST_DB_ENV_REP_SET_LIMIT bdb_test_error(envst->envp->rep_set_limit(envst->envp, gbytes, bytes)); #else bdb_test_error(envst->envp->set_rep_limit(envst->envp, gbytes, bytes)); #endif return obj; }
rep_nsites()
click to toggle source
static VALUE bdb_env_rep_get_nsites(VALUE obj, VALUE a) { bdb_ENV *envst; int offon; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_get_nsites(envst->envp, &offon)); return INT2NUM(offon); }
rep_nsites=(p1)
click to toggle source
static VALUE bdb_env_rep_set_nsites(VALUE obj, VALUE a) { bdb_ENV *envst; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_set_nsites(envst->envp, NUM2UINT(a))); return a; }
rep_priority()
click to toggle source
static VALUE bdb_env_rep_get_priority(VALUE obj, VALUE a) { bdb_ENV *envst; int offon; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_get_priority(envst->envp, &offon)); return INT2NUM(offon); }
rep_priority=(p1)
click to toggle source
static VALUE bdb_env_rep_set_priority(VALUE obj, VALUE a) { bdb_ENV *envst; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_set_priority(envst->envp, NUM2UINT(a))); return a; }
rep_process_message(p1, p2, p3)
click to toggle source
static VALUE bdb_env_rep_process_message(VALUE env, VALUE av, VALUE bv, VALUE ev) { bdb_ENV *envst; DBT control, rec; int ret, envid; VALUE result; #if HAVE_DB_ENV_REP_PROCESS_MESSAGE_5 VALUE lsn; struct dblsnst *lsnst; #endif GetEnvDB(env, envst); av = rb_str_to_str(av); bv = rb_str_to_str(bv); MEMZERO(&control, DBT, 1); MEMZERO(&rec, DBT, 1); control.size = RSTRING_LEN(av); control.data = StringValuePtr(av); rec.size = RSTRING_LEN(bv); rec.data = StringValuePtr(bv); envid = NUM2INT(ev); #if HAVE_DB_ENV_REP_PROCESS_MESSAGE_5 lsn = bdb_makelsn(env); Data_Get_Struct(lsn, struct dblsnst, lsnst); #if HAVE_DB_ENV_REP_PROCESS_MESSAGE_ENVID ret = envst->envp->rep_process_message(envst->envp, &control, &rec, envid, lsnst->lsn); #else ret = envst->envp->rep_process_message(envst->envp, &control, &rec, &envid, lsnst->lsn); #endif #else ret = envst->envp->rep_process_message(envst->envp, &control, &rec, &envid); #endif if (ret == DB_RUNRECOVERY) { bdb_test_error(ret); } result = rb_ary_new(); rb_ary_push(result, INT2NUM(ret)); rb_ary_push(result, rb_str_new(rec.data, rec.size)); rb_ary_push(result, INT2NUM(envid)); #if DB_RET_NOTPERM || DB_RET_ISPERM if (ret == DB_REP_NOTPERM || ret == DB_REP_ISPERM) { rb_ary_push(result, lsn); } #endif return result; }
rep_request()
click to toggle source
static VALUE bdb_env_rep_get_request(VALUE obj, VALUE a) { bdb_ENV *envst; u_int32_t frmin, frmax; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_get_request(envst->envp, &frmin, &frmax)); return rb_assoc_new(INT2NUM(frmin), INT2NUM(frmax)); }
rep_set_clockskew(p1, p2)
click to toggle source
static VALUE bdb_env_rep_set_clockskew(VALUE obj, VALUE a, VALUE b) { bdb_ENV *envst; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_set_clockskew(envst->envp, NUM2UINT(a), NUM2INT(b))); return obj; }
rep_set_config(p1, p2)
click to toggle source
static VALUE bdb_env_rep_set_config(VALUE obj, VALUE a, VALUE b) { bdb_ENV *envst; int onoff = 0; if (b == Qtrue) { onoff = 1; } else if (b == Qfalse || b == Qnil) { onoff = 0; } else { onoff = NUM2INT(b); } GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_set_config(envst->envp, NUM2UINT(a), onoff)); return obj; }
rep_set_nsites(p1)
click to toggle source
static VALUE bdb_env_rep_set_nsites(VALUE obj, VALUE a) { bdb_ENV *envst; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_set_nsites(envst->envp, NUM2UINT(a))); return a; }
rep_set_priority(p1)
click to toggle source
static VALUE bdb_env_rep_set_priority(VALUE obj, VALUE a) { bdb_ENV *envst; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_set_priority(envst->envp, NUM2UINT(a))); return a; }
rep_set_request(p1, p2)
click to toggle source
static VALUE bdb_env_rep_set_request(VALUE obj, VALUE a, VALUE b) { bdb_ENV *envst; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_set_request(envst->envp, NUM2UINT(a), NUM2INT(b))); return obj; }
rep_set_timeout(p1, p2)
click to toggle source
static VALUE bdb_env_rep_set_timeout(VALUE obj, VALUE a, VALUE b) { bdb_ENV *envst; GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_set_timeout(envst->envp, NUM2UINT(a), NUM2INT(b))); return obj; }
rep_set_transport(p1, p2)
click to toggle source
static VALUE bdb_env_rep_set_transport(VALUE obj, VALUE a, VALUE b) { bdb_ENV *envst; GetEnvDB(obj, envst); if (!FIXNUM_P(a)) { rb_raise(bdb_eFatal, "expected a Fixnum for the 1st arg of set_rep_transport"); } if (!rb_respond_to(b, bdb_id_call)) { rb_raise(bdb_eFatal, "2nd arg must respond to #call"); } envst->rep_transport = b; #if HAVE_ST_DB_ENV_REP_SET_TRANSPORT bdb_test_error(envst->envp->rep_set_transport(envst->envp, NUM2INT(a), bdb_env_rep_transport)); #else bdb_test_error(envst->envp->set_rep_transport(envst->envp, NUM2INT(a), bdb_env_rep_transport)); #endif return obj; }
rep_start(p1, p2)
click to toggle source
static VALUE bdb_env_rep_start(VALUE env, VALUE ident, VALUE flags) { bdb_ENV *envst; DBT cdata; GetEnvDB(env, envst); if (!NIL_P(ident)) { ident = rb_str_to_str(ident); MEMZERO(&cdata, DBT, 1); cdata.size = RSTRING_LEN(ident); cdata.data = StringValuePtr(ident); } bdb_test_error(envst->envp->rep_start(envst->envp, NIL_P(ident)?NULL:&cdata, NUM2INT(flags))); return Qnil; }
rep_stat()
click to toggle source
static VALUE bdb_env_rep_stat(int argc, VALUE *argv, VALUE obj) { bdb_ENV *envst; VALUE a, lsn; int flags; struct dblsnst *lsnst; DB_REP_STAT *bs; flags = 0; if (rb_scan_args(argc, argv, "01", &a) == 1) { flags = NUM2INT(a); } GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_stat(envst->envp, &bs, flags)); a = rb_hash_new(); #if HAVE_ST_DB_REP_STAT_ST_BULK_FILLS rb_hash_aset(a, rb_tainted_str_new2("st_bulk_fills"), INT2NUM(bs->st_bulk_fills)); #endif #if HAVE_ST_DB_REP_STAT_ST_BULK_OVERFLOWS rb_hash_aset(a, rb_tainted_str_new2("st_bulk_overflows"), INT2NUM(bs->st_bulk_overflows)); #endif #if HAVE_ST_DB_REP_STAT_ST_BULK_RECORDS rb_hash_aset(a, rb_tainted_str_new2("st_bulk_records"), INT2NUM(bs->st_bulk_records)); #endif #if HAVE_ST_DB_REP_STAT_ST_BULK_TRANSFERS rb_hash_aset(a, rb_tainted_str_new2("st_bulk_transfers"), INT2NUM(bs->st_bulk_transfers)); #endif #if HAVE_ST_DB_REP_STAT_ST_CLIENT_REREQUESTS rb_hash_aset(a, rb_tainted_str_new2("st_client_rerequests"), INT2NUM(bs->st_client_rerequests)); #endif #if HAVE_ST_DB_REP_STAT_ST_CLIENT_SVC_MISS rb_hash_aset(a, rb_tainted_str_new2("st_client_svc_miss"), INT2NUM(bs->st_client_svc_miss)); #endif #if HAVE_ST_DB_REP_STAT_ST_CLIENT_SVC_REQ rb_hash_aset(a, rb_tainted_str_new2("st_client_svc_req"), INT2NUM(bs->st_client_svc_req)); #endif rb_hash_aset(a, rb_tainted_str_new2("st_dupmasters"), INT2NUM(bs->st_dupmasters)); #if HAVE_ST_DB_REP_STAT_ST_EGEN rb_hash_aset(a, rb_tainted_str_new2("st_egen"), INT2NUM(bs->st_egen)); #endif rb_hash_aset(a, rb_tainted_str_new2("st_election_cur_winner"), INT2NUM(bs->st_election_cur_winner)); rb_hash_aset(a, rb_tainted_str_new2("st_election_gen"), INT2NUM(bs->st_election_gen)); lsn = bdb_makelsn(obj); Data_Get_Struct(lsn, struct dblsnst, lsnst); MEMCPY(lsnst->lsn, &bs->st_election_lsn, DB_LSN, 1); rb_hash_aset(a, rb_tainted_str_new2("st_election_lsn"), lsn); rb_hash_aset(a, rb_tainted_str_new2("st_election_nsites"), INT2NUM(bs->st_election_nsites)); #if HAVE_ST_DB_REP_STAT_ST_ELECTION_NVOTES rb_hash_aset(a, rb_tainted_str_new2("st_election_nvotes"), INT2NUM(bs->st_election_nvotes)); #endif rb_hash_aset(a, rb_tainted_str_new2("st_election_priority"), INT2NUM(bs->st_election_priority)); #if HAVE_ST_DB_REP_STAT_ST_ELECTION_SEC rb_hash_aset(a, rb_tainted_str_new2("st_election_sec"), INT2NUM(bs->st_election_sec)); #endif rb_hash_aset(a, rb_tainted_str_new2("st_election_status"), INT2NUM(bs->st_election_status)); rb_hash_aset(a, rb_tainted_str_new2("st_election_tiebreaker"), INT2NUM(bs->st_election_tiebreaker)); #if HAVE_ST_DB_REP_STAT_ST_ELECTION_USEC rb_hash_aset(a, rb_tainted_str_new2("st_election_usec"), INT2NUM(bs->st_election_usec)); #endif rb_hash_aset(a, rb_tainted_str_new2("st_election_votes"), INT2NUM(bs->st_election_votes)); rb_hash_aset(a, rb_tainted_str_new2("st_elections"), INT2NUM(bs->st_elections)); rb_hash_aset(a, rb_tainted_str_new2("st_elections_won"), INT2NUM(bs->st_elections_won)); rb_hash_aset(a, rb_tainted_str_new2("st_env_id"), INT2NUM(bs->st_env_id)); rb_hash_aset(a, rb_tainted_str_new2("st_env_priority"), INT2NUM(bs->st_env_priority)); rb_hash_aset(a, rb_tainted_str_new2("st_gen"), INT2NUM(bs->st_gen)); rb_hash_aset(a, rb_tainted_str_new2("st_log_duplicated"), INT2NUM(bs->st_log_duplicated)); rb_hash_aset(a, rb_tainted_str_new2("st_log_queued"), INT2NUM(bs->st_log_queued)); rb_hash_aset(a, rb_tainted_str_new2("st_log_queued_max"), INT2NUM(bs->st_log_queued_max)); rb_hash_aset(a, rb_tainted_str_new2("st_log_queued_total"), INT2NUM(bs->st_log_queued_total)); rb_hash_aset(a, rb_tainted_str_new2("st_log_records"), INT2NUM(bs->st_log_records)); rb_hash_aset(a, rb_tainted_str_new2("st_log_requested"), INT2NUM(bs->st_log_requested)); rb_hash_aset(a, rb_tainted_str_new2("st_master"), INT2NUM(bs->st_master)); rb_hash_aset(a, rb_tainted_str_new2("st_master_changes"), INT2NUM(bs->st_master_changes)); rb_hash_aset(a, rb_tainted_str_new2("st_msgs_badgen"), INT2NUM(bs->st_msgs_badgen)); rb_hash_aset(a, rb_tainted_str_new2("st_msgs_processed"), INT2NUM(bs->st_msgs_processed)); rb_hash_aset(a, rb_tainted_str_new2("st_msgs_recover"), INT2NUM(bs->st_msgs_recover)); rb_hash_aset(a, rb_tainted_str_new2("st_msgs_send_failures"), INT2NUM(bs->st_msgs_send_failures)); rb_hash_aset(a, rb_tainted_str_new2("st_msgs_sent"), INT2NUM(bs->st_msgs_sent)); rb_hash_aset(a, rb_tainted_str_new2("st_newsites"), INT2NUM(bs->st_newsites)); lsn = bdb_makelsn(obj); Data_Get_Struct(lsn, struct dblsnst, lsnst); MEMCPY(lsnst->lsn, &bs->st_next_lsn, DB_LSN, 1); rb_hash_aset(a, rb_tainted_str_new2("st_next_lsn"), lsn); #if HAVE_ST_DB_REP_STAT_ST_NEXT_PG rb_hash_aset(a, rb_tainted_str_new2("st_next_pg"), INT2NUM(bs->st_next_pg)); #endif rb_hash_aset(a, rb_tainted_str_new2("st_nsites"), INT2NUM(bs->st_nsites)); rb_hash_aset(a, rb_tainted_str_new2("st_nthrottles"), INT2NUM(bs->st_nthrottles)); rb_hash_aset(a, rb_tainted_str_new2("st_outdated"), INT2NUM(bs->st_outdated)); #if HAVE_ST_DB_REP_STAT_ST_PG_DUPLICATED rb_hash_aset(a, rb_tainted_str_new2("st_pg_duplicated"), INT2NUM(bs->st_pg_duplicated)); #endif #if HAVE_ST_DB_REP_STAT_ST_PG_RECORDS rb_hash_aset(a, rb_tainted_str_new2("st_pg_records"), INT2NUM(bs->st_pg_records)); #endif #if HAVE_ST_DB_REP_STAT_ST_PG_REQUESTED rb_hash_aset(a, rb_tainted_str_new2("st_pg_requested"), INT2NUM(bs->st_pg_requested)); #endif #if HAVE_ST_DB_REP_STAT_ST_STARTUP_COMPLETE rb_hash_aset(a, rb_tainted_str_new2("st_startup_complete"), INT2NUM(bs->st_startup_complete)); #endif rb_hash_aset(a, rb_tainted_str_new2("st_status"), INT2NUM(bs->st_status)); rb_hash_aset(a, rb_tainted_str_new2("st_txns_applied"), INT2NUM(bs->st_txns_applied)); lsn = bdb_makelsn(obj); Data_Get_Struct(lsn, struct dblsnst, lsnst); MEMCPY(lsnst->lsn, &bs->st_waiting_lsn, DB_LSN, 1); rb_hash_aset(a, rb_tainted_str_new2("st_waiting_lsn"), lsn); #if HAVE_ST_DB_REP_STAT_ST_WAITING_PG rb_hash_aset(a, rb_tainted_str_new2("st_waiting_pg"), INT2NUM(bs->st_waiting_pg)); #endif free(bs); return a; }
rep_sync(p1 = v1)
click to toggle source
static VALUE bdb_env_rep_sync(int argc, VALUE *argv, VALUE obj) { bdb_ENV *envst; VALUE a; int flags; flags = 0; if (rb_scan_args(argc, argv, "01", &a) == 1) { flags = NUM2INT(a); } GetEnvDB(obj, envst); bdb_test_error(envst->envp->rep_sync(envst->envp, flags)); return obj; }
repmgr_ack_policy()
click to toggle source
static VALUE bdb_env_repmgr_get_ack_policy(VALUE obj) { bdb_ENV *envst; int policy; GetEnvDB(obj, envst); bdb_test_error(envst->envp->repmgr_get_ack_policy(envst->envp, &policy)); return INT2NUM(policy); }
repmgr_ack_policy=(p1)
click to toggle source
static VALUE bdb_env_repmgr_set_ack_policy(VALUE obj, VALUE a) { bdb_ENV *envst; GetEnvDB(obj, envst); bdb_test_error(envst->envp->repmgr_set_ack_policy(envst->envp, NUM2UINT(a))); return a; }
repmgr_add_remote_site(p1, p2, p3 = v3)
click to toggle source
static VALUE bdb_env_repmgr_add_remote(int argc, VALUE *argv, VALUE obj) { bdb_ENV *envst; VALUE a, b, c; int eid, flags; flags = 0; if (rb_scan_args(argc, argv, "21", &a, &b, &c) == 3) { flags = NUM2INT(c); } GetEnvDB(obj, envst); bdb_test_error(envst->envp->repmgr_add_remote_site(envst->envp, StringValuePtr(a), NUM2UINT(b), &eid, flags)); return INT2NUM(eid); }
repmgr_get_ack_policy()
click to toggle source
static VALUE bdb_env_repmgr_get_ack_policy(VALUE obj) { bdb_ENV *envst; int policy; GetEnvDB(obj, envst); bdb_test_error(envst->envp->repmgr_get_ack_policy(envst->envp, &policy)); return INT2NUM(policy); }
repmgr_set_ack_policy(p1)
click to toggle source
static VALUE bdb_env_repmgr_set_ack_policy(VALUE obj, VALUE a) { bdb_ENV *envst; GetEnvDB(obj, envst); bdb_test_error(envst->envp->repmgr_set_ack_policy(envst->envp, NUM2UINT(a))); return a; }
repmgr_set_local_site(p1, p2, p3 = v3)
click to toggle source
static VALUE bdb_env_repmgr_set_local_site(int argc, VALUE *argv, VALUE obj) { bdb_ENV *envst; VALUE a, b, c; int flags; flags = 0; if (rb_scan_args(argc, argv, "21", &a, &b, &c) == 3) { flags = NUM2INT(c); } GetEnvDB(obj, envst); bdb_test_error(envst->envp->repmgr_set_local_site(envst->envp, StringValuePtr(a), NUM2UINT(b), flags)); return obj; }
repmgr_site_list()
click to toggle source
static VALUE bdb_env_repmgr_site_list(VALUE obj) { bdb_ENV *envst; VALUE res, tmp; u_int count, i; DB_REPMGR_SITE *list; GetEnvDB(obj, envst); bdb_test_error(envst->envp->repmgr_site_list(envst->envp, &count, &list)); res = rb_ary_new(); for (i = 0; i < count; i++) { tmp = rb_hash_new(); rb_hash_aset(tmp, rb_tainted_str_new2("eid"), INT2NUM(list[i].eid)); rb_hash_aset(tmp, rb_tainted_str_new2("host"), rb_tainted_str_new2(list[i].host)); rb_hash_aset(tmp, rb_tainted_str_new2("port"), INT2NUM(list[i].port)); rb_hash_aset(tmp, rb_tainted_str_new2("status"), INT2NUM(list[i].status)); rb_ary_push(res, tmp); } free(list); return res; }
repmgr_start(p1, p2)
click to toggle source
static VALUE bdb_env_repmgr_start(VALUE obj, VALUE a, VALUE b) { bdb_ENV *envst; GetEnvDB(obj, envst); bdb_test_error(envst->envp->repmgr_start(envst->envp, NUM2INT(a), NUM2INT(b))); return obj; }
set_flags(p1, p2 = v2)
click to toggle source
static VALUE bdb_env_set_flags(int argc, VALUE *argv, VALUE obj) { #if HAVE_ST_DB_ENV_SET_FLAGS bdb_ENV *envst; VALUE opt, flag; int state = 1; GetEnvDB(obj, envst); if (rb_scan_args(argc, argv, "11", &flag, &opt)) { switch (TYPE(opt)) { case T_TRUE: state = 1; break; case T_FALSE: state = 0; break; case T_FIXNUM: state = NUM2INT(opt); break; default: rb_raise(bdb_eFatal, "invalid value for onoff"); } } bdb_test_error(envst->envp->set_flags(envst->envp, NUM2INT(flag), state)); #endif return Qnil; }
set_log_config(p1, p2)
click to toggle source
static VALUE bdb_env_log_set_config(VALUE obj, VALUE a, VALUE b) { bdb_ENV *envst; int onoff; GetEnvDB(obj, envst); onoff = RTEST(b)?1:0; if (envst->envp->log_set_config(envst->envp, NUM2INT(a), onoff)) { rb_raise(rb_eArgError, "invalid argument"); } return obj; }
thread_id=(p1)
click to toggle source
static VALUE bdb_env_set_thread_id(VALUE obj, VALUE a) { bdb_ENV *envst; GetEnvDB(obj, envst); if (!rb_respond_to(a, bdb_id_call)) { rb_raise(rb_eArgError, "object must respond to #call"); } if (!RTEST(envst->thread_id)) { envst->envp->set_thread_id(envst->envp, bdb_env_thread_id); } envst->thread_id = a; return obj; }
thread_id_string=(p1)
click to toggle source
static VALUE bdb_env_set_thread_id_string(VALUE obj, VALUE a) { bdb_ENV *envst; GetEnvDB(obj, envst); if (!rb_respond_to(a, bdb_id_call)) { rb_raise(rb_eArgError, "object must respond to #call"); } if (!RTEST(envst->thread_id_string)) { envst->envp->set_thread_id_string(envst->envp, bdb_env_thread_id_string); } envst->thread_id_string = a; return obj; }