コード例 #1
0
ファイル: main.c プロジェクト: forhappy/intercept
static void
server_release_resources()
{
    tc_log_info(LOG_WARN, 0, "sig %d received", tc_over); 
    tc_log_info(LOG_NOTICE, 0, "release_resources begin");
    release_tunnel_resources();
    server_over();

    finally_release_obsolete_events();

    tc_event_loop_finish(&s_evt_loop);

    tc_destroy_pool(srv_settings.pool);
    tc_destroy_pool(srv_settings.cpool);
    tc_log_info(LOG_NOTICE, 0, "release_resources end except log file");
    tc_log_end();
}
コード例 #2
0
ファイル: tc_manager.c プロジェクト: 343829084/tcpcopy
void
tcp_copy_release_resources(void)
{
#if (TC_PCAP)
    int i;
#endif 
    tc_log_info(LOG_WARN, 0, "sig %d received", tc_over); 

    tc_output_stat();

    tc_dest_sess_table();

    check_resource_usage(NULL);
#if (TC_PLUGIN)
    if (clt_settings.plugin && clt_settings.plugin->exit_module) {
        clt_settings.plugin->exit_module(&clt_settings);
    }
#endif

    tc_event_loop_finish(&event_loop);
    tc_log_info(LOG_NOTICE, 0, "tc_event_loop_finish over");

#if (TC_DIGEST)
    tc_destroy_sha1();
    tc_destroy_digests();
#endif

#if (TC_PCAP)
    for (i = 0; i < clt_settings.devices.device_num; i++) {
        if (clt_settings.devices.device[i].pcap != NULL) {
            pcap_close(clt_settings.devices.device[i].pcap);
            clt_settings.devices.device[i].pcap = NULL;
        }
    }
#endif

#if (TC_OFFLINE)
    if (clt_settings.pcap != NULL) {
        pcap_close(clt_settings.pcap);
        clt_settings.pcap = NULL;
    }
#endif

    if (tc_raw_socket_out > 0) {
        tc_socket_close(tc_raw_socket_out);
        tc_raw_socket_out = TC_INVALID_SOCK;
    }

#if (TC_PCAP_SND)
    tc_pcap_over();
#endif
    tc_destroy_pool(clt_settings.pool);

    tc_log_end();
}
コード例 #3
0
static void 
exit_mysql_module() 
{
    tc_log_info(LOG_INFO, 0, "call exit_mysql_module");
    remove_obsolete_resources(1);
    if (ctx.pool != NULL) {
        tc_destroy_pool(ctx.pool);
        ctx.table = NULL;
        ctx.pool = NULL;
    }
}
コード例 #4
0
ファイル: tc_delay.c プロジェクト: barrysun/intercept
static void
tc_delay_del_obs(tc_event_timer_t *evt)
{
    delay_sess_t *s;

    s = evt->data;
    if (s != NULL) {
        if (!hash_del(table, s->pool, s->key)) {
            tc_log_info(LOG_WARN, 0, "no hash item for port transfer");
        }

        msg_ls_destr_cnt++;
        tc_destroy_pool(s->pool);
    } else {
        tc_log_info(LOG_ERR, 0, "delay session already deleted:%llu", evt);
    }
}
コード例 #5
0
ファイル: tc_event.c プロジェクト: 343829084/tcpburn
int tc_event_loop_finish(tc_event_loop_t *loop)
{
    tc_event_actions_t *actions;

    actions = loop->actions;

    if (actions != NULL) {
        /* destroy io module */
        actions->destroy(loop);

        loop->actions = NULL;
    }

    if (loop->pool) {
        tc_destroy_pool(loop->pool);
        loop->pool = NULL;
    }

    return TC_EVENT_OK;
}
コード例 #6
0
ファイル: main.c プロジェクト: forhappy/intercept
int
main(int argc, char **argv)
{
    int ret;

    settings_init();

    if (set_signal_handler(signals) == -1) {
        return -1;
    }

    tc_time_init();

    if (read_args(argc, argv) == -1) {
        return -1;
    }

    if (tc_log_init(srv_settings.log_path) == -1) {
        return -1;
    }

    srv_settings.pool = tc_create_pool(TC_DEFAULT_POOL_SIZE, 0);
    if (srv_settings.pool == NULL) {
        return -1;
    }
    srv_settings.cpool = tc_create_pool(TC_DEFAULT_POOL_SIZE, 0);
    if (srv_settings.cpool == NULL) {
        tc_destroy_pool(srv_settings.pool);
        return -1;
    }

    ret = tc_event_loop_init(&s_evt_loop, MAX_FD_NUM);
    if (ret == TC_EVENT_ERROR) {
        tc_log_info(LOG_ERR, 0, "event loop init failed");
        return -1;
    }

    /* output debug info */
    output_for_debug();
    if (set_details() == -1) {
        return -1;
    }

    tc_event_timer_init();

    if (server_init(&s_evt_loop, srv_settings.bound_ip, srv_settings.port) == 
            TC_ERR)
    {
        return -1;
    }

#if (TC_COMBINED)
    tc_event_add_timer(s_evt_loop.pool, CHECK_INTERVAL, NULL, server_push);
#endif
    tc_event_add_timer(s_evt_loop.pool, OUTPUT_INTERVAL, NULL, server_stat);

    /* run now */
    tc_event_proc_cycle(&s_evt_loop);

    server_release_resources();

    return 0;
}