Replace session queue with kernel list
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
#include "session_pool.h"
|
||||
#include "session_table.h"
|
||||
#include "session_timer.h"
|
||||
#include "session_queue.h"
|
||||
#include "session_manager.h"
|
||||
#include "session_private.h"
|
||||
#include "session_transition.h"
|
||||
@@ -40,7 +39,7 @@ struct session_manager
|
||||
struct session_table *tcp_sess_table;
|
||||
struct session_table *udp_sess_table;
|
||||
struct session_timer *sess_timer;
|
||||
struct session_queue *sess_evicte_queue;
|
||||
struct list_head evicte_queue;
|
||||
|
||||
struct duplicated_packet_filter *dup_pkt_filter;
|
||||
struct evicted_session_filter *evicte_sess_filter;
|
||||
@@ -467,7 +466,7 @@ static void session_manager_evicte_session(struct session_manager *mgr, struct s
|
||||
|
||||
session_timer_del(mgr->sess_timer, sess);
|
||||
session_set_closing_reason(sess, CLOSING_BY_EVICTED);
|
||||
session_queue_push(mgr->sess_evicte_queue, sess);
|
||||
list_add_tail(&sess->evicte, &mgr->evicte_queue);
|
||||
|
||||
switch (session_get_type(sess))
|
||||
{
|
||||
@@ -725,14 +724,14 @@ struct session_manager *session_manager_new(struct session_manager_options *opts
|
||||
mgr->tcp_sess_table = session_table_new();
|
||||
mgr->udp_sess_table = session_table_new();
|
||||
mgr->sess_timer = session_timer_new();
|
||||
mgr->sess_evicte_queue = session_queue_new();
|
||||
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->sess_evicte_queue == NULL || mgr->dup_pkt_filter == NULL || mgr->evicte_sess_filter == NULL)
|
||||
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)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
INIT_LIST_HEAD(&mgr->evicte_queue);
|
||||
session_filter_init();
|
||||
session_transition_init();
|
||||
tcp_flags_idx = session_get_ex_new_index("tcp_flags", NULL, NULL);
|
||||
@@ -750,8 +749,10 @@ void session_manager_free(struct session_manager *mgr)
|
||||
if (mgr)
|
||||
{
|
||||
// free all evicted session
|
||||
while (mgr->sess_evicte_queue && (sess = session_manager_get_evicted_session(mgr)))
|
||||
while (!list_empty(&mgr->evicte_queue))
|
||||
{
|
||||
sess = list_first_entry(&mgr->evicte_queue, struct session, evicte);
|
||||
list_del(&sess->evicte);
|
||||
session_manager_free_session(mgr, sess);
|
||||
}
|
||||
// free all udp session
|
||||
@@ -766,7 +767,6 @@ void session_manager_free(struct session_manager *mgr)
|
||||
}
|
||||
evicted_session_filter_free(mgr->evicte_sess_filter);
|
||||
duplicated_packet_filter_free(mgr->dup_pkt_filter);
|
||||
session_queue_free(mgr->sess_evicte_queue);
|
||||
session_timer_free(mgr->sess_timer);
|
||||
session_table_free(mgr->udp_sess_table);
|
||||
session_table_free(mgr->tcp_sess_table);
|
||||
@@ -919,7 +919,17 @@ struct session *session_manager_get_expired_session(struct session_manager *mgr,
|
||||
|
||||
struct session *session_manager_get_evicted_session(struct session_manager *mgr)
|
||||
{
|
||||
return session_queue_pop(mgr->sess_evicte_queue);
|
||||
struct session *sess = NULL;
|
||||
if (list_empty(&mgr->evicte_queue))
|
||||
{
|
||||
return sess;
|
||||
}
|
||||
else
|
||||
{
|
||||
sess = list_first_entry(&mgr->evicte_queue, struct session, evicte);
|
||||
list_del(&sess->evicte);
|
||||
return sess;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t session_manager_get_expire_interval(struct session_manager *mgr)
|
||||
|
||||
Reference in New Issue
Block a user