⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 db_server_proc.c

📁 linux 下的源代码分析阅读器 red hat公司新版
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * PUBLIC: void __txn_prepare_proc __P((u_int, u_int8_t *, * PUBLIC:      __txn_prepare_reply *)); */void__txn_prepare_proc(txnpcl_id, gid, replyp)	u_int txnpcl_id;	u_int8_t *gid;	__txn_prepare_reply *replyp;{	DB_TXN *txnp;	ct_entry *txnp_ctp;	int ret;	ACTIVATE_CTP(txnp_ctp, txnpcl_id, CT_TXN);	txnp = (DB_TXN *)txnp_ctp->ct_anyp;	ret = txnp->prepare(txnp, gid);	replyp->status = ret;	return;}/* * PUBLIC: void __env_txn_recover_proc __P((u_int, u_int32_t, u_int32_t, * PUBLIC:      __env_txn_recover_reply *, int *)); */void__env_txn_recover_proc(dbenvcl_id, count, flags, replyp, freep)	u_int dbenvcl_id;	u_int32_t count;	u_int32_t flags;	__env_txn_recover_reply *replyp;	int * freep;{	DB_ENV *dbenv;	DB_PREPLIST *dbprep, *p;	ct_entry *dbenv_ctp, *ctp;	long erri, i, retcount;	u_int32_t *txnidp;	int ret;	u_int8_t *gid;	ACTIVATE_CTP(dbenv_ctp, dbenvcl_id, CT_ENV);	dbenv = (DB_ENV *)dbenv_ctp->ct_anyp;	dbprep = NULL;	*freep = 0;	if ((ret =	    __os_malloc(dbenv, count * sizeof(DB_PREPLIST), &dbprep)) != 0)		goto out;	if ((ret =	    dbenv->txn_recover(dbenv, dbprep, count, &retcount, flags)) != 0)		goto out;	/*	 * If there is nothing, success, but it's easy.	 */	replyp->retcount = retcount;	if (retcount == 0) {		replyp->txn.txn_val = NULL;		replyp->txn.txn_len = 0;		replyp->gid.gid_val = NULL;		replyp->gid.gid_len = 0;	}	/*	 * We have our txn list.  Now we need to allocate the space for	 * the txn ID array and the GID array and set them up.	 */	if ((ret = __os_calloc(dbenv, retcount, sizeof(u_int32_t),	    &replyp->txn.txn_val)) != 0)		goto out;	replyp->txn.txn_len = retcount * sizeof(u_int32_t);	if ((ret = __os_calloc(dbenv, retcount, DB_XIDDATASIZE,	    &replyp->gid.gid_val)) != 0) {		__os_free(dbenv, replyp->txn.txn_val);		goto out;	}	replyp->gid.gid_len = retcount * DB_XIDDATASIZE;	/*	 * Now walk through our results, creating parallel arrays	 * to send back.  For each entry we need to create a new	 * txn ctp and then fill in the array info.	 */	i = 0;	p = dbprep;	gid = replyp->gid.gid_val;	txnidp = replyp->txn.txn_val;	while (i++ < retcount) {		ctp = new_ct_ent(&ret);		if (ret != 0) {			i--;			goto out2;		}		ctp->ct_txnp = p->txn;		ctp->ct_type = CT_TXN;		ctp->ct_parent = NULL;		ctp->ct_envparent = dbenv_ctp;		__dbsrv_settimeout(ctp, dbenv_ctp->ct_timeout);		__dbsrv_active(ctp);		*txnidp = ctp->ct_id;		memcpy(gid, p->gid, DB_XIDDATASIZE);		p++;		txnidp++;		gid += DB_XIDDATASIZE;	}	/*	 * If we get here, we have success and we have to set freep	 * so it'll get properly freed next time.	 */	*freep = 1;out:	if (dbprep != NULL)		__os_free(dbenv, dbprep);	replyp->status = ret;	return;out2:	/*	 * We had an error in the middle of creating our new txn	 * ct entries.  We have to unwind all that we have done.  Ugh.	 */	for (txnidp = replyp->txn.txn_val, erri = 0;	    erri < i; erri++, txnidp++) {		ctp = get_tableent(*txnidp);		__dbclear_ctp(ctp);	}	__os_free(dbenv, replyp->txn.txn_val);	__os_free(dbenv, replyp->gid.gid_val);	__os_free(dbenv, dbprep);	replyp->status = ret;	return;}/* * PUBLIC: void __db_associate_proc __P((u_int, u_int, u_int, u_int32_t, * PUBLIC:      __db_associate_reply *)); */void__db_associate_proc(dbpcl_id, txnpcl_id, sdbpcl_id, flags, replyp)	u_int dbpcl_id;	u_int txnpcl_id;	u_int sdbpcl_id;	u_int32_t flags;	__db_associate_reply *replyp;{	DB *dbp, *sdbp;	DB_TXN *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 = (DB_TXN *)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.	 */#ifdef CONFIG_TEST	if (LF_ISSET(DB_RPC2ND_MASK | DB_CREATE))#else	if (LF_ISSET(DB_CREATE))#endif		ret = EINVAL;	else		ret = dbp->associate(dbp, txnp, sdbp, NULL, flags);	replyp->status = ret;	return;}/* * PUBLIC: void __db_get_bt_minkey_proc __P((u_int, * PUBLIC:      __db_get_bt_minkey_reply *)); */void__db_get_bt_minkey_proc(dbpcl_id, replyp)	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(dbp, &replyp->minkey);}/* * PUBLIC: void __db_set_bt_minkey_proc __P((u_int, u_int32_t, * PUBLIC:      __db_set_bt_minkey_reply *)); */void__db_set_bt_minkey_proc(dbpcl_id, minkey, replyp)	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(dbp, minkey);	replyp->status = ret;	return;}/* * PUBLIC: void __db_close_proc __P((u_int, u_int32_t, __db_close_reply *)); */void__db_close_proc(dbpcl_id, flags, replyp)	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;}/* * PUBLIC: void __db_create_proc __P((u_int, u_int32_t, __db_create_reply *)); */void__db_create_proc(dbenvcl_id, flags, replyp)	u_int dbenvcl_id;	u_int32_t flags;	__db_create_reply *replyp;{	DB *dbp;	DB_ENV *dbenv;	ct_entry *dbenv_ctp, *dbp_ctp;	int ret;	ACTIVATE_CTP(dbenv_ctp, dbenvcl_id, CT_ENV);	dbenv = (DB_ENV *)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(dbenv, dbenv != NULL);	if ((ret = db_create(&dbp, dbenv, flags)) == 0) {		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;	} else		__dbclear_ctp(dbp_ctp);	replyp->status = ret;	return;}/* * PUBLIC: void __db_del_proc __P((u_int, u_int, u_int32_t, u_int32_t, * PUBLIC:	u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, * PUBLIC:	__db_del_reply *)); */void__db_del_proc(dbpcl_id, txnpcl_id, keydlen, keydoff, keyulen, keyflags,    keydata, keysize, flags, replyp)	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;	DBT key;	DB_TXN *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 = (DB_TXN *)txnp_ctp->ct_anyp;	} else		txnp = NULL;	memset(&key, 0, sizeof(key));	/* Set up key DBT */	key.dlen = keydlen;	key.ulen = keyulen;	key.doff = keydoff;	key.flags = keyflags;	key.size = keysize;	key.data = keydata;	ret = dbp->del(dbp, txnp, &key, flags);	replyp->status = ret;	return;}/* * PUBLIC: void __db_get_encrypt_flags_proc __P((u_int, * PUBLIC:      __db_get_encrypt_flags_reply *)); */void__db_get_encrypt_flags_proc(dbpcl_id, replyp)	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(dbp, &replyp->flags);}/* * PUBLIC: void __db_set_encrypt_proc __P((u_int, char *, u_int32_t, * PUBLIC:      __db_set_encrypt_reply *)); */void__db_set_encrypt_proc(dbpcl_id, passwd, flags, replyp)	u_int dbpcl_id;	char *passwd;	u_int32_t flags;	__db_set_encrypt_reply *replyp;{	int ret;	DB * dbp;	ct_entry *dbp_ctp;	ACTIVATE_CTP(dbp_ctp, dbpcl_id, CT_DB);	dbp = (DB *)dbp_ctp->ct_anyp;	ret = dbp->set_encrypt(dbp, passwd, flags);	replyp->status = ret;	return;}/* * PUBLIC: void __db_get_q_extentsize_proc __P((u_int, * PUBLIC:      __db_get_q_extentsize_reply *)); */void__db_get_q_extentsize_proc(dbpcl_id, replyp)	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(dbp, &replyp->extentsize);}/* * PUBLIC: void __db_set_q_extentsize_proc __P((u_int, u_int32_t, * PUBLIC:      __db_set_q_extentsize_reply *)); */void__db_set_q_extentsize_proc(dbpcl_id, extentsize, replyp)	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(dbp, extentsize);	replyp->status = ret;	return;}/* * PUBLIC: void __db_get_flags_proc __P((u_int, __db_get_flags_reply *)); */void__db_get_flags_proc(dbpcl_id, replyp)	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(dbp, &replyp->flags);}/* * PUBLIC: void __db_set_flags_proc * PUBLIC:     __P((u_int, u_int32_t, __db_set_flags_reply *)); */void__db_set_flags_proc(dbpcl_id, flags, replyp)	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(dbp, flags);	dbp_ctp->ct_dbdp.setflags |= flags;	replyp->status = ret;	return;}/* * PUBLIC: void __db_get_proc __P((u_int, u_int, u_int32_t, u_int32_t, * PUBLIC:	u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, * PUBLIC:	u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, * PUBLIC:	u_int32_t, __db_get_reply *, int *)); */void__db_get_proc(dbpcl_id, txnpcl_id, keydlen, keydoff, keyulen, keyflags,    keydata, keysize, datadlen, datadoff, dataulen, dataflags, datadata,    datasize, flags, replyp, freep)	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;	DBT key, data;	DB_TXN *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 = (DB_TXN *)txnp_ctp->ct_anyp;	} else		txnp = NULL;	replyp->keydata.keydata_val = NULL;	replyp->datadata.datadata_val = NULL;	*freep = 0;	memset(&key, 0, sizeof(key));	memset(&data, 0, sizeof(data));	/* Set up key and data DBT */	key.dlen = keydlen;	key.doff = keydoff;	/*	 * Ignore memory related flags on server.	 */	key.flags = DB_DBT_MALLOC;	if (keyflags & DB_DBT_PARTIAL)		key.flags |= DB_DBT_PARTIAL;	key.size = keysize;	key.ulen = keyulen;	key.data = keydata;	data.dlen = datadlen;	data.doff = datadoff;	data.ulen = dataulen;	/*	 * Ignore memory related flags on server.	 */	data.size = datasize;	data.data = datadata;	if (flags & DB_MULTIPLE) {		if (data.data == 0) {			ret = __os_umalloc(dbp->dbenv,			    data.ulen, &data.data);			if (ret != 0)				goto err;		}		data.flags |= DB_DBT_USERMEM;	} else		data.flags |= DB_DBT_MALLOC;	if (dataflags & DB_DBT_PARTIAL)		data.flags |= DB_DBT_PARTIAL;	/* Got all our stuff, now do the get */	ret = dbp->get(dbp, 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.data == keydata) {			ret = __os_umalloc(dbp->dbenv,			    key.size, &replyp->keydata.keydata_val);			if (ret != 0)				goto err;			memcpy(replyp->keydata.keydata_val, key.data, key.size);		} else			replyp->keydata.keydata_val = key.data;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -