diff options
| author | yangwei <[email protected]> | 2024-09-14 12:18:26 +0800 |
|---|---|---|
| committer | yangwei <[email protected]> | 2024-09-14 12:18:26 +0800 |
| commit | 1f55a6f2405ce209d04d7b71df593aef4474d1ed (patch) | |
| tree | 17e5eb5d0840adc60bf58651f9c736070b74c247 /infra/stellar_core.c | |
| parent | 0b142cd0bb38169936c516772d84c9b4e4201cae (diff) | |
✨ feat(module manager): from plugin manager to module manager
Diffstat (limited to 'infra/stellar_core.c')
| -rw-r--r-- | infra/stellar_core.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/infra/stellar_core.c b/infra/stellar_core.c index f72574e..0c2a1f4 100644 --- a/infra/stellar_core.c +++ b/infra/stellar_core.c @@ -8,13 +8,14 @@ #include <pthread.h> #include <sys/prctl.h> +#include "stellar/module_manager.h" + #include "utils.h" #include "packet_io.h" #include "log_private.h" #include "stellar_stat.h" #include "stellar_core.h" #include "packet_private.h" -#include "plugin_manager.h" #include "session_private.h" #include "session_manager.h" @@ -51,7 +52,8 @@ struct stellar_runtime struct logger *logger; struct stellar_stat *stat; struct packet_io *packet_io; - struct plugin_manager_schema *plug_mgr; + struct mq_schema *mq_schema; + struct stellar_module_manager *mod_mgr; struct stellar_thread threads[MAX_THREAD_NUM]; }; @@ -130,7 +132,11 @@ static void *worker_thread(void *arg) struct stellar *st = thread->st; struct stellar_runtime *runtime = &st->runtime; struct packet_io *packet_io = runtime->packet_io; - struct plugin_manager_schema *plug_mgr = runtime->plug_mgr; + struct stellar_module_manager *mod_mgr = runtime->mod_mgr; + struct mq_runtime *mq_rt = mq_runtime_new(runtime->mq_schema); + + stellar_module_manager_register_thread(mod_mgr, thread->tid, mq_rt); + struct thread_stat thr_stat = { .pkt_io = packet_io_stat(packet_io, thread->idx), .ip_reass = ip_reassembly_stat(ip_reass), @@ -145,7 +151,7 @@ static void *worker_thread(void *arg) for (int i = 0; i < RX_BURST_MAX; i++) { - packet_set_user_data(&packets[i], (void *)plug_mgr); + packet_set_user_data(&packets[i], (void *)mod_mgr); } snprintf(thd_name, sizeof(thd_name), "stellar:%d", thr_idx); @@ -292,6 +298,8 @@ static void *worker_thread(void *arg) stellar_stat_merge(runtime->stat, &thr_stat, thread->idx, UINT64_MAX); stellar_stat_print(runtime->stat, &thr_stat, thread->idx); + mq_runtime_free(mq_rt); + ATOMIC_SET(&thread->is_runing, 0); CORE_LOG_FATAL("worker thread %d exit", thr_idx); @@ -448,8 +456,9 @@ struct stellar *stellar_new(const char *stellar_cfg_file, const char *plugin_cfg CORE_LOG_ERROR("unable to create stellar stat"); goto error_out; } - runtime->plug_mgr = plugin_manager_init(st, plugin_cfg_file); - if (runtime->plug_mgr == NULL) + runtime->mq_schema=mq_schema_new(); + runtime->mod_mgr = stellar_module_manager_new(plugin_cfg_file, config->pkt_io_cfg->nr_worker_thread, runtime->mq_schema); + if (runtime->mod_mgr == NULL) { CORE_LOG_ERROR("unable to create plugin manager"); goto error_out; @@ -527,7 +536,8 @@ void stellar_free(struct stellar *st) struct stellar_config *config = &st->config; packet_io_free(runtime->packet_io); - plugin_manager_exit(runtime->plug_mgr); + stellar_module_manager_free(runtime->mod_mgr); + mq_schema_free(runtime->mq_schema); stellar_stat_free(runtime->stat); session_manager_config_free(config->sess_mgr_cfg); @@ -564,20 +574,11 @@ void stellar_reload_log_level(struct stellar *st) * Stellar Utility Function ******************************************************************************/ -struct plugin_manager_schema *stellar_get_plugin_manager(const struct stellar *st) -{ - return st->runtime.plug_mgr; -} - -void stellar_set_plugin_manger(struct stellar *st, struct plugin_manager_schema *plug_mgr) -{ - st->runtime.plug_mgr = plug_mgr; -} // only send user build packet, can't send packet which come from network void stellar_send_build_packet(struct stellar *st, struct packet *pkt) { - uint16_t thr_idx = stellar_get_current_thread_index(); + uint16_t thr_idx = stellar_module_manager_get_thread_id(st->runtime.mod_mgr); struct packet_io *packet_io = st->runtime.packet_io; struct session_manager *sess_mgr = st->runtime.threads[thr_idx].sess_mgr; session_manager_record_duplicated_packet(sess_mgr, pkt); |
