summaryrefslogtreecommitdiff
path: root/infra
diff options
context:
space:
mode:
author杨威 <[email protected]>2024-10-11 06:08:50 +0000
committer杨威 <[email protected]>2024-10-11 06:08:50 +0000
commit70d21f28c36fc93280352c9284de6529afcbe5be (patch)
tree4bfc3669ca0da512ceb897167feda65dcaefa1af /infra
parent2e35a795285499e064b91435ad90777f90419f68 (diff)
Rebase dev 2.0
Diffstat (limited to 'infra')
-rw-r--r--infra/CMakeLists.txt2
-rw-r--r--infra/mq/mq.c2
-rw-r--r--infra/mq/mq_internal.h2
-rw-r--r--infra/mq/test/gtest_mq_main.cpp2
-rw-r--r--infra/packet_manager/packet_manager.c14
-rw-r--r--infra/session_manager/session_manager.c21
-rw-r--r--infra/session_manager/session_manager_runtime.c10
-rw-r--r--infra/stellar_core.c17
-rw-r--r--infra/version.map24
9 files changed, 73 insertions, 21 deletions
diff --git a/infra/CMakeLists.txt b/infra/CMakeLists.txt
index 008713e..8dfa468 100644
--- a/infra/CMakeLists.txt
+++ b/infra/CMakeLists.txt
@@ -1,6 +1,6 @@
set(INFRA exdata mq tuple packet_manager packet_io ip_reassembly tcp_reassembly session_manager module_manager polling_manager)
set(DEPS bitmap dablooms interval_tree logger nmx_pool rbtree timeout toml)
-#set(DECODERS http lpi)
+set(DECODERS appid lpi_plus)
set(WHOLE_ARCHIVE ${DEPS} ${INFRA} ${DECODERS})
set(LIBS fieldstat4)
diff --git a/infra/mq/mq.c b/infra/mq/mq.c
index ff503a8..a054e19 100644
--- a/infra/mq/mq.c
+++ b/infra/mq/mq.c
@@ -122,7 +122,7 @@ static int mq_dispatch_one_message(struct mq_topic *topic, struct mq_message *mq
-int mq_runtime_publish_message_at_once(struct mq_runtime *rt, int topic_id, void *msg)
+int mq_runtime_publish_message_immediate(struct mq_runtime *rt, int topic_id, void *msg)
{
if(rt==NULL || rt->schema == NULL)return -1;
diff --git a/infra/mq/mq_internal.h b/infra/mq/mq_internal.h
index 4d60e37..146d222 100644
--- a/infra/mq/mq_internal.h
+++ b/infra/mq/mq_internal.h
@@ -71,7 +71,7 @@ struct mq_runtime
};
int mq_runtime_publish_message_with_priority(struct mq_runtime *rt, int topic_id, void *msg, enum mq_property priority);
-int mq_runtime_publish_message_at_once(struct mq_runtime *rt, int topic_id, void *msg);
+int mq_runtime_publish_message_immediate(struct mq_runtime *rt, int topic_id, void *msg);
#ifdef __cplusplus
}
diff --git a/infra/mq/test/gtest_mq_main.cpp b/infra/mq/test/gtest_mq_main.cpp
index 2f16fcb..a2ee952 100644
--- a/infra/mq/test/gtest_mq_main.cpp
+++ b/infra/mq/test/gtest_mq_main.cpp
@@ -342,7 +342,7 @@ static void test_pub_on_msg_free(void *msg, void *msg_free_arg)
if((long)msg!=env->N_round && (int)(long)msg==env->N_round-1)
{
EXPECT_EQ(mq_runtime_publish_message(env->rt, env->topic_id, (void *)(long)(env->N_round)), -1);//on message free, publish always failed
- EXPECT_EQ(mq_runtime_publish_message_at_once(env->rt, env->topic_id, (void *)(long)(env->N_round)), 0);//on message free, publish at once success
+ EXPECT_EQ(mq_runtime_publish_message_immediate(env->rt, env->topic_id, (void *)(long)(env->N_round)), 0);//on message free, publish at once success
}
return;
}
diff --git a/infra/packet_manager/packet_manager.c b/infra/packet_manager/packet_manager.c
index eba87ec..e492414 100644
--- a/infra/packet_manager/packet_manager.c
+++ b/infra/packet_manager/packet_manager.c
@@ -4,7 +4,8 @@
#include "packet_internal.h"
#include "packet_manager_runtime.h"
#include "packet_manager_internal.h"
-#include "stellar/module_manager.h"
+
+#define PACKET_MANAGER_MODULE_NAME "packet_manager_module"
struct packet_manager_config
{
@@ -290,6 +291,17 @@ void packet_manager_print_stat(struct packet_manager *pkt_mgr, uint16_t thread_i
* packet manager module
******************************************************************************/
+struct packet_manager *stellar_module_get_packet_manager(struct stellar_module_manager *mod_mgr)
+{
+ assert(mod_mgr);
+ struct stellar_module *pkt_mgr_mod = stellar_module_manager_get_module(mod_mgr, PACKET_MANAGER_MODULE_NAME);
+ if (pkt_mgr_mod == NULL)
+ {
+ return NULL;
+ }
+ return (struct packet_manager*)stellar_module_get_ctx(pkt_mgr_mod);
+}
+
struct stellar_module *packet_manager_on_init(struct stellar_module_manager *mod_mgr)
{
assert(mod_mgr);
diff --git a/infra/session_manager/session_manager.c b/infra/session_manager/session_manager.c
index a2b2fd7..5f3820f 100644
--- a/infra/session_manager/session_manager.c
+++ b/infra/session_manager/session_manager.c
@@ -11,9 +11,12 @@
#include "session_internal.h"
#include "session_manager_runtime.h"
+#define SESSION_MANAGER_MODULE_NAME "session_manager_module"
+
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-function"
+
struct session_manager_schema
{
struct exdata_schema *exdata;
@@ -162,14 +165,11 @@ static void clean_session(struct session_manager_runtime *sess_mgr_rt, uint64_t
#define MAX_CLEANED_SESS 1024
struct session *sess = NULL;
struct session *cleaned_sess[MAX_CLEANED_SESS] = {NULL};
- struct exdata_runtime *exdata_rt = NULL;
uint64_t used = session_manager_runtime_clean_session(sess_mgr_rt, now_ms, cleaned_sess, MAX_CLEANED_SESS);
for (uint64_t j = 0; j < used; j++)
{
sess = cleaned_sess[j];
- exdata_rt = (struct exdata_runtime *)session_get_user_data(sess);
- exdata_runtime_free(exdata_rt);
session_manager_runtime_free_session(sess_mgr_rt, sess);
}
}
@@ -421,12 +421,21 @@ int session_manager_subscribe_tcp_stream(struct session_manager *sess_mgr, on_tc
* session manager module
******************************************************************************/
+struct session_manager *stellar_module_get_session_manager(struct stellar_module_manager *mod_mgr)
+{
+ assert(mod_mgr);
+ struct stellar_module *sess_mgr_mod = stellar_module_manager_get_module(mod_mgr, SESSION_MANAGER_MODULE_NAME);
+ if (sess_mgr_mod == NULL)
+ {
+ return NULL;
+ }
+ return stellar_module_get_ctx(sess_mgr_mod);
+}
+
struct stellar_module *session_manager_on_init(struct stellar_module_manager *mod_mgr)
{
assert(mod_mgr);
- struct stellar_module *pkt_mgr_mod = stellar_module_manager_get_module(mod_mgr, PACKET_MANAGER_MODULE_NAME);
- assert(pkt_mgr_mod);
- struct packet_manager *pkt_mgr = stellar_module_get_ctx(pkt_mgr_mod);
+ struct packet_manager *pkt_mgr = stellar_module_get_packet_manager(mod_mgr);
assert(pkt_mgr);
struct stellar_polling_manager *poll_mgr = stellar_module_get_polling_manager(mod_mgr);
assert(poll_mgr);
diff --git a/infra/session_manager/session_manager_runtime.c b/infra/session_manager/session_manager_runtime.c
index f89176c..efb9e42 100644
--- a/infra/session_manager/session_manager_runtime.c
+++ b/infra/session_manager/session_manager_runtime.c
@@ -14,6 +14,12 @@
#include "session_transition.h"
#include "session_manager_runtime.h"
+#include "stellar/exdata.h"
+
+#define SESSION_MANAGER_RUNTIME_LOG_ERROR(format, ...) STELLAR_LOG_ERROR(__thread_local_logger, "session manager runtime", format, ##__VA_ARGS__)
+#define SESSION_MANAGER_RUNTIME_LOG_DEBUG(format, ...) STELLAR_LOG_DEBUG(__thread_local_logger, "session manager runtime", format, ##__VA_ARGS__)
+#define SESSION_MANAGER_RUNTIME_LOG_INFO(format, ...) STELLAR_LOG_INFO(__thread_local_logger, "session manager runtime", format, ##__VA_ARGS__)
+
struct snowflake
{
uint64_t seed;
@@ -1060,6 +1066,10 @@ void session_manager_runtime_free_session(struct session_manager_runtime *sess_m
{
if (sess)
{
+ struct exdata_runtime *exdata_rt = (struct exdata_runtime *)session_get_user_data(sess);
+ exdata_runtime_free(exdata_rt);
+
+ SESSION_MANAGER_RUNTIME_LOG_DEBUG("session %lu closed (%s)", session_get_id(sess), closing_reason_to_str(session_get_closing_reason(sess)));
SESSION_MANAGER_LOG_DEBUG("session %lu closed (%s)", session_get_id(sess), closing_reason_to_str(session_get_closing_reason(sess)));
session_timer_del(sess_mgr_rt->sess_timer, sess);
diff --git a/infra/stellar_core.c b/infra/stellar_core.c
index a63a5bd..81c3c2a 100644
--- a/infra/stellar_core.c
+++ b/infra/stellar_core.c
@@ -52,8 +52,7 @@ static void *worker_thread(void *arg)
struct stellar_module_manager *mod_mgr = st->mod_mgr;
struct mq_runtime *mq_rt = mq_runtime_new(st->mq_schema);
struct stellar_polling_manager *polling_mgr = stellar_module_get_polling_manager(mod_mgr);
- struct stellar_module *pkt_mgr_mod = stellar_module_manager_get_module(mod_mgr, PACKET_MANAGER_MODULE_NAME);
- struct packet_manager *pkt_mgr = stellar_module_get_ctx(pkt_mgr_mod);
+ struct packet_manager *pkt_mgr = stellar_module_get_packet_manager(mod_mgr);
snprintf(thread_name, sizeof(thread_name), "stellar:%d", thread_id);
prctl(PR_SET_NAME, (unsigned long long)thread_name, NULL, NULL, NULL);
@@ -199,7 +198,7 @@ struct stellar *stellar_new(const char *toml_file)
st->mod_mgr = stellar_module_manager_new(toml_file, st->thread_num, st->mq_schema, st->logger);
if (st->mod_mgr == NULL)
{
- CORE_LOG_ERROR("unable to create module manager");
+ CORE_LOG_ERROR("unable to create packet manager");
goto error_out;
}
@@ -290,4 +289,16 @@ struct logger *stellar_get_logger(struct stellar *st)
{
return NULL;
}
+}
+
+struct stellar_module_manager *stellar_get_module_manager(struct stellar *st)
+{
+ if (st)
+ {
+ return st->mod_mgr;
+ }
+ else
+ {
+ return NULL;
+ }
} \ No newline at end of file
diff --git a/infra/version.map b/infra/version.map
index a6163bc..496011a 100644
--- a/infra/version.map
+++ b/infra/version.map
@@ -36,6 +36,12 @@ global:
session_get_stat;
session_get0_readable_addr;
session_set_discard;
+ session_manager_new_session_exdata_index;
+ session_get_exdata;
+ session_set_exdata;
+ session_manager_subscribe_tcp;
+ session_manager_subscribe_udp;
+ session_manager_subscribe_tcp_stream;
stellar_session_plugin_register;
stellar_session_plugin_register_with_hooks;
@@ -49,6 +55,10 @@ global:
stellar_loopbreak;
stellar_get_logger;
stellar_reload_log_level;
+ stellar_get_module_manager;
+
+ stellar_appid_subscribe;
+
log_print;
log_check_level;
@@ -61,14 +71,14 @@ global:
session_manager_on_init;
session_manager_on_exit;
- http_message_*;
- http_decoder_init;
- http_decoder_exit;
- http_decoder_tcp_stream_msg_cb;
- http_url_decode;
+ http_message_*;
+ http_decoder_init;
+ http_decoder_exit;
+ http_decoder_tcp_stream_msg_cb;
+ http_url_decode;
- lpi_plugin_load;
- lpi_plugin_unload;
+ lpi_plus_init;
+ lpi_plus_exit;
local: *;
};