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); }
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); }
static void kFileStatus_Init(KonohaContext *kctx, kObject *o, void *conf) { kFileStatus *stat = (kFileStatus *)o; if(conf != NULL) { stat->stat = (struct stat *)PLATAPI malloc_i(sizeof(struct stat)); memcpy(stat->stat, conf, sizeof(struct stat)); } else { stat->stat = NULL; } }
static void LocalQueue_Init(KonohaContext *kctx, struct LocalQueue *queue) { queue->front = 0; queue->last = 0; queue->list = (RawEvent**)PLATAPI malloc_i(sizeof(RawEvent) * QUEUESIZE); }