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

📄 bt_curadj.c

📁 这是国外的resip协议栈
💻 C
📖 第 1 页 / 共 2 页
字号:
	    ldbp != NULL && ldbp->adj_fileid == dbp->adj_fileid;	    ldbp = LIST_NEXT(ldbp, dblistlinks)) {loop:		MUTEX_THREAD_LOCK(dbenv, dbp->mutexp);		for (dbc = TAILQ_FIRST(&ldbp->active_queue);		    dbc != NULL; dbc = TAILQ_NEXT(dbc, links)) {			/* Find cursors pointing to this record. */			orig_cp = (BTREE_CURSOR *)dbc->internal;			if (orig_cp->pgno != fpgno || orig_cp->indx != fi)				continue;			/*			 * Since we rescan the list see if this is already			 * converted.			 */			if (orig_cp->opd != NULL)				continue;			MUTEX_THREAD_UNLOCK(dbenv, dbp->mutexp);			/* [#8032]			DB_ASSERT(!STD_LOCKING(dbc) ||			    orig_cp->lock_mode != DB_LOCK_NG);			*/			if ((ret = __bam_opd_cursor(dbp,			    dbc, first, tpgno, ti)) !=0)				return (ret);			if (my_txn != NULL && dbc->txn != my_txn)				found = 1;			/* We released the mutex to get a cursor, start over. */			goto loop;		}		MUTEX_THREAD_UNLOCK(dbenv, dbp->mutexp);	}	MUTEX_THREAD_UNLOCK(dbenv, dbenv->dblist_mutexp);	if (found != 0 && DBC_LOGGING(my_dbc)) {		if ((ret = __bam_curadj_log(dbp, my_dbc->txn,		    &lsn, 0, DB_CA_DUP, fpgno, tpgno, 0, first, fi, ti)) != 0)			return (ret);	}	return (0);}/* * __bam_ca_undodup -- *	Adjust the cursors when returning items to a leaf page *	from a duplicate page. *	Called only during undo processing. * * PUBLIC: int __bam_ca_undodup __P((DB *, * PUBLIC:    u_int32_t, db_pgno_t, u_int32_t, u_int32_t)); */int__bam_ca_undodup(dbp, first, fpgno, fi, ti)	DB *dbp;	db_pgno_t fpgno;	u_int32_t first, fi, ti;{	BTREE_CURSOR *orig_cp;	DB *ldbp;	DBC *dbc;	DB_ENV *dbenv;	int ret;	dbenv = dbp->dbenv;	/*	 * Adjust the cursors.  See the comment in __bam_ca_delete().	 */	MUTEX_THREAD_LOCK(dbenv, dbenv->dblist_mutexp);	for (ldbp = __dblist_get(dbenv, dbp->adj_fileid);	    ldbp != NULL && ldbp->adj_fileid == dbp->adj_fileid;	    ldbp = LIST_NEXT(ldbp, dblistlinks)) {loop:		MUTEX_THREAD_LOCK(dbenv, dbp->mutexp);		for (dbc = TAILQ_FIRST(&ldbp->active_queue);		    dbc != NULL; dbc = TAILQ_NEXT(dbc, links)) {			orig_cp = (BTREE_CURSOR *)dbc->internal;			/*			 * A note on the orig_cp->opd != NULL requirement here:			 * it's possible that there's a cursor that refers to			 * the same duplicate set, but which has no opd cursor,			 * because it refers to a different item and we took			 * care of it while processing a previous record.			 */			if (orig_cp->pgno != fpgno ||			    orig_cp->indx != first ||			    orig_cp->opd == NULL ||			    ((BTREE_CURSOR *)orig_cp->opd->internal)->indx			    != ti)				continue;			MUTEX_THREAD_UNLOCK(dbenv, dbp->mutexp);			if ((ret = __db_c_close(orig_cp->opd)) != 0)				return (ret);			orig_cp->opd = NULL;			orig_cp->indx = fi;			/*			 * We released the mutex to free a cursor,			 * start over.			 */			goto loop;		}		MUTEX_THREAD_UNLOCK(dbenv, dbp->mutexp);	}	MUTEX_THREAD_UNLOCK(dbenv, dbenv->dblist_mutexp);	return (0);}/* * __bam_ca_rsplit -- *	Adjust the cursors when doing reverse splits. * * PUBLIC: int __bam_ca_rsplit __P((DBC *, db_pgno_t, db_pgno_t)); */int__bam_ca_rsplit(my_dbc, fpgno, tpgno)	DBC* my_dbc;	db_pgno_t fpgno, tpgno;{	DB *dbp, *ldbp;	DBC *dbc;	DB_ENV *dbenv;	DB_LSN lsn;	DB_TXN *my_txn;	int found, ret;	dbp = my_dbc->dbp;	dbenv = dbp->dbenv;	my_txn = IS_SUBTRANSACTION(my_dbc->txn) ? my_dbc->txn : NULL;	/*	 * Adjust the cursors.  See the comment in __bam_ca_delete().	 */	found = 0;	MUTEX_THREAD_LOCK(dbenv, dbenv->dblist_mutexp);	for (ldbp = __dblist_get(dbenv, dbp->adj_fileid);	    ldbp != NULL && ldbp->adj_fileid == dbp->adj_fileid;	    ldbp = LIST_NEXT(ldbp, dblistlinks)) {		MUTEX_THREAD_LOCK(dbenv, dbp->mutexp);		for (dbc = TAILQ_FIRST(&ldbp->active_queue);		    dbc != NULL; dbc = TAILQ_NEXT(dbc, links)) {			if (dbc->dbtype == DB_RECNO)				continue;			if (dbc->internal->pgno == fpgno) {				dbc->internal->pgno = tpgno;				/* [#8032]				DB_ASSERT(!STD_LOCKING(dbc) ||				    dbc->internal->lock_mode != DB_LOCK_NG);				*/				if (my_txn != NULL && dbc->txn != my_txn)					found = 1;			}		}		MUTEX_THREAD_UNLOCK(dbenv, dbp->mutexp);	}	MUTEX_THREAD_UNLOCK(dbenv, dbenv->dblist_mutexp);	if (found != 0 && DBC_LOGGING(my_dbc)) {		if ((ret = __bam_curadj_log(dbp, my_dbc->txn,		    &lsn, 0, DB_CA_RSPLIT, fpgno, tpgno, 0, 0, 0, 0)) != 0)			return (ret);	}	return (0);}/* * __bam_ca_split -- *	Adjust the cursors when splitting a page. * * PUBLIC: int __bam_ca_split __P((DBC *, * PUBLIC:    db_pgno_t, db_pgno_t, db_pgno_t, u_int32_t, int)); */int__bam_ca_split(my_dbc, ppgno, lpgno, rpgno, split_indx, cleft)	DBC *my_dbc;	db_pgno_t ppgno, lpgno, rpgno;	u_int32_t split_indx;	int cleft;{	DB *dbp, *ldbp;	DBC *dbc;	DBC_INTERNAL *cp;	DB_ENV *dbenv;	DB_LSN lsn;	DB_TXN *my_txn;	int found, ret;	dbp = my_dbc->dbp;	dbenv = dbp->dbenv;	my_txn = IS_SUBTRANSACTION(my_dbc->txn) ? my_dbc->txn : NULL;	/*	 * Adjust the cursors.  See the comment in __bam_ca_delete().	 *	 * If splitting the page that a cursor was on, the cursor has to be	 * adjusted to point to the same record as before the split.  Most	 * of the time we don't adjust pointers to the left page, because	 * we're going to copy its contents back over the original page.  If	 * the cursor is on the right page, it is decremented by the number of	 * records split to the left page.	 */	found = 0;	MUTEX_THREAD_LOCK(dbenv, dbenv->dblist_mutexp);	for (ldbp = __dblist_get(dbenv, dbp->adj_fileid);	    ldbp != NULL && ldbp->adj_fileid == dbp->adj_fileid;	    ldbp = LIST_NEXT(ldbp, dblistlinks)) {		MUTEX_THREAD_LOCK(dbenv, dbp->mutexp);		for (dbc = TAILQ_FIRST(&ldbp->active_queue);		    dbc != NULL; dbc = TAILQ_NEXT(dbc, links)) {			if (dbc->dbtype == DB_RECNO)				continue;			cp = dbc->internal;			if (cp->pgno == ppgno) {				/* [#8032]				DB_ASSERT(!STD_LOCKING(dbc) ||				    cp->lock_mode != DB_LOCK_NG);				*/				if (my_txn != NULL && dbc->txn != my_txn)					found = 1;				if (cp->indx < split_indx) {					if (cleft)						cp->pgno = lpgno;				} else {					cp->pgno = rpgno;					cp->indx -= split_indx;				}			}		}		MUTEX_THREAD_UNLOCK(dbenv, dbp->mutexp);	}	MUTEX_THREAD_UNLOCK(dbenv, dbenv->dblist_mutexp);	if (found != 0 && DBC_LOGGING(my_dbc)) {		if ((ret = __bam_curadj_log(dbp,		    my_dbc->txn, &lsn, 0, DB_CA_SPLIT, ppgno, rpgno,		    cleft ? lpgno : PGNO_INVALID, 0, split_indx, 0)) != 0)			return (ret);	}	return (0);}/* * __bam_ca_undosplit -- *	Adjust the cursors when undoing a split of a page. *	If we grew a level we will execute this for both the *	left and the right pages. *	Called only during undo processing. * * PUBLIC: void __bam_ca_undosplit __P((DB *, * PUBLIC:    db_pgno_t, db_pgno_t, db_pgno_t, u_int32_t)); */void__bam_ca_undosplit(dbp, frompgno, topgno, lpgno, split_indx)	DB *dbp;	db_pgno_t frompgno, topgno, lpgno;	u_int32_t split_indx;{	DB *ldbp;	DBC *dbc;	DB_ENV *dbenv;	DBC_INTERNAL *cp;	dbenv = dbp->dbenv;	/*	 * Adjust the cursors.  See the comment in __bam_ca_delete().	 *	 * When backing out a split, we move the cursor back	 * to the original offset and bump it by the split_indx.	 */	MUTEX_THREAD_LOCK(dbenv, dbenv->dblist_mutexp);	for (ldbp = __dblist_get(dbenv, dbp->adj_fileid);	    ldbp != NULL && ldbp->adj_fileid == dbp->adj_fileid;	    ldbp = LIST_NEXT(ldbp, dblistlinks)) {		MUTEX_THREAD_LOCK(dbenv, dbp->mutexp);		for (dbc = TAILQ_FIRST(&ldbp->active_queue);		    dbc != NULL; dbc = TAILQ_NEXT(dbc, links)) {			if (dbc->dbtype == DB_RECNO)				continue;			cp = dbc->internal;			if (cp->pgno == topgno) {				cp->pgno = frompgno;				cp->indx += split_indx;			} else if (cp->pgno == lpgno)				cp->pgno = frompgno;		}		MUTEX_THREAD_UNLOCK(dbenv, dbp->mutexp);	}	MUTEX_THREAD_UNLOCK(dbenv, dbenv->dblist_mutexp);}

⌨️ 快捷键说明

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