Пример #1
0
/*
 * pool_init creates a named pool and opens connections to the database
 */
static TDS_POOL *
pool_init(const char *name)
{
	TDS_POOL *pool;
	char *err = NULL;

	/* initialize the pool */

	pool = (TDS_POOL *) calloc(1, sizeof(TDS_POOL));

	pool->event_fd = INVALID_SOCKET;
	if (tds_mutex_init(&pool->events_mtx)) {
		fprintf(stderr, "Error initializing pool mutex\n");
		exit(EXIT_FAILURE);
	}

	/* FIXME -- read this from the conf file */
	if (!pool_read_conf_file(name, pool, &err)) {
		fprintf(stderr, "Configuration for pool ``%s'' not found.\n", name);
		exit(EXIT_FAILURE);
	}

	if (err) {
		fprintf(stderr, "%s\n", err);
		exit(EXIT_FAILURE);
	}
	check_field(name, pool->user,   "user");
	check_field(name, pool->server, "server");
	check_field(name, pool->port,   "port");

	if (pool->max_open_conn < pool->min_open_conn) {
		fprintf(stderr, "Max connections less than minimum\n");
		exit(EXIT_FAILURE);
	}

	pool->name = strdup(name);

	pool_open_logfile(pool);

	pool_mbr_init(pool);
	pool_user_init(pool);

	pool_socket_init(pool);

	return pool;
}
Пример #2
0
/*
 * pool_init creates a named pool and opens connections to the database
 */
static TDS_POOL *
pool_init(char *name)
{
	TDS_POOL *pool;

	/* initialize the pool */

	pool = (TDS_POOL *) calloc(1, sizeof(TDS_POOL));
	/* FIXME -- read this from the conf file */
	if (!pool_read_conf_file(name, pool)) {
		fprintf(stderr, "Configuration for pool ``%s'' not found.\n", name);
		exit(EXIT_FAILURE);
	}
	pool->num_members = pool->max_open_conn;

	pool->name = strdup(name);

	pool_mbr_init(pool);
	pool_user_init(pool);

	return pool;
}