コード例 #1
0
ファイル: tdb_htrie.c プロジェクト: postfix/tempesta
void
tdb_htrie_test_fixsz(const char *fname)
{
	int r __attribute__((unused));
	int t, fd;
	char *addr;
	TdbHdr *dbh;
	struct timeval tv0, tv1;
	pthread_t thr[THR_N];

	printf("\n----------- Fixed size records test -------------\n");

	addr = tdb_htrie_open(TDB_MAP_ADDR1, fname, TDB_FSF_SZ, &fd);
	dbh = tdb_htrie_init(addr, TDB_FSF_SZ, sizeof(ints[0]));
	if (!dbh)
		TDB_ERR("cannot initialize htrie for ints");

	r = gettimeofday(&tv0, NULL);
	assert(!r);

	for (t = 0; t < THR_N; ++t)
		if (spawn_thread(thr + t, fixsz_thr_f, dbh))
			perror("cannot spawn fixsz thread");
	for (t = 0; t < THR_N; ++t)
		pthread_join(thr[t], NULL);

	r = gettimeofday(&tv1, NULL);
	assert(!r);

	printf("tdb htrie ints test: time=%lums\n",
		tv_to_ms(&tv1) - tv_to_ms(&tv0));

	tdb_htrie_exit(dbh);
	tdb_htrie_pure_close(addr, TDB_FSF_SZ, fd);

	printf("\n	**** Fixed size records test reopen ****\n");

	addr = tdb_htrie_open(TDB_MAP_ADDR2, fname, TDB_FSF_SZ, &fd);
	dbh = tdb_htrie_init(addr, TDB_FSF_SZ, sizeof(ints[0]));
	if (!dbh)
		TDB_ERR("cannot initialize htrie for ints");

	lookup_fixsz_records(dbh);

	tdb_htrie_exit(dbh);
	tdb_htrie_pure_close(addr, TDB_FSF_SZ, fd);
}
コード例 #2
0
ファイル: main.c プロジェクト: yulintao/tempesta
static void
__do_close_table(TDB *db)
{
	/* Unmapping can be done from process context. */
	tdb_file_close(db);

	tdb_htrie_exit(db->hdr);

	TDB_LOG("Close table '%s'\n", db->tbl_name);

	kfree(db);
}