summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2024-11-08 19:16:06 +0800
committerluwenpeng <[email protected]>2024-11-08 19:17:23 +0800
commit8349a631e1a2542e3e7075b9c8f00e7d57337888 (patch)
tree8d62f67fc3ea85fd2f7868b8353fab6fc869bffd
parentd0a868591470a4a9d71a65a5d540058e72c8d92c (diff)
rename: update session pool and packet pool API names for clarity
-rw-r--r--infra/packet_io/mars_io.c8
-rw-r--r--infra/packet_io/pcap_io.c8
-rw-r--r--infra/packet_manager/packet_pool.c4
-rw-r--r--infra/packet_manager/packet_pool.h4
-rw-r--r--infra/packet_manager/test/gtest_packet_pool.cpp16
-rw-r--r--infra/session_manager/session_manager_rte.c8
-rw-r--r--infra/session_manager/session_pool.c4
-rw-r--r--infra/session_manager/session_pool.h4
-rw-r--r--infra/session_manager/test/gtest_session_pool.cpp14
-rw-r--r--infra/session_manager/test/gtest_session_table.cpp14
10 files changed, 42 insertions, 42 deletions
diff --git a/infra/packet_io/mars_io.c b/infra/packet_io/mars_io.c
index 6ce3de4..0dcec91 100644
--- a/infra/packet_io/mars_io.c
+++ b/infra/packet_io/mars_io.c
@@ -243,7 +243,7 @@ static void origin_free_cb(struct packet *pkt, void *args)
stat->bytes_user_freed += packet_get_raw_len(pkt);
marsio_buff_free(mars_io->mr_ins, &mbuff, 1, 0, origin->thr_idx);
- packet_pool_push(pool, pkt);
+ packet_pool_release_packet(pool, pkt);
}
/******************************************************************************
@@ -408,7 +408,7 @@ int mars_io_recv(void *handle, uint16_t thr_idx, struct packet *pkts[], int nr_p
}
else
{
- pkt = packet_pool_pop(pool);
+ pkt = packet_pool_acquire_packet(pool);
assert(pkt != NULL);
struct packet_origin origin = {
.type = ORIGIN_TYPE_MR,
@@ -449,7 +449,7 @@ void mars_io_send(void *handle, uint16_t thr_idx, struct packet *pkts[], int nr_
mbuff = (marsio_buff_t *)origin->ctx;
copy_metadata_to_mbuff(pkt, mbuff);
marsio_send_burst(mars_io->mr_path, thr_idx, &mbuff, 1);
- packet_pool_push(mars_io->pool[thr_idx], pkt);
+ packet_pool_release_packet(mars_io->pool[thr_idx], pkt);
}
else
{
@@ -501,7 +501,7 @@ void mars_io_drop(void *handle, uint16_t thr_idx, struct packet *pkts[], int nr_
{
mbuff = (marsio_buff_t *)origin->ctx;
marsio_buff_free(mars_io->mr_ins, &mbuff, 1, 0, thr_idx);
- packet_pool_push(mars_io->pool[thr_idx], pkt);
+ packet_pool_release_packet(mars_io->pool[thr_idx], pkt);
}
else
{
diff --git a/infra/packet_io/pcap_io.c b/infra/packet_io/pcap_io.c
index 8242a18..8d7090f 100644
--- a/infra/packet_io/pcap_io.c
+++ b/infra/packet_io/pcap_io.c
@@ -344,7 +344,7 @@ static void origin_free_cb(struct packet *pkt, void *args)
stat->bytes_user_freed += packet_get_raw_len(pkt);
free(pcap);
- packet_pool_push(pool, pkt);
+ packet_pool_release_packet(pool, pkt);
}
/******************************************************************************
@@ -476,7 +476,7 @@ int pcap_io_recv(void *handle, uint16_t thr_idx, struct packet *pkts[], int nr_p
stat->pkts_rx++;
stat->bytes_rx += pcap->len;
- pkt = packet_pool_pop(pool);
+ pkt = packet_pool_acquire_packet(pool);
assert(pkt != NULL);
struct packet_origin origin = {
.type = ORIGIN_TYPE_PCAP,
@@ -524,7 +524,7 @@ void pcap_io_send(void *handle, uint16_t thr_idx, struct packet *pkts[], int nr_
{
pcap = (struct pcap_pkt *)origin->ctx;
free(pcap);
- packet_pool_push(pcap_io->pool[thr_idx], pkt);
+ packet_pool_release_packet(pcap_io->pool[thr_idx], pkt);
}
else
{
@@ -582,7 +582,7 @@ void pcap_io_drop(void *handle, uint16_t thr_idx, struct packet *pkts[], int nr_
{
pcap = (struct pcap_pkt *)origin->ctx;
free(pcap);
- packet_pool_push(pcap_io->pool[thr_idx], pkt);
+ packet_pool_release_packet(pcap_io->pool[thr_idx], pkt);
}
else
{
diff --git a/infra/packet_manager/packet_pool.c b/infra/packet_manager/packet_pool.c
index 51b6f43..45c09ce 100644
--- a/infra/packet_manager/packet_pool.c
+++ b/infra/packet_manager/packet_pool.c
@@ -62,7 +62,7 @@ void packet_pool_free(struct packet_pool *pool)
}
}
-struct packet *packet_pool_pop(struct packet_pool *pool)
+struct packet *packet_pool_acquire_packet(struct packet_pool *pool)
{
struct packet *pkt = TAILQ_FIRST(&pool->free_list);
if (pkt == NULL)
@@ -84,7 +84,7 @@ struct packet *packet_pool_pop(struct packet_pool *pool)
return pkt;
}
-void packet_pool_push(struct packet_pool *pool, struct packet *pkt)
+void packet_pool_release_packet(struct packet_pool *pool, struct packet *pkt)
{
if (pool == NULL || pkt == NULL)
{
diff --git a/infra/packet_manager/packet_pool.h b/infra/packet_manager/packet_pool.h
index b5fbbd2..422ace4 100644
--- a/infra/packet_manager/packet_pool.h
+++ b/infra/packet_manager/packet_pool.h
@@ -11,8 +11,8 @@ struct packet_pool;
struct packet_pool *packet_pool_new(uint64_t capacity);
void packet_pool_free(struct packet_pool *pool);
-struct packet *packet_pool_pop(struct packet_pool *pool);
-void packet_pool_push(struct packet_pool *pool, struct packet *pkt);
+struct packet *packet_pool_acquire_packet(struct packet_pool *pool);
+void packet_pool_release_packet(struct packet_pool *pool, struct packet *pkt);
uint64_t packet_pool_get_used_num(const struct packet_pool *pool);
uint64_t packet_pool_get_free_num(const struct packet_pool *pool);
diff --git a/infra/packet_manager/test/gtest_packet_pool.cpp b/infra/packet_manager/test/gtest_packet_pool.cpp
index be272a4..c7f8179 100644
--- a/infra/packet_manager/test/gtest_packet_pool.cpp
+++ b/infra/packet_manager/test/gtest_packet_pool.cpp
@@ -16,40 +16,40 @@ TEST(PACKET_POOL, TEST)
EXPECT_TRUE(packet_pool_get_free_num(pool) == 3);
// pop
- pkt1 = packet_pool_pop(pool);
+ pkt1 = packet_pool_acquire_packet(pool);
EXPECT_TRUE(pkt1 != NULL);
EXPECT_TRUE(packet_pool_get_used_num(pool) == 1);
EXPECT_TRUE(packet_pool_get_free_num(pool) == 2);
- pkt2 = packet_pool_pop(pool);
+ pkt2 = packet_pool_acquire_packet(pool);
EXPECT_TRUE(pkt2 != NULL);
EXPECT_TRUE(packet_pool_get_used_num(pool) == 2);
EXPECT_TRUE(packet_pool_get_free_num(pool) == 1);
- pkt3 = packet_pool_pop(pool);
+ pkt3 = packet_pool_acquire_packet(pool);
EXPECT_TRUE(pkt3 != NULL);
EXPECT_TRUE(packet_pool_get_used_num(pool) == 3);
EXPECT_TRUE(packet_pool_get_free_num(pool) == 0);
- pkt4 = packet_pool_pop(pool);
+ pkt4 = packet_pool_acquire_packet(pool);
EXPECT_TRUE(pkt4 != NULL);
EXPECT_TRUE(packet_pool_get_used_num(pool) == 4);
EXPECT_TRUE(packet_pool_get_free_num(pool) == 0);
// push
- packet_pool_push(pool, pkt1);
+ packet_pool_release_packet(pool, pkt1);
EXPECT_TRUE(packet_pool_get_used_num(pool) == 3);
EXPECT_TRUE(packet_pool_get_free_num(pool) == 1);
- packet_pool_push(pool, pkt2);
+ packet_pool_release_packet(pool, pkt2);
EXPECT_TRUE(packet_pool_get_used_num(pool) == 2);
EXPECT_TRUE(packet_pool_get_free_num(pool) == 2);
- packet_pool_push(pool, pkt3);
+ packet_pool_release_packet(pool, pkt3);
EXPECT_TRUE(packet_pool_get_used_num(pool) == 1);
EXPECT_TRUE(packet_pool_get_free_num(pool) == 3);
- packet_pool_push(pool, pkt4);
+ packet_pool_release_packet(pool, pkt4);
EXPECT_TRUE(packet_pool_get_used_num(pool) == 0);
EXPECT_TRUE(packet_pool_get_free_num(pool) == 3);
diff --git a/infra/session_manager/session_manager_rte.c b/infra/session_manager/session_manager_rte.c
index 56e229b..2c534a1 100644
--- a/infra/session_manager/session_manager_rte.c
+++ b/infra/session_manager/session_manager_rte.c
@@ -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;
}
}
diff --git a/infra/session_manager/session_pool.c b/infra/session_manager/session_pool.c
index 43bef64..548cebb 100644
--- a/infra/session_manager/session_pool.c
+++ b/infra/session_manager/session_pool.c
@@ -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)
{
diff --git a/infra/session_manager/session_pool.h b/infra/session_manager/session_pool.h
index e3509c8..6108b64 100644
--- a/infra/session_manager/session_pool.h
+++ b/infra/session_manager/session_pool.h
@@ -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);
diff --git a/infra/session_manager/test/gtest_session_pool.cpp b/infra/session_manager/test/gtest_session_pool.cpp
index 8c868ee..8109b18 100644
--- a/infra/session_manager/test/gtest_session_pool.cpp
+++ b/infra/session_manager/test/gtest_session_pool.cpp
@@ -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);
diff --git a/infra/session_manager/test/gtest_session_table.cpp b/infra/session_manager/test/gtest_session_table.cpp
index 4a45f38..491ca58 100644
--- a/infra/session_manager/test/gtest_session_table.cpp
+++ b/infra/session_manager/test/gtest_session_table.cpp
@@ -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);