update session finite state machine & add tcp init -> opening test case
This commit is contained in:
@@ -43,9 +43,34 @@ struct stellar_ctx
|
||||
} g_stellar_ctx = {
|
||||
.need_exit = 0,
|
||||
.max_worker_num = 1,
|
||||
.sess_mgr_cfg = {
|
||||
// max session number
|
||||
.max_tcp_session_num = 3,
|
||||
.max_udp_session_num = 3,
|
||||
|
||||
// TODO session manager config
|
||||
};
|
||||
// tcp timeout
|
||||
.tcp_timeout_init = 2,
|
||||
.tcp_timeout_handshake = 2,
|
||||
.tcp_timeout_data = 2,
|
||||
.tcp_timeout_half_closed = 2,
|
||||
.tcp_timeout_time_wait = 2,
|
||||
.tcp_timeout_discard = 2,
|
||||
|
||||
// udp timeout
|
||||
.udp_timeout_data = 1,
|
||||
|
||||
// tcp duplicate packet filter
|
||||
.tcp_dupkt_filter_enable = 1,
|
||||
.tcp_dupkt_filter_capacity = 1000,
|
||||
.tcp_dupkt_filter_timeout = 10,
|
||||
.tcp_dupkt_filter_error_rate = 0.0001,
|
||||
|
||||
// udp eviction filter
|
||||
.udp_eviction_filter_enable = 1,
|
||||
.udp_eviction_filter_capacity = 1000,
|
||||
.udp_eviction_filter_timeout = 10,
|
||||
.udp_eviction_filter_error_rate = 0.0001,
|
||||
}};
|
||||
|
||||
static int recv_packet(const char **data)
|
||||
{
|
||||
@@ -90,13 +115,13 @@ static void __session_dispatch(struct session *sess)
|
||||
printf("\n");
|
||||
printf("=> session dispatch: %p\n", sess);
|
||||
session_dump(sess);
|
||||
printf("<= session dispatch\n");
|
||||
printf("<= session dispatch\n\n");
|
||||
|
||||
session_set0_cur_pkt(sess, NULL);
|
||||
session_set_cur_dir(sess, SESSION_DIR_NONE);
|
||||
}
|
||||
|
||||
static void thread_ctx_init(struct stellar_ctx *ctx)
|
||||
static int thread_ctx_init(struct stellar_ctx *ctx)
|
||||
{
|
||||
for (uint16_t i = 0; i < ctx->max_worker_num; i++)
|
||||
{
|
||||
@@ -106,8 +131,14 @@ static void thread_ctx_init(struct stellar_ctx *ctx)
|
||||
thd_ctx->is_runing = 0;
|
||||
|
||||
thd_ctx->sess_mgr = session_manager_create(&ctx->sess_mgr_cfg);
|
||||
assert(thd_ctx->sess_mgr != NULL);
|
||||
if (thd_ctx->sess_mgr == NULL)
|
||||
{
|
||||
STELLAR_LOG_ERROR("unable to create session manager");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void thread_ctx_free(struct stellar_ctx *ctx)
|
||||
@@ -193,7 +224,11 @@ int main(int argc, char **argv)
|
||||
|
||||
timestamp_update();
|
||||
|
||||
thread_ctx_init(&g_stellar_ctx);
|
||||
if (thread_ctx_init(&g_stellar_ctx) != 0)
|
||||
{
|
||||
STELLAR_LOG_ERROR("unable to init thread context");
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < g_stellar_ctx.max_worker_num; i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user