int flags;
u_int32_t flags;
db_close(dbp, flags)	DB *dbp;	int flags;{	DBC *dbc;	DB *tdbp;	int ret, t_ret;	/* Validate arguments. */	if ((ret = __db_fchk(dbp->dbenv, "db_close", flags, DB_NOSYNC)) != 0)		return (ret);	/* Sync the underlying file. */	if (!LF_ISSET(DB_NOSYNC) &&	    (t_ret = dbp->sync(dbp, 0)) != 0 && ret == 0)		ret = t_ret;	/*	 * Call the underlying access method close routine for all the	 * cursors and handles.	 */	for (tdbp = LIST_FIRST(&dbp->handleq);	    tdbp != NULL; tdbp = LIST_NEXT(tdbp, links)) {		while ((dbc = TAILQ_FIRST(&tdbp->curs_queue)) != NULL)			switch (tdbp->type) {			case DB_BTREE:				if ((t_ret =				    __bam_c_iclose(tdbp, dbc)) != 0 && ret == 0)					ret = t_ret;				break;			case DB_HASH:				if ((t_ret =				    __ham_c_iclose(tdbp, dbc)) != 0 && ret == 0)					ret = t_ret;				break;			case DB_RECNO:				if ((t_ret =				    __ram_c_iclose(tdbp, dbc)) != 0 && ret == 0)					ret = t_ret;				break;			default:				abort();			}		switch (tdbp->type) {		case DB_BTREE:			if ((t_ret = __bam_close(tdbp)) != 0 && ret == 0)				ret = t_ret;			break;		case DB_HASH:			if ((t_ret = __ham_close(tdbp)) != 0 && ret == 0)				ret = t_ret;			break;		case DB_RECNO:			if ((t_ret = __ram_close(tdbp)) != 0 && ret == 0)				ret = t_ret;			break;		default:			abort();		}	}	/* Sync the memory pool. */	if ((t_ret = memp_fsync(dbp->mpf)) != 0 &&	    t_ret != DB_INCOMPLETE && ret == 0)		ret = t_ret;	/* Close the memory pool file. */	if ((t_ret = memp_fclose(dbp->mpf)) != 0 && ret == 0)		ret = t_ret;	/* If the memory pool was local, close it. */	if (F_ISSET(dbp, DB_AM_MLOCAL) &&	    (t_ret = memp_close(dbp->mp)) != 0 && ret == 0)		ret = t_ret;	/* Discard the log file id. */	if (F_ISSET(dbp, DB_AM_LOGGING))		(void)log_unregister(dbp->dbenv->lg_info, dbp->log_fileid);	/* Discard the lock cookie for all handles. */	for (tdbp = LIST_FIRST(&dbp->handleq);	    tdbp != NULL; tdbp = LIST_NEXT(tdbp, links))		if (F_ISSET(tdbp, DB_AM_LOCKING)) {#ifdef DEBUG			DB_LOCKREQ request;			/*			 * If we're running tests, display any locks currently			 * held.  It's possible that some applications may hold			 * locks for long periods, e.g., conference room locks,			 * but the DB tests should never close holding locks.			 */			request.op = DB_LOCK_DUMP;			if ((t_ret = lock_vec(tdbp->dbenv->lk_info,			    tdbp->locker, 0, &request, 1, NULL)) != 0 &&			    ret == 0)				ret = EAGAIN;#endif		}	/* If we allocated a DB_ENV, discard it. */	if (dbp->mp_dbenv != NULL)		FREE(dbp->mp_dbenv, sizeof(DB_ENV));	/* Free all of the DB's. */	LIST_REMOVE(dbp, links);	while ((tdbp = LIST_FIRST(&dbp->handleq)) != NULL) {		LIST_REMOVE(tdbp, links);		FREE(tdbp, sizeof(*tdbp));	}	FREE(dbp, sizeof(*dbp));	return (ret);}