remove session_manager_subscribe_xxx() API; convert session closing events to pseudo packets
when a session is closed, use the packet manager to create a pseudo packet,
set the session to be closed as packet Exdata, and schedule it to the packet forwarding stage.
when the pseudo packet free, the session will be free.
This commit is contained in:
@@ -34,7 +34,6 @@ struct session_manager_rte
|
||||
|
||||
// only used for session_set_discard() or session_manager_rte_record_duplicated_packet(), because the function is called by plugin and has no time input.
|
||||
uint64_t now_ms;
|
||||
uint64_t last_clean_expired_sess_ts;
|
||||
struct snowflake *sf;
|
||||
};
|
||||
|
||||
@@ -810,7 +809,6 @@ struct session_manager_rte *session_manager_rte_new(const struct session_manager
|
||||
TAILQ_INIT(&sess_mgr_rte->evc_list);
|
||||
session_transition_init();
|
||||
sess_mgr_rte->now_ms = now_ms;
|
||||
sess_mgr_rte->last_clean_expired_sess_ts = now_ms;
|
||||
|
||||
return sess_mgr_rte;
|
||||
|
||||
@@ -1064,55 +1062,6 @@ struct session *session_manager_rte_get_evicted_session(struct session_manager_r
|
||||
return sess;
|
||||
}
|
||||
|
||||
uint64_t session_manager_rte_clean_session(struct session_manager_rte *sess_mgr_rte, uint64_t now_ms, struct session *cleaned_sess_ptr[], uint64_t array_size)
|
||||
{
|
||||
sess_mgr_rte->now_ms = now_ms;
|
||||
struct session *sess = NULL;
|
||||
uint64_t cleaned_sess_num = 0;
|
||||
uint64_t expired_sess_num = 0;
|
||||
|
||||
uint8_t expired_sess_canbe_clean = 0;
|
||||
if (now_ms - sess_mgr_rte->last_clean_expired_sess_ts >= sess_mgr_rte->cfg.expire_period_ms ||
|
||||
now_ms == UINT64_MAX)
|
||||
{
|
||||
expired_sess_canbe_clean = 1;
|
||||
}
|
||||
|
||||
for (uint64_t i = 0; i < array_size; i++)
|
||||
{
|
||||
// frist clean evicted session
|
||||
sess = session_manager_rte_get_evicted_session(sess_mgr_rte);
|
||||
if (sess)
|
||||
{
|
||||
cleaned_sess_ptr[cleaned_sess_num++] = sess;
|
||||
}
|
||||
// then clean expired session
|
||||
else
|
||||
{
|
||||
if (expired_sess_canbe_clean && expired_sess_num < sess_mgr_rte->cfg.expire_batch_max)
|
||||
{
|
||||
sess_mgr_rte->last_clean_expired_sess_ts = now_ms;
|
||||
sess = session_manager_rte_get_expired_session(sess_mgr_rte, now_ms);
|
||||
if (sess)
|
||||
{
|
||||
cleaned_sess_ptr[cleaned_sess_num++] = sess;
|
||||
expired_sess_num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cleaned_sess_num;
|
||||
}
|
||||
|
||||
uint64_t session_manager_rte_scan_session(struct session_manager_rte *sess_mgr_rte, const struct session_filter *filter, uint64_t mached_sess_id[], uint64_t array_size)
|
||||
{
|
||||
uint64_t capacity = 0;
|
||||
|
||||
Reference in New Issue
Block a user