Пример #1
0
/* initialization before config loading */
void init_objects(void)
{
	aatree_init(&user_tree, user_node_cmp, NULL);
	aatree_init(&pam_user_tree, user_node_cmp, NULL);
	user_cache = slab_create("user_cache", sizeof(PgUser), 0, NULL, USUAL_ALLOC);
	db_cache = slab_create("db_cache", sizeof(PgDatabase), 0, NULL, USUAL_ALLOC);
	pool_cache = slab_create("pool_cache", sizeof(PgPool), 0, NULL, USUAL_ALLOC);

	if (!user_cache || !db_cache || !pool_cache)
		fatal("cannot create initial caches");
}
Пример #2
0
static int ml_aitvaras_init(lua_State* l) {
	checkargs(0, "aitvaras.init");

	invocation_cs = async_make_cs();
	mempool_init(&invocation_pool, sizeof(Invocation));

	cb_l = l;

	lua_getglobal(l, "aitvaras");	

	if(!_validate_conf(l)) 
		return luaL_error(l, "invalid configuration");

	const char* lobby_addr = _getstr(l, "lobby_addr");
	const char* server_addr = _getstr(l, "server_addr");
	char* enlist_req = alloca(strlen(lobby_addr) + strlen("/enlist") + 1);
	strcpy(enlist_req, lobby_addr);
	strcat(enlist_req, "/enlist");

	http_post(enlist_req, false, server_addr, NULL, _enlist_cb);

	aatree_init(&clients);

	const char* options[] = {
		"listening_ports", _getstr(l, "listening_port"),
		"document_root", _getstr(l, "document_root"),
		NULL
	};
	mg_ctx = mg_start(mg_callback, NULL, options);

	lua_pop(l, 1);

	return 0;
}
Пример #3
0
int main(void)
{
	struct AATree aatree;
	struct CBTree *cbtree;
	struct md5_ctx md5;
	struct Heap *heap;
	char buf[128];

	static_assert(sizeof(int) >= 4, "unsupported int size");

	heap = heap_create(heap_is_better, NULL, NULL);
	heap_top(heap);
	aatree_init(&aatree, NULL, NULL);
	cbtree = cbtree_create(NULL, NULL, NULL, NULL);
	cbtree_destroy(cbtree);
	daemonize(NULL, false);
	hash_lookup3("foo", 3);
	if (!event_init())
		log_debug("test");
	if (!parse_ini_file("foo", NULL, NULL))
		log_debug("test");
	log_stats("1");
	file_size("foo");
	md5_reset(&md5);
	strlcpy(buf, "foo", sizeof(buf));
	printf("xmalloc: %p\n", xmalloc(128));
	if (0) die("0");
	csrandom();
	tls_init();
	return 0;
}
Пример #4
0
/* initialization before config loading */
void init_objects(void)
{
	aatree_init(&user_tree, user_node_cmp, NULL);
	user_cache = slab_create("user_cache", sizeof(PgUser), 0, NULL, USUAL_ALLOC);
	db_cache = slab_create("db_cache", sizeof(PgDatabase), 0, NULL, USUAL_ALLOC);
	pool_cache = slab_create("pool_cache", sizeof(PgPool), 0, NULL, USUAL_ALLOC);
    cluster_cache = slab_create("cluster_cache", sizeof(PgCluster), 0, NULL, USUAL_ALLOC);

    if (regcomp(&sharding_command_regex, "^([a-zA-Z]+)[ ]+'([^']+)';(.*)", REG_EXTENDED)) {
        fatal("Could not compile regular expression.\n");
    };

	if (!user_cache || !db_cache || !pool_cache || !cluster_cache)
		fatal("cannot create initial caches");
}
Пример #5
0
int main(void)
{
	struct AATree aatree;
	struct CBTree *cbtree;
	struct md5_ctx md5;
	char buf[128];

	aatree_init(&aatree, NULL, NULL);
	cbtree = cbtree_create(NULL, NULL, NULL, USUAL_ALLOC);
	daemonize(NULL, NULL);
	hash_lookup3("foo", 3);
	if (!event_init())
		log_debug("test");
	if (!parse_ini_file("foo", NULL, NULL))
		log_debug("test");
	log_stats("1");
	file_size("foo");
	md5_reset(&md5);
	strlcpy(buf, "foo", sizeof(buf));
	printf("xmalloc: %p\n", xmalloc(128));
	if (0) die("0");
	return 0;
}