Пример #1
0
/* added by Wakamori */
static void opt_logcached(int mode, const char *optstr)
{
#if defined(HAVE_LIBMEMCACHED)
	knh_syslog = memcached_syslog;
	knh_vsyslog = memcached_vsyslog;

	kbytes_t host_port = B(optstr);
	kbytes_t host = knh_bytes_head(host_port, ':');
	kint_t port;
	if (!knh_bytes_parseint(knh_bytes_next(host_port, ':'), &port)) {
		KNH_DIE("konoha: invalid arguments.");
	}
	memc = memcached_create(NULL);
	char tmp = host.buf[host.len];
	host.buf[host.len] = '\0';

	memcached_return rc;
	memcached_server_list_st servers;
	servers = memcached_server_list_append(NULL, host.text, port, &rc);
	if (rc != MEMCACHED_SUCCESS) {
		KNH_DIE("konoha: cannot append a memcached server.");
	}
	host.buf[host.len] = tmp;
	rc = memcached_server_push(memc, servers);
	if (rc != MEMCACHED_SUCCESS) {
		KNH_DIE("konoha: cannot push a memcached server.");
	}
	memcached_server_list_free(servers);
#else
	KNH_DIE("konoha: memcached library is not installed.");
#endif /* defined(HAVE_LIBMEMCACHED) */
}
Пример #2
0
ksymbol_t knh_addname(CTX, kString *s, knh_Fdictset f)
{
	size_t n = knh_Map_size(_ctx->share->symbolDictCaseSet);
	if(unlikely(!(n+1 < MN_SETTER))) {  /* Integer overflowed */
		KNH_DIE("too many names, last nameid(fn)=%d < %d", (int)(n+1), (int)MN_SETTER);
	}
	kArray_add(ctx->share->symbolList, s);
	f(_ctx, ctx->share->symbolDictCaseSet, s, n + 1);
	return (ksymbol_t)(n);
}
Пример #3
0
static void opt_a(int mode, const char *optstr)
{
	isAudit = (mode > 0) ? mode : 1;
#if defined(K_USING_SYSLOG)
//	((knh_ServiceSPI_t*)ctx->spi)->syslogspi = "syslog";
//	((knh_ServiceSPI_t*)ctx->spi)->syslog    = syslog;
//	((knh_ServiceSPI_t*)ctx->spi)->vsyslog   = vsyslog;
	knh_syslog = syslog;
	knh_vsyslog = vsyslog;
	openlog("konoha", LOG_PID, LOG_LOCAL7);
#else
	KNH_DIE("konoha: no available logging system.");
#endif
}