refactor(session manager): replace dep/list/list.h with sys/queue.h

This commit is contained in:
luwenpeng
2024-09-13 15:44:46 +08:00
parent 244cc88ace
commit e0ecee73b3
5 changed files with 42 additions and 50 deletions

View File

@@ -26,7 +26,7 @@ struct snowflake
struct session_manager
{
struct list_head evicte_queue;
struct session_list evicte_list;
struct session_pool *sess_pool;
struct session_timer *sess_timer;
struct session_table *tcp_sess_table;
@@ -550,7 +550,7 @@ static void session_manager_evicte_session(struct session_manager *mgr, struct s
}
}
session_timer_del(mgr->sess_timer, sess);
list_add_tail(&sess->evicte, &mgr->evicte_queue);
TAILQ_INSERT_TAIL(&mgr->evicte_list, sess, evicte_tqe);
switch (session_get_type(sess))
{
@@ -977,7 +977,7 @@ struct session_manager *session_manager_new(const struct session_manager_config
goto error;
}
INIT_LIST_HEAD(&mgr->evicte_queue);
TAILQ_INIT(&mgr->evicte_list);
session_transition_init();
mgr->now_ms = now_ms;
mgr->last_clean_expired_sess_ts = now_ms;
@@ -995,10 +995,9 @@ void session_manager_free(struct session_manager *mgr)
if (mgr)
{
// free all evicted session
while (!list_empty(&mgr->evicte_queue))
while ((sess = TAILQ_FIRST(&mgr->evicte_list)))
{
sess = list_first_entry(&mgr->evicte_queue, struct session, evicte);
list_del(&sess->evicte);
TAILQ_REMOVE(&mgr->evicte_list, sess, evicte_tqe);
session_manager_free_session(mgr, sess);
}
// free all udp session
@@ -1234,16 +1233,12 @@ struct session *session_manager_get_expired_session(struct session_manager *mgr,
struct session *session_manager_get_evicted_session(struct session_manager *mgr)
{
if (list_empty(&mgr->evicte_queue))
struct session *sess = TAILQ_FIRST(&mgr->evicte_list);
if (sess)
{
return NULL;
}
else
{
struct session *sess = list_first_entry(&mgr->evicte_queue, struct session, evicte);
list_del(&sess->evicte);
return sess;
TAILQ_REMOVE(&mgr->evicte_list, sess, evicte_tqe);
}
return sess;
}
// array_size at least EVICTE_SESSION_BURST, suggest 2 * EVICTE_SESSION_BURST