예제 #1
0
static void
frontend_cb(evhtp_request_t * req, void * arg) {
    int * aux;
    int   thr;

    aux = (int *)evthr_get_aux(req->conn->thread);
    thr = *aux;

    printf("  Received frontend request on thread %d... ", thr);

    /* Pause the frontend request while we run the backend requests. */
    evhtp_request_pause(req);

    make_request(evthr_get_base(req->conn->thread),
                 req->conn->thread,
                 "127.0.0.1", 80,
                 req->uri->path->full,
                 req->headers_in, backend_cb, req);

    printf("Ok.\n");
}
static void
app_init_thread(evhtp_t *htp, evthr_t *thread, void *arg) {
    struct tq_listener_s *listener;
    struct tq_service_s *service;
    struct app        *app;

    service     = (struct tq_service_s *)arg;
    listener    = service->parent_listener;
    app         = calloc(sizeof(struct app), 1); /* Also resets thread_call_count */

    app->parent = listener->app_parent;
    app->evbase = evthr_get_base(thread);
    app->evhtp  = htp;

    listener->app_thr = app;

    app->thread_number = app->parent->threads_online;
    app->parent->threads_online++;

    evthr_set_aux(thread, service);
}