remove session_manager_subscribe_xxx() API; convert session closing events to pseudo packets

when a session is closed, use the packet manager to create a pseudo packet,
    set the session to be closed as packet Exdata, and schedule it to the packet forwarding stage.
    when the pseudo packet free, the session will be free.
This commit is contained in:
luwenpeng
2024-11-18 18:33:19 +08:00
parent 746d7fca06
commit c2e9275a9e
25 changed files with 210 additions and 378 deletions

View File

@@ -227,7 +227,7 @@ struct packet_manager *packet_manager_new(struct mq_schema *mq_sche, uint16_t th
PACKET_MANAGER_LOG_ERROR("failed to create fieldstat_easy");
goto error_out;
}
if (fieldstat_easy_enable_auto_output(pkt_mgr->fs, "packet_manager.fs4", 2) != 0)
if (fieldstat_easy_enable_auto_output(pkt_mgr->fs, "metrics/packet_manager.json", 2) != 0)
{
PACKET_MANAGER_LOG_ERROR("failed to enable auto output for fieldstat_easy");
goto error_out;
@@ -477,6 +477,20 @@ struct packet *packet_manager_build_l3_packet(struct packet_manager *pkt_mgr, co
return pkt;
}
struct packet *packet_manager_dup_packet(struct packet_manager *pkt_mgr, const struct packet *origin_pkt)
{
struct packet *pkt = packet_dup(origin_pkt);
if (pkt == NULL)
{
return NULL;
}
struct exdata_runtime *ex_rte = exdata_runtime_new(pkt_mgr->sche->ex_sche);
packet_set_user_data(pkt, ex_rte);
return pkt;
}
void packet_manager_free_packet(struct packet_manager *pkt_mgr __attribute__((unused)), struct packet *pkt)
{
if (pkt)
@@ -581,8 +595,9 @@ struct module *packet_manager_on_thread_init(struct module_manager *mod_mgr, int
void packet_manager_on_thread_exit(struct module_manager *mod_mgr __attribute__((unused)), int thread_id, struct module *mod)
{
struct packet_manager *pkt_mgr = module_get_ctx(mod);
assert(pkt_mgr);
assert(thread_id < pkt_mgr->thread_num);
packet_manager_clean(pkt_mgr, thread_id);
if (pkt_mgr)
{
assert(thread_id < pkt_mgr->thread_num);
packet_manager_clean(pkt_mgr, thread_id);
}
}

View File

@@ -84,4 +84,5 @@ gtest_discover_tests(gtest_packet_ldbc)
gtest_discover_tests(gtest_packet_pool)
gtest_discover_tests(gtest_packet_manager)
file(COPY ../../../conf/ DESTINATION ./conf/)
file(COPY ../../../conf/ DESTINATION ./conf/)
file(COPY ./metrics/ DESTINATION ./metrics/)