Beispiel #1
0
static void StartEventHandler(KonohaContext *kctx, void *args)
{
	KNH_ASSERT(EVENTAPI eventContext == NULL);
	struct EventContext *eventContext = (struct EventContext *)PLATAPI malloc_i(sizeof(struct EventContext));
	bzero(eventContext, sizeof(struct EventContext));
	((KonohaFactory *)kctx->platApi)->EventModule.eventContext = eventContext;

	eventContext->safePointRef = (int *)&kctx->safepoint;

	eventContext->queue = (LocalQueue *)PLATAPI malloc_i(sizeof(LocalQueue));
	LocalQueue_Init(kctx, eventContext->queue);

	eventContext->httpContext = httpContext;

	pthread_mutex_init(&eventContext->lock, NULL);
	pthread_cond_init(&eventContext->cond, NULL);

	KNH_ASSERT(args != NULL);
	Ip *ip = (Ip *)args;
	struct event_base *base = event_base_new();
	struct evhttp *httpd = evhttp_new(base);
	KNH_ASSERT(evhttp_bind_socket(httpd, ip->host, ip->port) >= 0);
	evhttp_set_gencb(httpd, http_handler, (void *)eventContext);
	eventContext->base = base;
	eventContext->httpd = httpd;

	pthread_t t;
	pthread_create(&t, NULL, HttpEventListener, (void *)eventContext);
}
Beispiel #2
0
static void StartEventHandler(KonohaContext *kctx, void *args)
{
	KNH_ASSERT(PLATAPI eventContext == NULL);
	struct EventContext *eventContext = (struct EventContext *)PLATAPI malloc_i(sizeof(struct EventContext));
	((KonohaFactory *)kctx->platApi)->eventContext = eventContext;
	bzero(((KonohaFactory *)kctx->platApi)->eventContext, sizeof(struct EventContext));
	eventContext->queue = (LocalQueue *)PLATAPI malloc_i(sizeof(LocalQueue));
	LocalQueue_Init(kctx, eventContext->queue);
	SetSignal(kctx);
}