当前位置: 首页>>代码示例>>C++>>正文


C++ DB_ENV::set_msgfile方法代码示例

本文整理汇总了C++中DB_ENV::set_msgfile方法的典型用法代码示例。如果您正苦于以下问题:C++ DB_ENV::set_msgfile方法的具体用法?C++ DB_ENV::set_msgfile怎么用?C++ DB_ENV::set_msgfile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DB_ENV的用法示例。


在下文中一共展示了DB_ENV::set_msgfile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TestSetTransactionTimeout

int TestSetTransactionTimeout(CuTest *ct) {
	DB_ENV *dbenv;
	struct context *info;
	FILE *msgfile;
	char *path;
	db_timeout_t timeout;

	dbenv = NULL;
	if ((path = calloc(100, sizeof(char))) == NULL)
		return (ENOMEM);
	snprintf(path, 100, "%s%c%s", TEST_ENV, PATH_SEPARATOR[0], "msgfile");
	if ((msgfile = fopen(path, "w")) == NULL)
		return (EINVAL);
	info = ct->context;
	info->fp = msgfile;
	info->path = path;
	/* txn timeout: reset at run-time. */
	ENV
	CuAssertTrue(ct,
	    dbenv->set_timeout(dbenv, 37, DB_SET_TXN_TIMEOUT) == 0);
	CuAssertTrue(ct, dbenv->open(dbenv,
	    TEST_ENV, DB_CREATE | DB_INIT_LOCK, 0666) == 0);
	CuAssertTrue(ct,
	    dbenv->get_timeout(dbenv, &timeout, DB_SET_TXN_TIMEOUT) == 0);
	CuAssertTrue(ct, timeout == 37);
	ENV
	/* New transaction timeout is ignored when joining the environment. */
	CuAssertTrue(ct,
	    dbenv->set_timeout(dbenv, 63, DB_SET_TXN_TIMEOUT) == 0);
	/* Redirect the error message to suppress the warning. */
	dbenv->set_msgfile(dbenv, msgfile);
	CuAssertTrue(ct, dbenv->open(dbenv, TEST_ENV, DB_JOINENV, 0666) == 0);
	CuAssertTrue(ct,
	    dbenv->get_timeout(dbenv, &timeout, DB_SET_TXN_TIMEOUT) == 0);
	CuAssertTrue(ct, timeout == 37);
	/* Direct the error message back to the standard output. */
	dbenv->set_msgfile(dbenv, NULL);
	/* Re-config the transaction timeout after opening the environment. */
	CuAssertTrue(ct,
	    dbenv->set_timeout(dbenv, 63, DB_SET_TXN_TIMEOUT) == 0);
	CuAssertTrue(ct,
	    dbenv->get_timeout(dbenv, &timeout, DB_SET_TXN_TIMEOUT) == 0);
	CuAssertTrue(ct, timeout == 63);
	return (0);
}
开发者ID:CompassHXM,项目名称:h-store,代码行数:45,代码来源:TestEnvConfig.c

示例2: TestSetLogMax

int TestSetLogMax(CuTest *ct) {
	DB_ENV *dbenv;
	struct context *info;
	FILE *msgfile;
	char *path;
	u_int32_t v;

	dbenv = NULL;
	if ((path = calloc(100, sizeof(char))) == NULL)
		return (ENOMEM);
	snprintf(path, 100, "%s%c%s", TEST_ENV, PATH_SEPARATOR[0], "msgfile");
	if ((msgfile = fopen(path, "w")) == NULL)
		return (EINVAL);
	info = ct->context;
	info->fp = msgfile;
	info->path = path;
	/* lg_max: reset at run-time. */
	ENV
	CuAssertTrue(ct, dbenv->set_lg_max(dbenv, 37 * 1024 * 1024) == 0);
	CuAssertTrue(ct, dbenv->open(dbenv,
	    TEST_ENV, DB_CREATE | DB_INIT_LOG, 0666) == 0);
	CuAssertTrue(ct, dbenv->get_lg_max(dbenv, &v) == 0);
	CuAssertTrue(ct, v == 37 * 1024 * 1024);
	ENV
	/* New log maximum size is ignored when joining the environment. */
	CuAssertTrue(ct, dbenv->set_lg_max(dbenv, 63 * 1024 * 1024) == 0);
	/* Redirect the error message to suppress the warning. */
	dbenv->set_msgfile(dbenv, msgfile);
	CuAssertTrue(ct, dbenv->open(dbenv, TEST_ENV, DB_JOINENV, 0666) == 0);
	CuAssertTrue(ct, dbenv->get_lg_max(dbenv, &v) == 0);
	CuAssertTrue(ct, v == 37 * 1024 * 1024);
	/* Direct the error message back to the standard output. */
	dbenv->set_msgfile(dbenv, NULL);
	/* Re-config the log maximum size after opening the environment. */
	CuAssertTrue(ct, dbenv->set_lg_max(dbenv, 63 * 1024 * 1024) == 0);
	CuAssertTrue(ct, dbenv->get_lg_max(dbenv, &v) == 0);
	CuAssertTrue(ct, v == 63 * 1024 * 1024);
	return (0);
}
开发者ID:CompassHXM,项目名称:h-store,代码行数:39,代码来源:TestEnvConfig.c


注:本文中的DB_ENV::set_msgfile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。