예제 #1
0
파일: main.c 프로젝트: huayl/pelikan
static void
teardown(void)
{
    core_worker_teardown();
    core_server_teardown();
    core_admin_teardown();
    admin_process_teardown();
    process_teardown();
    slab_teardown();
    compose_teardown();
    parse_teardown();
    response_teardown();
    request_teardown();
    procinfo_teardown();
    time_teardown();

    timing_wheel_teardown();
    tcp_teardown();
    sockio_teardown();
    event_teardown();
    dbuf_teardown();
    buf_teardown();

    debug_teardown();
    log_teardown();
}
예제 #2
0
void
core_teardown(void)
{
    core_admin_teardown();
    core_worker_teardown();
    core_server_teardown();

    ring_array_destroy(conn_arr);
    pipe_conn_destroy(&pipe_c);

    core_init = false;
}
예제 #3
0
파일: admin.c 프로젝트: sagar0/pelikan
void
core_admin_setup(admin_options_st *options)
{
    struct tcp_conn *c;
    struct timeout tick;
    char *host = ADMIN_HOST;
    char *port = ADMIN_PORT;
    int timeout = ADMIN_TIMEOUT;
    int nevent = ADMIN_NEVENT;
    uint64_t tick_ms = ADMIN_TW_TICK;
    size_t cap = ADMIN_TW_CAP;
    size_t ntick = ADMIN_TW_NTICK;

    log_info("set up the %s module", ADMIN_MODULE_NAME);

    if (admin_init) {
        log_warn("admin has already been setup, re-creating");
        core_admin_teardown();
    }

    if (options != NULL) {
        host = option_str(&options->admin_host);
        port = option_str(&options->admin_port);
        timeout = option_uint(&options->admin_timeout);
        nevent = option_uint(&options->admin_nevent);
        tick_ms = option_uint(&options->admin_tw_tick);
        cap = option_uint(&options->admin_tw_cap);
        ntick = option_uint(&options->admin_tw_ntick);
    }

    ctx->timeout = timeout;
    ctx->evb = event_base_create(nevent, _admin_event);
    if (ctx->evb == NULL) {
        log_crit("failed to set up admin thread; could not create event "
                 "base for control plane");
        goto error;
    }

    hdl->accept = (channel_accept_fn)tcp_accept;
    hdl->reject = (channel_reject_fn)tcp_reject;
    hdl->open = (channel_open_fn)tcp_listen;
    hdl->term = (channel_term_fn)tcp_close;
    hdl->recv = (channel_recv_fn)tcp_recv;
    hdl->send = (channel_send_fn)tcp_send;
    hdl->rid = (channel_id_fn)tcp_read_id;
    hdl->wid = (channel_id_fn)tcp_write_id;

    admin_sock = buf_sock_borrow();
    if (admin_sock == NULL) {
        log_crit("failed to set up admin thread; could not get buf_sock");
        goto error;
    }

    admin_sock->hdl = hdl;

    if (CC_OK != getaddr(&admin_ai, host, port)) {
        log_crit("failed to resolve address for admin host & port");
        goto error;
    }
    c = admin_sock->ch;
    if (!hdl->open(admin_ai, c)) {
        log_crit("admin connection setup failed");
        goto error;
    }
    c->level = CHANNEL_META;
    event_add_read(ctx->evb, hdl->rid(c), admin_sock);

    timeout_set_ms(&tick, tick_ms);
    tw = timing_wheel_create(&tick, cap, ntick);
    if (tw == NULL) {
        log_crit("create timing wheel failed");
        goto error;
    }
    timing_wheel_start(tw);

    admin_init = true;

    return;

error:
    core_admin_teardown();
    exit(EX_CONFIG);
}