📄 db_server_cxxproc.cpp
字号:
}extern "C" void__db_associate_proc( u_int dbpcl_id, u_int txnpcl_id, u_int sdbpcl_id, u_int32_t flags, __db_associate_reply *replyp){ Db *dbp, *sdbp; DbTxn *txnp; ct_entry *dbp_ctp, *sdbp_ctp, *txnp_ctp; int ret; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; ACTIVATE_CTP(sdbp_ctp, sdbpcl_id, CT_DB); sdbp = (Db *)sdbp_ctp->ct_anyp; if (txnpcl_id != 0) { ACTIVATE_CTP(txnp_ctp, txnpcl_id, CT_TXN); txnp = (DbTxn *)txnp_ctp->ct_anyp; } else txnp = NULL; /* * We do not support DB_CREATE for associate or the callbacks * implemented in the Java and JE RPC servers. Users can only * access secondary indices on a read-only basis, so whatever they * are looking for needs to be there already. */ if (LF_ISSET(DB_RPC2ND_MASK | DB_CREATE)) ret = EINVAL; else ret = dbp->associate(txnp, sdbp, NULL, flags); replyp->status = ret; return;}extern "C" void__db_get_bt_minkey_proc( u_int dbpcl_id, __db_get_bt_minkey_reply *replyp){ Db *dbp; ct_entry *dbp_ctp; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; replyp->status = dbp->get_bt_minkey(&replyp->minkey);}extern "C" void__db_set_bt_minkey_proc( u_int dbpcl_id, u_int32_t minkey, __db_set_bt_minkey_reply *replyp){ Db *dbp; ct_entry *dbp_ctp; int ret; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; ret = dbp->set_bt_minkey(minkey); replyp->status = ret; return;}extern "C" void__db_close_proc( u_int dbpcl_id, u_int32_t flags, __db_close_reply *replyp){ ct_entry *dbp_ctp; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); replyp->status = __db_close_int(dbpcl_id, flags); return;}extern "C" void__db_create_proc( u_int dbenvcl_id, u_int32_t flags, __db_create_reply *replyp){ Db *dbp; DbEnv *dbenv; ct_entry *dbenv_ctp, *dbp_ctp; ACTIVATE_CTP(dbenv_ctp, dbenvcl_id, CT_ENV); dbenv = (DbEnv *)dbenv_ctp->ct_anyp; dbp_ctp = new_ct_ent(&replyp->status); if (dbp_ctp == NULL) return ; /* * We actually require env's for databases. The client should * have caught it, but just in case. */ DB_ASSERT(NULL, dbenv != NULL); dbp = new Db(dbenv, flags); dbp_ctp->ct_dbp = dbp; dbp_ctp->ct_type = CT_DB; dbp_ctp->ct_parent = dbenv_ctp; dbp_ctp->ct_envparent = dbenv_ctp; replyp->dbcl_id = dbp_ctp->ct_id; replyp->status = 0; return;}extern "C" void__db_del_proc( u_int dbpcl_id, u_int txnpcl_id, u_int32_t keydlen, u_int32_t keydoff, u_int32_t keyulen, u_int32_t keyflags, void *keydata, u_int32_t keysize, u_int32_t flags, __db_del_reply *replyp){ Db *dbp; DbTxn *txnp; ct_entry *dbp_ctp, *txnp_ctp; int ret; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; if (txnpcl_id != 0) { ACTIVATE_CTP(txnp_ctp, txnpcl_id, CT_TXN); txnp = (DbTxn *)txnp_ctp->ct_anyp; } else txnp = NULL; /* Set up key */ Dbt key(keydata, keysize); key.set_dlen(keydlen); key.set_ulen(keyulen); key.set_doff(keydoff); key.set_flags(keyflags); ret = dbp->del(txnp, &key, flags); replyp->status = ret; return;}extern "C" void__db_get_encrypt_flags_proc( u_int dbpcl_id, __db_get_encrypt_flags_reply *replyp){ Db *dbp; ct_entry *dbp_ctp; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; replyp->status = dbp->get_encrypt_flags(&replyp->flags);}extern "C" void__db_set_encrypt_proc( u_int dbpcl_id, char *passwd, u_int32_t flags, __db_set_encrypt_reply *replyp){ Db *dbp; ct_entry *dbp_ctp; int ret; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; ret = dbp->set_encrypt(passwd, flags); replyp->status = ret; return;}extern "C" void__db_get_q_extentsize_proc( u_int dbpcl_id, __db_get_q_extentsize_reply *replyp){ Db *dbp; ct_entry *dbp_ctp; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; replyp->status = dbp->get_q_extentsize(&replyp->extentsize);}extern "C" void__db_set_q_extentsize_proc( u_int dbpcl_id, u_int32_t extentsize, __db_set_q_extentsize_reply *replyp){ Db *dbp; ct_entry *dbp_ctp; int ret; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; ret = dbp->set_q_extentsize(extentsize); replyp->status = ret; return;}extern "C" void__db_get_flags_proc( u_int dbpcl_id, __db_get_flags_reply *replyp){ Db *dbp; ct_entry *dbp_ctp; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; replyp->status = dbp->get_flags(&replyp->flags);}extern "C" void__db_set_flags_proc( u_int dbpcl_id, u_int32_t flags, __db_set_flags_reply *replyp){ Db *dbp; ct_entry *dbp_ctp; int ret; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; ret = dbp->set_flags(flags); dbp_ctp->ct_dbdp.setflags = flags; replyp->status = ret; return;}extern "C" void__db_get_proc( u_int dbpcl_id, u_int txnpcl_id, u_int32_t keydlen, u_int32_t keydoff, u_int32_t keyulen, u_int32_t keyflags, void *keydata, u_int32_t keysize, u_int32_t datadlen, u_int32_t datadoff, u_int32_t dataulen, u_int32_t dataflags, void *datadata, u_int32_t datasize, u_int32_t flags, __db_get_reply *replyp, int * freep){ Db *dbp; DbTxn *txnp; ct_entry *dbp_ctp, *txnp_ctp; int ret; void *tmpdata; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; if (txnpcl_id != 0) { ACTIVATE_CTP(txnp_ctp, txnpcl_id, CT_TXN); txnp = (DbTxn *)txnp_ctp->ct_anyp; } else txnp = NULL; replyp->keydata.keydata_val = NULL; replyp->datadata.datadata_val = NULL; *freep = 0; /* Set up key and data */ Dbt key(keydata, keysize); key.set_dlen(keydlen); key.set_ulen(keyulen); key.set_doff(keydoff); /* * Ignore memory related flags on server. */ key.set_flags(DB_DBT_MALLOC | (keyflags & DB_DBT_PARTIAL)); Dbt data(datadata, datasize); data.set_dlen(datadlen); data.set_ulen(dataulen); data.set_doff(datadoff); /* * Ignore memory related flags on server. */ dataflags &= DB_DBT_PARTIAL; if (flags & DB_MULTIPLE) { if (data.get_data() == 0) { ret = __os_umalloc(dbp->get_DB()->dbenv, dataulen, &tmpdata); if (ret != 0) goto err; data.set_data(tmpdata); } dataflags |= DB_DBT_USERMEM; } else dataflags |= DB_DBT_MALLOC; data.set_flags(dataflags); /* Got all our stuff, now do the get */ ret = dbp->get(txnp, &key, &data, flags); /* * Otherwise just status. */ if (ret == 0) { /* * XXX * We need to xdr_free whatever we are returning, next time. * However, DB does not allocate a new key if one was given * and we'd be free'ing up space allocated in the request. * So, allocate a new key/data pointer if it is the same one * as in the request. */ *freep = 1; /* * Key */ if (key.get_data() == keydata) { ret = __os_umalloc(dbp->get_DB()->dbenv, key.get_size(), &replyp->keydata.keydata_val); if (ret != 0) goto err; memcpy(replyp->keydata.keydata_val, key.get_data(), key.get_size()); } else replyp->keydata.keydata_val = (char *)key.get_data(); replyp->keydata.keydata_len = key.get_size(); /* * Data */ if (data.get_data() == datadata) { ret = __os_umalloc(dbp->get_DB()->dbenv, data.get_size(), &replyp->datadata.datadata_val); if (ret != 0) goto err; memcpy(replyp->datadata.datadata_val, data.get_data(), data.get_size()); } else replyp->datadata.datadata_val = (char *)data.get_data(); replyp->datadata.datadata_len = data.get_size(); } else {err: FREE_IF_CHANGED(dbp->get_DB()->dbenv, key.get_data(), keydata); FREE_IF_CHANGED(dbp->get_DB()->dbenv, data.get_data(), datadata); FREE_IF_CHANGED(dbp->get_DB()->dbenv, replyp->keydata.keydata_val, key.get_data()); replyp->keydata.keydata_val = NULL; replyp->keydata.keydata_len = 0; replyp->datadata.datadata_val = NULL; replyp->datadata.datadata_len = 0; *freep = 0; } replyp->status = ret; return;}extern "C" void__db_get_h_ffactor_proc( u_int dbpcl_id, __db_get_h_ffactor_reply *replyp){ Db *dbp; ct_entry *dbp_ctp; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; replyp->status = dbp->get_h_ffactor(&replyp->ffactor);}extern "C" void__db_set_h_ffactor_proc( u_int dbpcl_id, u_int32_t ffactor, __db_set_h_ffactor_reply *replyp){ Db *dbp; ct_entry *dbp_ctp; int ret; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; ret = dbp->set_h_ffactor(ffactor); replyp->status = ret; return;}extern "C" void__db_get_h_nelem_proc( u_int dbpcl_id, __db_get_h_nelem_reply *replyp){ Db *dbp; ct_entry *dbp_ctp; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; replyp->status = dbp->get_h_nelem(&replyp->nelem);}extern "C" void__db_set_h_nelem_proc( u_int dbpcl_id, u_int32_t nelem, __db_set_h_nelem_reply *replyp){ Db *dbp; ct_entry *dbp_ctp; int ret; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; ret = dbp->set_h_nelem(nelem); replyp->status = ret; return;}extern "C" void__db_key_range_proc( u_int dbpcl_id, u_int txnpcl_id, u_int32_t keydlen, u_int32_t keydoff, u_int32_t keyulen, u_int32_t keyflags, void *keydata, u_int32_t keysize, u_int32_t flags, __db_key_range_reply *replyp){ Db *dbp; DB_KEY_RANGE range; DbTxn *txnp; ct_entry *dbp_ctp, *txnp_ctp; int ret; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; if (txnpcl_id != 0) { ACTIVATE_CTP(txnp_ctp, txnpcl_id, CT_TXN); txnp = (DbTxn *)txnp_ctp->ct_anyp; } else txnp = NULL; /* Set up key */ Dbt key(keydata, keysize); key.set_dlen(keydlen); key.set_ulen(keyulen); key.set_doff(keydoff); key.set_flags(keyflags); ret = dbp->key_range(txnp, &key, &range, flags); replyp->status = ret; replyp->less = range.less; replyp->equal = range.equal; replyp->greater = range.greater; return;}extern "C" void__db_get_lorder_proc( u_int dbpcl_id, __db_get_lorder_reply *replyp){ Db *dbp; ct_entry *dbp_ctp; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; replyp->status = dbp->get_lorder((int *)&replyp->lorder);}extern "C" void__db_set_lorder_proc( u_int dbpcl_id, u_int32_t lorder, __db_set_lorder_reply *replyp){ Db *dbp; ct_entry *dbp_ctp; int ret; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; ret = dbp->set_lorder(lorder); replyp->status = ret; return;}extern "C" void__db_get_dbname_proc( u_int dbpcl_id, __db_get_dbname_reply *replyp){ Db *dbp; ct_entry *dbp_ctp; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; replyp->status = dbp->get_dbname( (const char **)&replyp->filename, (const char **)&replyp->dbname);}extern "C" void__db_get_open_flags_proc( u_int dbpcl_id, __db_get_open_flags_reply *replyp){ Db *dbp; ct_entry *dbp_ctp; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; replyp->status = dbp->get_open_flags(&replyp->flags);}extern "C" void__db_open_proc( u_int dbpcl_id, u_int txnpcl_id, char *name, char *subdb, u_int32_t type, u_int32_t flags, u_int32_t mode, __db_open_reply *replyp){ Db *dbp; DbTxn *txnp; DBTYPE dbtype; ct_entry *dbp_ctp, *new_ctp, *txnp_ctp; int isswapped, ret; ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB); dbp = (Db *)dbp_ctp->ct_anyp; if (txnpcl_id != 0) { ACTIVATE_CTP(txnp_ctp, txnpcl_id, CT_TXN); txnp = (DbTxn *)txnp_ctp->ct_anyp; } else txnp = NULL; replyp->dbcl_id = dbpcl_id; if ((new_ctp = __dbsrv_sharedb( dbp_ctp, name, subdb, (DBTYPE)type, flags)) != NULL) { /* * We can share, clean up old ID, set new one. */ if (__dbsrv_verbose) printf("Sharing db ID %ld\n", new_ctp->ct_id); replyp->dbcl_id = new_ctp->ct_id; ret = __db_close_int(dbpcl_id, 0); goto out; } ret = dbp->open(txnp, name, subdb, (DBTYPE)type, flags, mode); if (ret == 0) { (void)dbp->get_type(&dbtype);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -