session manager not trigger event
This commit is contained in:
@@ -19,9 +19,6 @@ struct session_manager
|
||||
struct session_timer *sess_timer;
|
||||
struct session_queue *evicted_sess;
|
||||
|
||||
session_event_cb event_cb;
|
||||
void *arg;
|
||||
|
||||
// timeout config
|
||||
uint64_t timeout_toclosing;
|
||||
uint64_t timeout_toclosed;
|
||||
@@ -205,11 +202,6 @@ static void session_to_closed(struct session *sess, void *arg)
|
||||
struct session_manager *mgr = (struct session_manager *)arg;
|
||||
assert(mgr != NULL);
|
||||
|
||||
uint32_t event;
|
||||
while (session_pop_event(sess, &event))
|
||||
{
|
||||
}
|
||||
|
||||
update_counter_on_closed(mgr, sess);
|
||||
session_set_state(sess, SESSION_STATE_CLOSED);
|
||||
session_set0_cur_pkt(sess, NULL);
|
||||
@@ -231,7 +223,6 @@ static void session_to_closing(struct session *sess, void *arg)
|
||||
|
||||
update_counter_on_closing(mgr, sess);
|
||||
session_set_state(sess, SESSION_STATE_CLOSING);
|
||||
session_push_event(sess, SESSION_EVENT_CLOSING);
|
||||
session_manager_update_session_timer(mgr, sess, session_to_closed, mgr->timeout_toclosed);
|
||||
}
|
||||
|
||||
@@ -426,8 +417,6 @@ static int handle_tcp_new_session(struct session_manager *mgr, struct tuple6 *ke
|
||||
session_set_create_time(sess, timestamp_get_msec());
|
||||
update_session_base(sess, pkt, curr_dir);
|
||||
|
||||
session_push_event(sess, SESSION_EVENT_OPENING);
|
||||
session_push_event(sess, SESSION_EVENT_PACKET);
|
||||
session_manager_update_session_timer(mgr, sess, session_to_closing, mgr->timeout_toclosing);
|
||||
|
||||
return 0;
|
||||
@@ -458,8 +447,6 @@ static int handle_udp_new_session(struct session_manager *mgr, struct tuple6 *ke
|
||||
session_set_create_time(sess, timestamp_get_msec());
|
||||
update_session_base(sess, pkt, curr_dir);
|
||||
|
||||
session_push_event(sess, SESSION_EVENT_OPENING);
|
||||
session_push_event(sess, SESSION_EVENT_PACKET);
|
||||
session_manager_update_session_timer(mgr, sess, session_to_closing, mgr->timeout_toclosing);
|
||||
|
||||
return 0;
|
||||
@@ -476,8 +463,6 @@ static void handle_tcp_old_session(struct session_manager *mgr, struct tuple6 *k
|
||||
{
|
||||
update_counter_on_closing(mgr, sess);
|
||||
session_set_state(sess, SESSION_STATE_CLOSING);
|
||||
session_push_event(sess, SESSION_EVENT_PACKET);
|
||||
session_push_event(sess, SESSION_EVENT_CLOSING);
|
||||
session_manager_update_session_timer(mgr, sess, session_to_closed, mgr->timeout_toclosed);
|
||||
return;
|
||||
}
|
||||
@@ -486,7 +471,6 @@ static void handle_tcp_old_session(struct session_manager *mgr, struct tuple6 *k
|
||||
{
|
||||
update_counter_on_active(mgr, sess);
|
||||
session_set_state(sess, SESSION_STATE_ACTIVE);
|
||||
session_push_event(sess, SESSION_EVENT_PACKET);
|
||||
session_manager_update_session_timer(mgr, sess, session_to_closing, mgr->timeout_toclosing);
|
||||
return;
|
||||
}
|
||||
@@ -500,7 +484,6 @@ static void handle_udp_old_session(struct session_manager *mgr, struct tuple6 *k
|
||||
|
||||
update_counter_on_active(mgr, sess);
|
||||
session_set_state(sess, SESSION_STATE_ACTIVE);
|
||||
session_push_event(sess, SESSION_EVENT_PACKET);
|
||||
session_manager_update_session_timer(mgr, sess, session_to_closing, mgr->timeout_toclosing);
|
||||
}
|
||||
|
||||
@@ -609,12 +592,6 @@ void session_manager_destroy(struct session_manager *mgr)
|
||||
}
|
||||
}
|
||||
|
||||
void session_manager_set_session_eventcb(struct session_manager *mgr, session_event_cb cb, void *arg)
|
||||
{
|
||||
mgr->event_cb = cb;
|
||||
mgr->arg = arg;
|
||||
}
|
||||
|
||||
void session_manager_set_timeout_toclosing(struct session_manager *mgr, uint64_t timeout_ms)
|
||||
{
|
||||
mgr->timeout_toclosing = timeout_ms;
|
||||
@@ -655,7 +632,6 @@ struct session *session_manager_update(struct session_manager *mgr, const struct
|
||||
|
||||
update_counter_on_closing(mgr, unused_sess);
|
||||
session_set_state(unused_sess, SESSION_STATE_CLOSING);
|
||||
session_push_event(unused_sess, SESSION_EVENT_CLOSING);
|
||||
session_queue_push(mgr->evicted_sess, unused_sess);
|
||||
session_manager_update_session_timer(mgr, unused_sess, session_to_closed, mgr->timeout_toclosed);
|
||||
}
|
||||
@@ -702,34 +678,9 @@ struct session *session_manager_expire(struct session_manager *mgr)
|
||||
return sess;
|
||||
}
|
||||
|
||||
static void session_dispatch(struct session_manager *mgr, struct session *sess)
|
||||
struct session *session_manager_evicte(struct session_manager *mgr)
|
||||
{
|
||||
if (sess == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t event;
|
||||
while (session_pop_event(sess, &event))
|
||||
{
|
||||
SESSION_LOG_DEBUG("handle \"%s\" event on session %lu", session_event_tostring((enum session_event)event), session_get_id(sess));
|
||||
if (mgr->event_cb)
|
||||
{
|
||||
mgr->event_cb(sess, event, mgr->arg);
|
||||
}
|
||||
}
|
||||
session_set0_cur_pkt(sess, NULL);
|
||||
session_set_cur_dir(sess, SESSION_DIR_NONE);
|
||||
}
|
||||
|
||||
void session_manager_dispatch(struct session_manager *mgr, struct session *sess)
|
||||
{
|
||||
// Handle sessions that are ready to be processed
|
||||
session_dispatch(mgr, sess);
|
||||
|
||||
// Handle sessions that are evicted because the flow table is full
|
||||
struct session *evicted_sess = session_queue_pop(mgr->evicted_sess);
|
||||
session_dispatch(mgr, evicted_sess);
|
||||
return session_queue_pop(mgr->evicted_sess);
|
||||
}
|
||||
|
||||
uint64_t session_manager_get_sessions(struct session_manager *mgr, enum session_type type, enum session_state state)
|
||||
|
||||
Reference in New Issue
Block a user