rename: update session pool and packet pool API names for clarity
This commit is contained in:
@@ -581,7 +581,7 @@ static struct session *session_manager_rte_new_tcp_session(struct session_manage
|
||||
}
|
||||
|
||||
enum flow_type type = (flags & TH_ACK) ? FLOW_TYPE_S2C : FLOW_TYPE_C2S;
|
||||
struct session *sess = session_pool_pop(sess_mgr_rte->sess_pool);
|
||||
struct session *sess = session_pool_acquire_sessoin(sess_mgr_rte->sess_pool);
|
||||
if (sess == NULL)
|
||||
{
|
||||
assert(0);
|
||||
@@ -598,7 +598,7 @@ static struct session *session_manager_rte_new_tcp_session(struct session_manage
|
||||
if (tcp_init(sess_mgr_rte, sess) == -1)
|
||||
{
|
||||
assert(0);
|
||||
session_pool_push(sess_mgr_rte->sess_pool, sess);
|
||||
session_pool_release_sessoin(sess_mgr_rte->sess_pool, sess);
|
||||
return NULL;
|
||||
}
|
||||
tcp_update(sess_mgr_rte, sess, type, tcp_layer);
|
||||
@@ -628,7 +628,7 @@ static struct session *session_manager_rte_new_udp_session(struct session_manage
|
||||
session_manager_rte_evicte_session(sess_mgr_rte, evic_sess, LRU_EVICT);
|
||||
}
|
||||
|
||||
struct session *sess = session_pool_pop(sess_mgr_rte->sess_pool);
|
||||
struct session *sess = session_pool_acquire_sessoin(sess_mgr_rte->sess_pool);
|
||||
if (sess == NULL)
|
||||
{
|
||||
assert(sess);
|
||||
@@ -933,7 +933,7 @@ void session_manager_rte_free_session(struct session_manager_rte *sess_mgr_rte,
|
||||
session_set_current_packet(sess, NULL);
|
||||
session_set_flow_type(sess, FLOW_TYPE_NONE);
|
||||
session_init(sess);
|
||||
session_pool_push(sess_mgr_rte->sess_pool, sess);
|
||||
session_pool_release_sessoin(sess_mgr_rte->sess_pool, sess);
|
||||
sess = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ void session_pool_free(struct session_pool *pool)
|
||||
}
|
||||
}
|
||||
|
||||
struct session *session_pool_pop(struct session_pool *pool)
|
||||
struct session *session_pool_acquire_sessoin(struct session_pool *pool)
|
||||
{
|
||||
if (pool == NULL)
|
||||
{
|
||||
@@ -71,7 +71,7 @@ struct session *session_pool_pop(struct session_pool *pool)
|
||||
return sess;
|
||||
}
|
||||
|
||||
void session_pool_push(struct session_pool *pool, struct session *sess)
|
||||
void session_pool_release_sessoin(struct session_pool *pool, struct session *sess)
|
||||
{
|
||||
if (pool == NULL || sess == NULL)
|
||||
{
|
||||
|
||||
@@ -11,8 +11,8 @@ struct session_pool;
|
||||
struct session_pool *session_pool_new(uint64_t capacity);
|
||||
void session_pool_free(struct session_pool *pool);
|
||||
|
||||
struct session *session_pool_pop(struct session_pool *pool);
|
||||
void session_pool_push(struct session_pool *pool, struct session *sess);
|
||||
struct session *session_pool_acquire_sessoin(struct session_pool *pool);
|
||||
void session_pool_release_sessoin(struct session_pool *pool, struct session *sess);
|
||||
const struct session *session_pool_get0(const struct session_pool *pool, uint64_t idx);
|
||||
|
||||
uint64_t session_pool_get_free_num(const struct session_pool *pool);
|
||||
|
||||
@@ -15,36 +15,36 @@ TEST(SESSION_POOL, POP_PUSH)
|
||||
EXPECT_TRUE(session_pool_get_used_num(sess_pool) == 0);
|
||||
|
||||
// pop
|
||||
sess1 = session_pool_pop(sess_pool);
|
||||
sess1 = session_pool_acquire_sessoin(sess_pool);
|
||||
EXPECT_TRUE(sess1 != NULL);
|
||||
EXPECT_TRUE(session_pool_get_free_num(sess_pool) == 2);
|
||||
EXPECT_TRUE(session_pool_get_used_num(sess_pool) == 1);
|
||||
|
||||
sess2 = session_pool_pop(sess_pool);
|
||||
sess2 = session_pool_acquire_sessoin(sess_pool);
|
||||
EXPECT_TRUE(sess2 != NULL);
|
||||
EXPECT_TRUE(session_pool_get_free_num(sess_pool) == 1);
|
||||
EXPECT_TRUE(session_pool_get_used_num(sess_pool) == 2);
|
||||
|
||||
sess3 = session_pool_pop(sess_pool);
|
||||
sess3 = session_pool_acquire_sessoin(sess_pool);
|
||||
EXPECT_TRUE(sess3 != NULL);
|
||||
EXPECT_TRUE(session_pool_get_free_num(sess_pool) == 0);
|
||||
EXPECT_TRUE(session_pool_get_used_num(sess_pool) == 3);
|
||||
|
||||
sess4 = session_pool_pop(sess_pool);
|
||||
sess4 = session_pool_acquire_sessoin(sess_pool);
|
||||
EXPECT_TRUE(sess4 == NULL);
|
||||
EXPECT_TRUE(session_pool_get_free_num(sess_pool) == 0);
|
||||
EXPECT_TRUE(session_pool_get_used_num(sess_pool) == 3);
|
||||
|
||||
// push
|
||||
session_pool_push(sess_pool, sess1);
|
||||
session_pool_release_sessoin(sess_pool, sess1);
|
||||
EXPECT_TRUE(session_pool_get_free_num(sess_pool) == 1);
|
||||
EXPECT_TRUE(session_pool_get_used_num(sess_pool) == 2);
|
||||
|
||||
session_pool_push(sess_pool, sess2);
|
||||
session_pool_release_sessoin(sess_pool, sess2);
|
||||
EXPECT_TRUE(session_pool_get_free_num(sess_pool) == 2);
|
||||
EXPECT_TRUE(session_pool_get_used_num(sess_pool) == 1);
|
||||
|
||||
session_pool_push(sess_pool, sess3);
|
||||
session_pool_release_sessoin(sess_pool, sess3);
|
||||
EXPECT_TRUE(session_pool_get_free_num(sess_pool) == 3);
|
||||
EXPECT_TRUE(session_pool_get_used_num(sess_pool) == 0);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ static void session_free_callback(struct session *sess, void *arg)
|
||||
if (sess)
|
||||
{
|
||||
struct session_pool *sess_pool = (struct session_pool *)arg;
|
||||
session_pool_push(sess_pool, sess);
|
||||
session_pool_release_sessoin(sess_pool, sess);
|
||||
sess = NULL;
|
||||
}
|
||||
}
|
||||
@@ -106,17 +106,17 @@ TEST(SESSION_TABLE, OP_SESSION)
|
||||
session_table_set_freecb(sess_table, session_free_callback, sess_pool);
|
||||
|
||||
// Add
|
||||
sess1 = session_pool_pop(sess_pool);
|
||||
sess1 = session_pool_acquire_sessoin(sess_pool);
|
||||
EXPECT_TRUE(sess1 != NULL);
|
||||
session_set_id(sess1, 1);
|
||||
session_set_tuple6(sess1, &sess1_tup6);
|
||||
|
||||
sess2 = session_pool_pop(sess_pool);
|
||||
sess2 = session_pool_acquire_sessoin(sess_pool);
|
||||
EXPECT_TRUE(sess2 != NULL);
|
||||
session_set_id(sess2, 2);
|
||||
session_set_tuple6(sess2, &sess2_tup6);
|
||||
|
||||
sess3 = session_pool_pop(sess_pool);
|
||||
sess3 = session_pool_acquire_sessoin(sess_pool);
|
||||
EXPECT_TRUE(sess3 != NULL);
|
||||
session_set_id(sess3, 3);
|
||||
session_set_tuple6(sess3, &sess3_tup6);
|
||||
@@ -200,21 +200,21 @@ TEST(SESSION_TABLE, FIND_OLDEST_NEWEST)
|
||||
|
||||
EXPECT_TRUE(session_table_find_lru(sess_table) == NULL);
|
||||
|
||||
sess1 = session_pool_pop(sess_pool);
|
||||
sess1 = session_pool_acquire_sessoin(sess_pool);
|
||||
EXPECT_TRUE(sess1 != NULL);
|
||||
session_set_id(sess1, 1);
|
||||
session_set_tuple6(sess1, &sess1_tup6);
|
||||
session_table_add(sess_table, sess1);
|
||||
EXPECT_TRUE(session_table_find_lru(sess_table) == sess1);
|
||||
|
||||
sess2 = session_pool_pop(sess_pool);
|
||||
sess2 = session_pool_acquire_sessoin(sess_pool);
|
||||
EXPECT_TRUE(sess2 != NULL);
|
||||
session_set_id(sess2, 2);
|
||||
session_set_tuple6(sess2, &sess2_tup6);
|
||||
session_table_add(sess_table, sess2);
|
||||
EXPECT_TRUE(session_table_find_lru(sess_table) == sess1);
|
||||
|
||||
sess3 = session_pool_pop(sess_pool);
|
||||
sess3 = session_pool_acquire_sessoin(sess_pool);
|
||||
EXPECT_TRUE(sess3 != NULL);
|
||||
session_set_id(sess3, 3);
|
||||
session_set_tuple6(sess3, &sess3_tup6);
|
||||
|
||||
Reference in New Issue
Block a user