コード例 #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
ファイル: core.c プロジェクト: adityamarella/pelikan
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
ファイル: server.c プロジェクト: sagar0/pelikan
void
core_server_setup(server_options_st *options, server_metrics_st *metrics)
{
    struct tcp_conn *c;
    char *host = SERVER_HOST;
    char *port = SERVER_PORT;
    int timeout = SERVER_TIMEOUT;
    int nevent = SERVER_NEVENT;

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

    if (server_init) {
        log_warn("server has already been setup, re-creating");
        core_server_teardown();
    }

    server_metrics = metrics;

    if (options != NULL) {
        host = option_str(&options->server_host);
        port = option_str(&options->server_port);
        timeout = option_uint(&options->server_timeout);
        nevent = option_uint(&options->server_nevent);
    }

    ctx->timeout = timeout;
    ctx->evb = event_base_create(nevent, _server_event);
    if (ctx->evb == NULL) {
        log_crit("failed to setup server core; could not create event_base");
        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;

    /**
     * Here we give server socket a buf_sock purely because it is difficult to
     * write code in the core event loop that would accommodate different types
     * of structs at the moment. However, this doesn't have to be the case in
     * the future. We can choose to wrap different types in a common header-
     * one that contains a type field and a pointer to the actual struct, or
     * define common fields, like how posix sockaddr structs are used.
     */
    server_sock = buf_sock_borrow();
    if (server_sock == NULL) {
        log_crit("failed to setup server core; could not get buf_sock");
        goto error;
    }

    server_sock->hdl = hdl;
    if (CC_OK != getaddr(&server_ai, host, port)) {
        log_crit("failed to resolve address for admin host & port");
        goto error;
    }

    c = server_sock->ch;
    if (!hdl->open(server_ai, c)) {
        log_crit("server connection setup failed");
        goto error;
    }
    c->level = CHANNEL_META;

    event_add_read(ctx->evb, hdl->rid(c), server_sock);

    server_init = true;

    return;

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