Update session timer
This commit is contained in:
@@ -406,13 +406,6 @@ static int session_filter_run(struct session_manager *mgr, enum filter_stage sta
|
||||
* Session Manager
|
||||
******************************************************************************/
|
||||
|
||||
static void timer_update(struct session_timer *timer, struct session *sess, uint64_t abs_timeout)
|
||||
{
|
||||
session_timer_del(timer, sess);
|
||||
session_set_expirecb(sess, NULL, NULL, abs_timeout);
|
||||
session_timer_add(timer, sess);
|
||||
}
|
||||
|
||||
static void session_update(struct session *sess, enum session_state next_state, const struct packet *pkt, const struct tuple6 *key, enum session_dir dir, uint64_t now)
|
||||
{
|
||||
if (session_get_state(sess) == SESSION_STATE_INIT)
|
||||
@@ -532,7 +525,7 @@ static struct session *session_manager_new_tcp_session(struct session_manager *m
|
||||
session_insert_tcp_payload(sess, tcp_hdr_get_seq(hdr), tcp_layer->pld_ptr, tcp_layer->pld_len, now);
|
||||
|
||||
uint64_t timeout = (flags & TH_ACK) ? mgr->tcp_handshake_timeout : mgr->tcp_init_timeout;
|
||||
timer_update(mgr->sess_timer, sess, now + timeout);
|
||||
session_timer_update(mgr->sess_timer, sess, now + timeout);
|
||||
session_table_add(mgr->tcp_sess_table, key, sess);
|
||||
|
||||
duplicated_packet_filter_add(mgr->dup_pkt_filter, pkt, now);
|
||||
@@ -565,7 +558,7 @@ static struct session *session_manager_new_udp_session(struct session_manager *m
|
||||
session_transition_log(sess, SESSION_STATE_INIT, next_state, UDP_DATA);
|
||||
session_stat_inc(&mgr->stat.udp_sess, next_state);
|
||||
|
||||
timer_update(mgr->sess_timer, sess, now + mgr->udp_data_timeout);
|
||||
session_timer_update(mgr->sess_timer, sess, now + mgr->udp_data_timeout);
|
||||
session_table_add(mgr->udp_sess_table, key, sess);
|
||||
|
||||
return sess;
|
||||
@@ -630,7 +623,7 @@ static int session_manager_update_tcp_session(struct session_manager *mgr, struc
|
||||
case SESSION_STATE_CLOSING:
|
||||
if (flags & TH_FIN)
|
||||
{
|
||||
timeout = (history & C2S_FIN_RECV && history & S2C_FIN_RECV) ? mgr->tcp_half_closed_timeout : mgr->tcp_time_wait_timeout;
|
||||
timeout = (history & C2S_FIN_RECV && history & S2C_FIN_RECV) ? mgr->tcp_time_wait_timeout : mgr->tcp_half_closed_timeout;
|
||||
}
|
||||
else if (flags & TH_RST)
|
||||
{
|
||||
@@ -648,7 +641,7 @@ static int session_manager_update_tcp_session(struct session_manager *mgr, struc
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
timer_update(mgr->sess_timer, sess, now + timeout);
|
||||
session_timer_update(mgr->sess_timer, sess, now + timeout);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -661,7 +654,7 @@ static int session_manager_update_udp_session(struct session_manager *mgr, struc
|
||||
session_update(sess, next_state, pkt, key, dir, now);
|
||||
session_transition_log(sess, curr_state, next_state, UDP_DATA);
|
||||
session_stat_update(mgr, sess, curr_state, next_state);
|
||||
timer_update(mgr->sess_timer, sess, now + mgr->udp_data_timeout);
|
||||
session_timer_update(mgr->sess_timer, sess, now + mgr->udp_data_timeout);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -723,7 +716,7 @@ struct session_manager *session_manager_new(struct session_manager_options *opts
|
||||
mgr->sess_pool = session_pool_new(mgr->max_tcp_session_num + mgr->max_udp_session_num);
|
||||
mgr->tcp_sess_table = session_table_new();
|
||||
mgr->udp_sess_table = session_table_new();
|
||||
mgr->sess_timer = session_timer_new();
|
||||
mgr->sess_timer = session_timer_new(now);
|
||||
mgr->dup_pkt_filter = duplicated_packet_filter_new(&duplicated_packet_filter_opts, now);
|
||||
mgr->evicte_sess_filter = evicted_session_filter_new(&evicted_session_filter_opts, now);
|
||||
if (mgr->sess_pool == NULL || mgr->tcp_sess_table == NULL || mgr->udp_sess_table == NULL || mgr->sess_timer == NULL || mgr->dup_pkt_filter == NULL || mgr->evicte_sess_filter == NULL)
|
||||
@@ -909,7 +902,7 @@ struct session *session_manager_get_expired_session(struct session_manager *mgr,
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
timer_update(mgr->sess_timer, sess, now + timeout);
|
||||
session_timer_update(mgr->sess_timer, sess, now + timeout);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user