int kbytes, minutes;
u_int32_t kbytes, minutes;
txn_checkpoint(mgr, kbytes, minutes)	const DB_TXNMGR *mgr;	int kbytes, minutes;{	TXN_DETAIL *txnp;	DB_LSN ckp_lsn, last_ckp;	DB_LOG *dblp;	u_int32_t kbytes_written;	time_t last_ckp_time, now;	int ret;	/* Check usage. */	if (kbytes < 0 || minutes < 0)		return (EINVAL);	/*	 * Check if we need to run recovery.	 */	ZERO_LSN(ckp_lsn);	if (minutes != 0) {		(void)time(&now);		LOCK_TXNREGION(mgr);		last_ckp_time = mgr->region->time_ckp;		UNLOCK_TXNREGION(mgr);		if (now - last_ckp_time >= (time_t)(minutes * 60))			goto do_ckp;	}	if (kbytes != 0) {		dblp = mgr->dbenv->lg_info;		LOCK_LOGREGION(dblp);		kbytes_written =		    dblp->lp->stat.st_wc_mbytes * 1024 +		    dblp->lp->stat.st_wc_bytes / 1024;		ckp_lsn = dblp->lp->lsn;		UNLOCK_LOGREGION(dblp);		if (kbytes_written >= (u_int32_t)kbytes)			goto do_ckp;	}	/*	 * If we checked time and data and didn't go to checkpoint,	 * we're done.	 */	if (minutes != 0 || kbytes != 0)		return (0);do_ckp:	if (IS_ZERO_LSN(ckp_lsn)) {		dblp = mgr->dbenv->lg_info;		LOCK_LOGREGION(dblp);		ckp_lsn = dblp->lp->lsn;		UNLOCK_LOGREGION(dblp);	}	/*	 * We have to find an LSN such that all transactions begun	 * before that LSN are complete.	 */	LOCK_TXNREGION(mgr);	if (!IS_ZERO_LSN(mgr->region->pending_ckp))		ckp_lsn = mgr->region->pending_ckp;	else		for (txnp =		    SH_TAILQ_FIRST(&mgr->region->active_txn, __txn_detail);		    txnp != NULL;		    txnp = SH_TAILQ_NEXT(txnp, links, __txn_detail)) {			/*			 * Look through the active transactions for the			 * lowest begin lsn.			 */			if (!IS_ZERO_LSN(txnp->begin_lsn) &&			    log_compare(&txnp->begin_lsn, &ckp_lsn) < 0)				ckp_lsn = txnp->begin_lsn;		}	mgr->region->pending_ckp = ckp_lsn;	UNLOCK_TXNREGION(mgr);	if (mgr->dbenv->mp_info != NULL &&	    (ret = memp_sync(mgr->dbenv->mp_info, &ckp_lsn)) != 0) {		/*		 * ret < 0 means that there are still buffers to flush;		 * the checkpoint is not complete. Back off and try again.		 */		if (ret > 0)			__db_err(mgr->dbenv,			    "txn_checkpoint: system failure in memp_sync %s\n",			    strerror(ret));		return (ret);	}	if (mgr->dbenv->lg_info != NULL) {		LOCK_TXNREGION(mgr);		last_ckp = mgr->region->last_ckp;		ZERO_LSN(mgr->region->pending_ckp);		UNLOCK_TXNREGION(mgr);		if ((ret = __txn_ckp_log(mgr->dbenv->lg_info,		   NULL, &ckp_lsn, DB_CHECKPOINT, &ckp_lsn, &last_ckp)) != 0) {			__db_err(mgr->dbenv,			    "txn_checkpoint: log failed at LSN [%ld %ld] %s\n",			    (long)ckp_lsn.file, (long)ckp_lsn.offset,			    strerror(ret));			return (ret);		}		LOCK_TXNREGION(mgr);		mgr->region->last_ckp = ckp_lsn;		(void)time(&mgr->region->time_ckp);		UNLOCK_TXNREGION(mgr);	}	return (0);}