🦄 refactor(stellar_module to module): simplify stellar module to module
This commit is contained in:
@@ -25,25 +25,25 @@ static void stellar_appid_on_msg_dispatch(int topic_id __unused,
|
||||
appid_cb(appid_msg->sess, appid_msg->origin, appid_msg->appid, appid_msg->appid_num, on_msg_cb_arg);
|
||||
}
|
||||
|
||||
int stellar_appid_subscribe(struct stellar_module_manager *mod_mgr, on_appid_callback *cb, void *args)
|
||||
int stellar_appid_subscribe(struct module_manager *mod_mgr, on_appid_callback *cb, void *args)
|
||||
{
|
||||
if(mod_mgr==NULL)return -1;
|
||||
int appid_topic_id=mq_schema_get_topic_id(stellar_module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC);
|
||||
int appid_topic_id=mq_schema_get_topic_id(module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC);
|
||||
if(appid_topic_id<0)
|
||||
{
|
||||
appid_topic_id=mq_schema_create_topic(stellar_module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC, stellar_appid_on_msg_dispatch, mod_mgr, appid_message_free, NULL);
|
||||
appid_topic_id=mq_schema_create_topic(module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC, stellar_appid_on_msg_dispatch, mod_mgr, appid_message_free, NULL);
|
||||
}
|
||||
return mq_schema_subscribe(stellar_module_manager_get_mq_schema(mod_mgr), appid_topic_id, (on_msg_cb_func *)cb, args);
|
||||
return mq_schema_subscribe(module_manager_get_mq_schema(mod_mgr), appid_topic_id, (on_msg_cb_func *)cb, args);
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
int stellar_appid_create_topic(struct stellar_module_manager *mod_mgr)
|
||||
int stellar_appid_create_topic(struct module_manager *mod_mgr)
|
||||
{
|
||||
int app_topic_id=mq_schema_get_topic_id(stellar_module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC);
|
||||
int app_topic_id=mq_schema_get_topic_id(module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC);
|
||||
if(app_topic_id < 0)
|
||||
{
|
||||
app_topic_id=mq_schema_create_topic(stellar_module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC, stellar_appid_on_msg_dispatch, NULL,appid_message_free, NULL);
|
||||
app_topic_id=mq_schema_create_topic(module_manager_get_mq_schema(mod_mgr), APPID_MESSAGE_TOPIC, stellar_appid_on_msg_dispatch, NULL,appid_message_free, NULL);
|
||||
}
|
||||
return app_topic_id;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "stellar/module_manager.h"
|
||||
#include "stellar/module.h"
|
||||
#define LPI_PLUS_MODULE_NAME "LPI_PLUS"
|
||||
struct lpi_plus_mapper;
|
||||
struct lpi_plus_mapper *stellar_module_get_lpip(struct stellar_module_manager *mod_mgr);
|
||||
struct lpi_plus_mapper *module_to_lpip_mapper(struct module *mod);
|
||||
const char *lpi_plus_appid2name(struct lpi_plus_mapper *mapper, int appid);
|
||||
@@ -45,7 +45,7 @@ struct lpi_plus_env
|
||||
unsigned int max_pkts;
|
||||
int lpip_session_exdata_idx;
|
||||
int topic_appid;
|
||||
struct stellar_module_manager *mod_mgr;
|
||||
struct module_manager *mod_mgr;
|
||||
struct lpi_plus_mapper *mapper;
|
||||
};
|
||||
|
||||
@@ -312,7 +312,7 @@ static void lpi_plus_on_session(struct session *sess, enum session_state state,
|
||||
if(appid>0 && lpi_plus_appid_update(exdata->appid, &(exdata->appid_num), appid))
|
||||
{
|
||||
struct appid_message *msg=lpi_plus_message_new(sess, exdata->appid, exdata->appid_num);
|
||||
if(0 > mq_runtime_publish_message(stellar_module_manager_get_mq_runtime(env->mod_mgr),
|
||||
if(0 > mq_runtime_publish_message(module_manager_get_mq_runtime(env->mod_mgr),
|
||||
env->topic_appid,
|
||||
msg))FREE(msg);
|
||||
}
|
||||
@@ -326,30 +326,30 @@ static void lpi_plus_exdata_free(int idx __unused, void *ex_ptr, void *arg __unu
|
||||
FREE(ex_ptr);
|
||||
}
|
||||
|
||||
void lpi_plus_exit(struct stellar_module_manager *mod_mgr, struct stellar_module *mod)
|
||||
void lpi_plus_exit(struct module_manager *mod_mgr, struct module *mod)
|
||||
{
|
||||
if(mod_mgr==NULL)return;
|
||||
if(mod)
|
||||
{
|
||||
struct lpi_plus_env *env=(struct lpi_plus_env *)stellar_module_get_ctx(mod);
|
||||
struct lpi_plus_env *env=(struct lpi_plus_env *)module_get_ctx(mod);
|
||||
lpi_free_library();
|
||||
lpi_plus_mapper_free(env->mapper);
|
||||
FREE(env);
|
||||
stellar_module_free(mod);
|
||||
module_free(mod);
|
||||
}
|
||||
}
|
||||
|
||||
struct stellar_module *lpi_plus_init(struct stellar_module_manager *mod_mgr)
|
||||
struct module *lpi_plus_init(struct module_manager *mod_mgr)
|
||||
{
|
||||
if(mod_mgr==NULL)return NULL;
|
||||
|
||||
struct lpi_plus_env *env=CALLOC(struct lpi_plus_env, 1);
|
||||
struct stellar_module *mod=stellar_module_new("LPI_PLUS", env);
|
||||
struct module *mod=module_new("LPI_PLUS", env);
|
||||
env->mod_mgr=mod_mgr;
|
||||
env->max_pkts=16;//TODO: load from toml
|
||||
|
||||
struct session_manager *sess_mgr=stellar_module_get_session_manager(mod_mgr);
|
||||
struct mq_schema *mq_s=stellar_module_manager_get_mq_schema(mod_mgr);
|
||||
struct module *sess_mgr_mod=module_manager_get_module(mod_mgr, SESSION_MANAGER_MODULE_NAME);
|
||||
struct session_manager *sess_mgr=module_to_session_manager(sess_mgr_mod);
|
||||
struct mq_schema *mq_s=module_manager_get_mq_schema(mod_mgr);
|
||||
|
||||
if(sess_mgr==NULL || mq_s==NULL)
|
||||
{
|
||||
@@ -385,12 +385,11 @@ INIT_ERROR:
|
||||
|
||||
}
|
||||
|
||||
struct lpi_plus_mapper *stellar_module_get_lpip(struct stellar_module_manager *mod_mgr)
|
||||
struct lpi_plus_mapper *module_to_lpip_mapper(struct module *mod)
|
||||
{
|
||||
if(mod_mgr==NULL)return NULL;
|
||||
struct stellar_module *mod=stellar_module_manager_get_module(mod_mgr, "LPI_PLUS");
|
||||
if(mod==NULL)return NULL;
|
||||
struct lpi_plus_env *lpi_p=(struct lpi_plus_env *)stellar_module_get_ctx(mod);
|
||||
assert(strcmp(module_get_name(mod), LPI_PLUS_MODULE_NAME) == 0);
|
||||
struct lpi_plus_env *lpi_p=(struct lpi_plus_env *)module_get_ctx(mod);
|
||||
if(lpi_p==NULL)return NULL;
|
||||
return lpi_p->mapper;
|
||||
}
|
||||
@@ -9,7 +9,7 @@ extern "C"
|
||||
#include <stdint.h>
|
||||
|
||||
#include "stellar/session.h"
|
||||
#include "stellar/module_manager.h"
|
||||
#include "stellar/module.h"
|
||||
|
||||
enum APPID_ORIGIN
|
||||
{
|
||||
@@ -24,8 +24,8 @@ enum APPID_ORIGIN
|
||||
};
|
||||
|
||||
typedef void on_appid_callback(struct session *sess, enum APPID_ORIGIN origin, int appid[], size_t appid_num, void *args);
|
||||
int stellar_appid_create_topic(struct stellar_module_manager *mod_mgr);
|
||||
int stellar_appid_subscribe(struct stellar_module_manager *mod_mgr, on_appid_callback *cb, void *args);
|
||||
int stellar_appid_create_topic(struct module_manager *mod_mgr);
|
||||
int stellar_appid_subscribe(struct module_manager *mod_mgr, on_appid_callback *cb, void *args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
52
include/stellar/module.h
Normal file
52
include/stellar/module.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "stellar/mq.h"
|
||||
#include "stellar/log.h"
|
||||
|
||||
struct module;
|
||||
struct module *module_new(const char *name, void *ctx);
|
||||
void module_free(struct module *mod);
|
||||
|
||||
void * module_get_ctx(struct module *mod);
|
||||
void module_set_ctx(struct module *mod, void *ctx);
|
||||
|
||||
const char *module_get_name(struct module* mod);
|
||||
void module_set_name(struct module* mod, const char *name);
|
||||
|
||||
struct module_manager;
|
||||
|
||||
typedef struct module *module_on_instance_init_func(struct module_manager *mod_mgr);
|
||||
typedef void module_on_instance_exit_func(struct module_manager *mod_mgr, struct module *mod);
|
||||
|
||||
typedef struct module *module_on_thread_init_func(struct module_manager *mod_mgr, int thread_id, struct module *mod);
|
||||
typedef void module_on_thread_exit_func(struct module_manager *mod_mgr, int thread_id, struct module *mod);
|
||||
|
||||
struct module_manager *module_manager_new(const char *module_spec_toml_path, int max_thread_num, struct mq_schema *mq_schema, struct logger *logger);
|
||||
void module_manager_free(struct module_manager *mod_mgr);
|
||||
|
||||
void module_manager_register_thread(struct module_manager *mod_mgr, int thread_id, struct mq_runtime *mq_rt);
|
||||
void module_manager_unregister_thread(struct module_manager *mod_mgr, int thread_id);
|
||||
|
||||
// return -1 on error
|
||||
int module_manager_get_thread_id(struct module_manager *mod_mgr);
|
||||
struct mq_runtime *module_manager_get_mq_runtime(struct module_manager *mod_mgr);
|
||||
|
||||
struct module *module_manager_get_module(struct module_manager *mod_mgr, const char *module_name);
|
||||
|
||||
int module_manager_get_max_thread_num(struct module_manager *mod_mgr);
|
||||
const char *module_manager_get_toml_path(struct module_manager *mod_mgr);
|
||||
struct mq_schema *module_manager_get_mq_schema(struct module_manager *mod_mgr);
|
||||
struct logger *module_manager_get_logger(struct module_manager *mod_mgr);
|
||||
|
||||
typedef void module_on_polling_func(struct module_manager *mod_mgr, void *polling_arg);
|
||||
int module_manager_polling_subscribe(struct module_manager *mod_mgr, module_on_polling_func on_polling, void *polling_arg);
|
||||
void module_manager_polling_active(struct module_manager *mod_mgr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,52 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "stellar/mq.h"
|
||||
#include "stellar/log.h"
|
||||
|
||||
struct stellar_module;
|
||||
struct stellar_module *stellar_module_new(const char *name, void *ctx);
|
||||
void stellar_module_free(struct stellar_module *mod);
|
||||
|
||||
void * stellar_module_get_ctx(struct stellar_module *mod);
|
||||
void stellar_module_set_ctx(struct stellar_module *mod, void *ctx);
|
||||
|
||||
const char *stellar_module_get_name(struct stellar_module* mod);
|
||||
void stellar_module_set_name(struct stellar_module* mod, const char *name);
|
||||
|
||||
struct stellar_module_manager;
|
||||
|
||||
typedef struct stellar_module *module_on_instance_init_func(struct stellar_module_manager *mod_mgr);
|
||||
typedef void module_on_instance_exit_func(struct stellar_module_manager *mod_mgr, struct stellar_module *mod);
|
||||
|
||||
typedef struct stellar_module *module_on_thread_init_func(struct stellar_module_manager *mod_mgr, int thread_id, struct stellar_module *mod);
|
||||
typedef void module_on_thread_exit_func(struct stellar_module_manager *mod_mgr, int thread_id, struct stellar_module *mod);
|
||||
|
||||
struct stellar_module_manager *stellar_module_manager_new(const char *module_spec_toml_path, int max_thread_num, struct mq_schema *mq_schema, struct logger *logger);
|
||||
void stellar_module_manager_free(struct stellar_module_manager *mod_mgr);
|
||||
|
||||
void stellar_module_manager_register_thread(struct stellar_module_manager *mod_mgr, int thread_id, struct mq_runtime *mq_rt);
|
||||
void stellar_module_manager_unregister_thread(struct stellar_module_manager *mod_mgr, int thread_id);
|
||||
|
||||
// return -1 on error
|
||||
int stellar_module_manager_get_thread_id(struct stellar_module_manager *mod_mgr);
|
||||
struct mq_runtime *stellar_module_manager_get_mq_runtime(struct stellar_module_manager *mod_mgr);
|
||||
|
||||
struct stellar_module *stellar_module_manager_get_module(struct stellar_module_manager *mod_mgr, const char *module_name);
|
||||
|
||||
int stellar_module_manager_get_max_thread_num(struct stellar_module_manager *mod_mgr);
|
||||
const char *stellar_module_manager_get_toml_path(struct stellar_module_manager *mod_mgr);
|
||||
struct mq_schema *stellar_module_manager_get_mq_schema(struct stellar_module_manager *mod_mgr);
|
||||
struct logger *stellar_module_manager_get_logger(struct stellar_module_manager *mod_mgr);
|
||||
|
||||
typedef void module_on_polling_func(struct stellar_module_manager *mod_mgr, void *polling_arg);
|
||||
int stellar_module_manager_polling_subscribe(struct stellar_module_manager *mod_mgr, module_on_polling_func on_polling, void *polling_arg);
|
||||
void stellar_module_manager_polling_active(struct stellar_module_manager *mod_mgr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -17,7 +17,7 @@ extern "C"
|
||||
#include <linux/mpls.h>
|
||||
|
||||
#include "stellar/exdata.h"
|
||||
#include "stellar/module_manager.h"
|
||||
#include "stellar/module.h"
|
||||
|
||||
struct packet;
|
||||
/******************************************************************************
|
||||
@@ -205,8 +205,9 @@ enum packet_stage
|
||||
PACKET_STAGE_MAX,
|
||||
};
|
||||
|
||||
#define PACKET_MANAGER_MODULE_NAME "packet_manager_module"
|
||||
struct packet_manager;
|
||||
struct packet_manager *stellar_module_get_packet_manager(struct stellar_module_manager *mod_mgr);
|
||||
struct packet_manager *module_to_packet_manager(struct module *mod);
|
||||
int packet_manager_new_packet_exdata_index(struct packet_manager *pkt_mgr, const char *name, exdata_free *func, void *arg);
|
||||
|
||||
typedef void on_packet_stage_callback(struct packet *pkt, enum packet_stage stage, void *arg);
|
||||
|
||||
@@ -6,7 +6,7 @@ extern "C"
|
||||
#endif
|
||||
|
||||
#include "stellar/packet.h"
|
||||
#include "stellar/module_manager.h"
|
||||
#include "stellar/module.h"
|
||||
|
||||
enum session_state
|
||||
{
|
||||
@@ -147,8 +147,9 @@ void session_set_discard(struct session *sess);
|
||||
void session_set_exdata(struct session *sess, int idx, void *ex_ptr);
|
||||
void *session_get_exdata(const struct session *sess, int idx);
|
||||
|
||||
#define SESSION_MANAGER_MODULE_NAME "session_manager_module"
|
||||
struct session_manager;
|
||||
struct session_manager *stellar_module_get_session_manager(struct stellar_module_manager *mod_mgr);
|
||||
struct session_manager *module_to_session_manager(struct module *mod);
|
||||
int session_manager_new_session_exdata_index(struct session_manager *sess_mgr, const char *name, exdata_free *func, void *arg);
|
||||
|
||||
// When the state is SESSION_STATE_CLOSED, the packet is NULL, and the session will be destroyed.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "module_manager_interna.h"
|
||||
|
||||
#include "stellar/module_manager.h"
|
||||
#include "stellar/utils.h"
|
||||
#include <dlfcn.h>
|
||||
#include <stdbool.h>
|
||||
@@ -14,10 +13,10 @@
|
||||
|
||||
#include "toml/toml.h"
|
||||
|
||||
struct stellar_module_manager *stellar_module_manager_new(const char *module_spec_toml_path, int max_thread_num, struct mq_schema *mq_schema, struct logger *logger)
|
||||
struct module_manager *module_manager_new(const char *module_spec_toml_path, int max_thread_num, struct mq_schema *mq_schema, struct logger *logger)
|
||||
{
|
||||
|
||||
struct stellar_module_manager *mod_mgr = CALLOC(struct stellar_module_manager, 1);
|
||||
struct module_manager *mod_mgr = CALLOC(struct module_manager, 1);
|
||||
mod_mgr->schema.max_thread_num=max_thread_num;
|
||||
mod_mgr->schema.mq_schema=mq_schema;
|
||||
mod_mgr->schema.logger=logger;
|
||||
@@ -63,7 +62,7 @@ struct stellar_module_manager *stellar_module_manager_new(const char *module_spe
|
||||
if (mod_mgr->module_specs[i].on_instance_init_cb)
|
||||
{
|
||||
mod_mgr->module_specs[i].mod = mod_mgr->module_specs[i].on_instance_init_cb(mod_mgr);
|
||||
if (stellar_module_manager_get_module(mod_mgr, mod_mgr->module_specs[i].mod->name) == NULL)
|
||||
if (module_manager_get_module(mod_mgr, mod_mgr->module_specs[i].mod->name) == NULL)
|
||||
{
|
||||
mod_mgr->module_specs[i].init_succ = true;
|
||||
}
|
||||
@@ -122,7 +121,7 @@ MODULE_SPEC_LOAD_END:
|
||||
}
|
||||
|
||||
|
||||
void stellar_module_manager_free(struct stellar_module_manager *mod_mgr)
|
||||
void module_manager_free(struct module_manager *mod_mgr)
|
||||
{
|
||||
if(mod_mgr==NULL)return;
|
||||
if(mod_mgr->module_spec_toml_path)FREE(mod_mgr->module_spec_toml_path);
|
||||
@@ -147,25 +146,25 @@ void stellar_module_manager_free(struct stellar_module_manager *mod_mgr)
|
||||
return;
|
||||
}
|
||||
|
||||
int stellar_module_manager_get_max_thread_num(struct stellar_module_manager*mod_mgr)
|
||||
int module_manager_get_max_thread_num(struct module_manager*mod_mgr)
|
||||
{
|
||||
if(mod_mgr==NULL)return -1;
|
||||
return mod_mgr->schema.max_thread_num;
|
||||
}
|
||||
|
||||
struct mq_schema *stellar_module_manager_get_mq_schema(struct stellar_module_manager *mod_mgr)
|
||||
struct mq_schema *module_manager_get_mq_schema(struct module_manager *mod_mgr)
|
||||
{
|
||||
if(mod_mgr==NULL)return NULL;
|
||||
return mod_mgr->schema.mq_schema;
|
||||
}
|
||||
|
||||
struct logger *stellar_module_manager_get_logger(struct stellar_module_manager *mod_mgr)
|
||||
struct logger *module_manager_get_logger(struct module_manager *mod_mgr)
|
||||
{
|
||||
if(mod_mgr==NULL)return NULL;
|
||||
return mod_mgr->schema.logger;
|
||||
}
|
||||
|
||||
const char *stellar_module_manager_get_toml_path(struct stellar_module_manager *mod_mgr)
|
||||
const char *module_manager_get_toml_path(struct module_manager *mod_mgr)
|
||||
{
|
||||
if(mod_mgr==NULL)return NULL;
|
||||
return mod_mgr->module_spec_toml_path;
|
||||
@@ -174,17 +173,17 @@ const char *stellar_module_manager_get_toml_path(struct stellar_module_manager *
|
||||
__thread int local_thread_id=-1;
|
||||
__thread struct mq_runtime *local_mq_rt=NULL;
|
||||
|
||||
int stellar_module_manager_get_thread_id(struct stellar_module_manager* mod_mgr __unused)
|
||||
int module_manager_get_thread_id(struct module_manager* mod_mgr __unused)
|
||||
{
|
||||
return local_thread_id;
|
||||
}
|
||||
|
||||
struct mq_runtime *stellar_module_manager_get_mq_runtime(struct stellar_module_manager *mod_mgr __unused)
|
||||
struct mq_runtime *module_manager_get_mq_runtime(struct module_manager *mod_mgr __unused)
|
||||
{
|
||||
return local_mq_rt;
|
||||
}
|
||||
|
||||
void stellar_module_manager_register_thread(struct stellar_module_manager* mod_mgr, int thread_id, struct mq_runtime *mq_rt)
|
||||
void module_manager_register_thread(struct module_manager* mod_mgr, int thread_id, struct mq_runtime *mq_rt)
|
||||
{
|
||||
local_thread_id=thread_id;
|
||||
local_mq_rt=mq_rt;
|
||||
@@ -200,7 +199,7 @@ void stellar_module_manager_register_thread(struct stellar_module_manager* mod_m
|
||||
return;
|
||||
}
|
||||
|
||||
void stellar_module_manager_unregister_thread(struct stellar_module_manager *mod_mgr, int thread_id)
|
||||
void module_manager_unregister_thread(struct module_manager *mod_mgr, int thread_id)
|
||||
{
|
||||
assert(local_thread_id==thread_id);
|
||||
for(int i=0; i<mod_mgr->load_module_num; i++)
|
||||
@@ -216,7 +215,7 @@ void stellar_module_manager_unregister_thread(struct stellar_module_manager *mod
|
||||
return;
|
||||
}
|
||||
|
||||
struct stellar_module *stellar_module_manager_get_module(struct stellar_module_manager *mod_mgr, const char *module_name)
|
||||
struct module *module_manager_get_module(struct module_manager *mod_mgr, const char *module_name)
|
||||
{
|
||||
if(mod_mgr==NULL || module_name == NULL)return NULL;
|
||||
if (mod_mgr->module_specs)
|
||||
@@ -238,41 +237,41 @@ struct stellar_module *stellar_module_manager_get_module(struct stellar_module_m
|
||||
*******************************************/
|
||||
|
||||
|
||||
struct stellar_module *stellar_module_new(const char *name, void *ctx)
|
||||
struct module *module_new(const char *name, void *ctx)
|
||||
{
|
||||
struct stellar_module *mod = CALLOC(struct stellar_module, 1);
|
||||
struct module *mod = CALLOC(struct module, 1);
|
||||
memcpy(mod->name, name, MIN(NAME_MAX, strlen(name)));
|
||||
mod->module_ctx=ctx;
|
||||
return mod;
|
||||
}
|
||||
|
||||
void stellar_module_free(struct stellar_module *mod)
|
||||
void module_free(struct module *mod)
|
||||
{
|
||||
if(mod==NULL)return;
|
||||
FREE(mod);
|
||||
return;
|
||||
}
|
||||
|
||||
void * stellar_module_get_ctx(struct stellar_module *mod)
|
||||
void * module_get_ctx(struct module *mod)
|
||||
{
|
||||
if(mod==NULL)return NULL;
|
||||
return mod->module_ctx;
|
||||
}
|
||||
|
||||
void stellar_module_set_ctx(struct stellar_module *mod, void *ctx)
|
||||
void module_set_ctx(struct module *mod, void *ctx)
|
||||
{
|
||||
if(mod==NULL)return;
|
||||
mod->module_ctx=ctx;
|
||||
return;
|
||||
}
|
||||
|
||||
const char *stellar_module_get_name(struct stellar_module* mod)
|
||||
const char *module_get_name(struct module* mod)
|
||||
{
|
||||
if(mod==NULL)return NULL;
|
||||
return mod->name;
|
||||
}
|
||||
|
||||
void stellar_module_set_name(struct stellar_module* mod, const char *name)
|
||||
void module_set_name(struct module* mod, const char *name)
|
||||
{
|
||||
if(mod==NULL)return;
|
||||
memcpy(mod->name, name, MIN(NAME_MAX, strlen(name)));
|
||||
@@ -293,15 +292,15 @@ static void on_polling_dispatch(int topic_id __unused,
|
||||
void *on_msg_cb_arg,
|
||||
void *dispatch_arg)
|
||||
{
|
||||
struct stellar_module_manager *mod_mgr=(struct stellar_module_manager *)dispatch_arg;
|
||||
struct module_manager *mod_mgr=(struct module_manager *)dispatch_arg;
|
||||
module_on_polling_func *polling = (module_on_polling_func *)on_msg_cb;
|
||||
polling(mod_mgr, on_msg_cb_arg);
|
||||
}
|
||||
|
||||
int stellar_module_manager_polling_subscribe(struct stellar_module_manager *mod_mgr, module_on_polling_func on_polling, void *polling_arg)
|
||||
int module_manager_polling_subscribe(struct module_manager *mod_mgr, module_on_polling_func on_polling, void *polling_arg)
|
||||
{
|
||||
if(mod_mgr == NULL)return -1;
|
||||
mod_mgr->topic_polling_id=mq_schema_get_topic_id(stellar_module_manager_get_mq_schema(mod_mgr), TOPIC_POLLING);
|
||||
mod_mgr->topic_polling_id=mq_schema_get_topic_id(module_manager_get_mq_schema(mod_mgr), TOPIC_POLLING);
|
||||
if(mod_mgr->topic_polling_id<0)
|
||||
{
|
||||
mod_mgr->topic_polling_id=mq_schema_create_topic(mod_mgr->schema.mq_schema, TOPIC_POLLING, on_polling_dispatch, mod_mgr, NULL, NULL);
|
||||
@@ -311,17 +310,17 @@ int stellar_module_manager_polling_subscribe(struct stellar_module_manager *mod_
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
void stellar_module_manager_polling_active(struct stellar_module_manager *mod_mgr)
|
||||
void module_manager_polling_active(struct module_manager *mod_mgr)
|
||||
{
|
||||
if(mod_mgr == NULL)return;
|
||||
mq_runtime_publish_message(local_mq_rt, mod_mgr->topic_polling_id, NULL);
|
||||
}
|
||||
|
||||
|
||||
void stellar_polling_dispatch(struct stellar_module_manager *mod_mgr)
|
||||
void stellar_polling_dispatch(struct module_manager *mod_mgr)
|
||||
{
|
||||
if(mod_mgr==NULL)return;
|
||||
stellar_module_manager_polling_active(mod_mgr);
|
||||
module_manager_polling_active(mod_mgr);
|
||||
mq_runtime_dispatch(local_mq_rt);
|
||||
return;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "stellar/module_manager.h"
|
||||
#include "stellar/module.h"
|
||||
|
||||
#include "stellar/mq.h"
|
||||
|
||||
@@ -13,7 +13,7 @@ extern "C"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct stellar_module
|
||||
struct module
|
||||
{
|
||||
char name[NAME_MAX];
|
||||
void *module_ctx;
|
||||
@@ -21,7 +21,7 @@ struct stellar_module
|
||||
|
||||
struct module_spec_load
|
||||
{
|
||||
struct stellar_module *mod;
|
||||
struct module *mod;
|
||||
module_on_instance_init_func *on_instance_init_cb;
|
||||
module_on_instance_exit_func *on_instance_exit_cb;
|
||||
module_on_thread_init_func *on_thread_init_cb;
|
||||
@@ -35,7 +35,7 @@ struct module_spec_load
|
||||
}__attribute__((aligned(sizeof(void*))));
|
||||
|
||||
|
||||
struct stellar_module_manager
|
||||
struct module_manager
|
||||
{
|
||||
char *module_spec_toml_path;
|
||||
struct module_spec_load *module_specs;
|
||||
@@ -50,7 +50,7 @@ struct stellar_module_manager
|
||||
|
||||
}__attribute__((aligned(sizeof(void*))));
|
||||
|
||||
void stellar_polling_dispatch(struct stellar_module_manager *mod_mgr);
|
||||
void stellar_polling_dispatch(struct module_manager *mod_mgr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* TEST MODUEL MANAGER INTERNAL API *
|
||||
***********************************/
|
||||
|
||||
extern "C" struct stellar_module *gtest_mock_init(struct stellar_module_manager *mod_mgr){return NULL;}
|
||||
extern "C" void gtest_mock_exit(struct stellar_module_manager *mod_mgr, struct stellar_module *mod){}
|
||||
extern "C" struct module *gtest_mock_init(struct module_manager *mod_mgr){return NULL;}
|
||||
extern "C" void gtest_mock_exit(struct module_manager *mod_mgr, struct module *mod){}
|
||||
const char *gtest_mock_spec_toml =
|
||||
"[[module]]\n"
|
||||
"path = \"\"\n"
|
||||
@@ -31,18 +31,18 @@ TEST(module_manager_internal, stellar_module_manager_new_with_toml) {
|
||||
write(fd, gtest_mock_spec_toml, strlen(gtest_mock_spec_toml));
|
||||
close(fd);
|
||||
|
||||
struct stellar_module_manager *mod_mgr=stellar_module_manager_new(toml_template, 10, mq_schema, NULL);
|
||||
struct module_manager *mod_mgr=module_manager_new(toml_template, 10, mq_schema, NULL);
|
||||
|
||||
EXPECT_TRUE(mod_mgr!=NULL);
|
||||
EXPECT_TRUE(stellar_module_manager_get_module(mod_mgr, "test")==NULL);
|
||||
EXPECT_EQ(stellar_module_manager_get_max_thread_num(mod_mgr), 10);
|
||||
EXPECT_EQ(stellar_module_manager_get_mq_schema(mod_mgr), mq_schema);
|
||||
EXPECT_STREQ(stellar_module_manager_get_toml_path(mod_mgr), toml_template);
|
||||
EXPECT_TRUE(module_manager_get_module(mod_mgr, "test")==NULL);
|
||||
EXPECT_EQ(module_manager_get_max_thread_num(mod_mgr), 10);
|
||||
EXPECT_EQ(module_manager_get_mq_schema(mod_mgr), mq_schema);
|
||||
EXPECT_STREQ(module_manager_get_toml_path(mod_mgr), toml_template);
|
||||
|
||||
EXPECT_EQ(stellar_module_manager_get_thread_id(mod_mgr), -1);// no thread registered
|
||||
EXPECT_TRUE(stellar_module_manager_get_mq_runtime(mod_mgr)==NULL);
|
||||
EXPECT_EQ(module_manager_get_thread_id(mod_mgr), -1);// no thread registered
|
||||
EXPECT_TRUE(module_manager_get_mq_runtime(mod_mgr)==NULL);
|
||||
|
||||
stellar_module_manager_free(mod_mgr);
|
||||
module_manager_free(mod_mgr);
|
||||
|
||||
unlink(toml_template);
|
||||
}
|
||||
@@ -53,16 +53,16 @@ TEST(module_manager_internal, stellar_module_manager_new_with_toml) {
|
||||
|
||||
TEST(stellar_module, basic_new_and_free) {
|
||||
|
||||
struct stellar_module *mod = stellar_module_new("test", NULL);
|
||||
struct module *mod = module_new("test", NULL);
|
||||
EXPECT_TRUE(mod!=NULL);
|
||||
|
||||
stellar_module_set_name(mod, "test1");
|
||||
EXPECT_STREQ(stellar_module_get_name(mod), "test1");
|
||||
module_set_name(mod, "test1");
|
||||
EXPECT_STREQ(module_get_name(mod), "test1");
|
||||
|
||||
stellar_module_set_ctx(mod, (void*)1);
|
||||
EXPECT_EQ((long)stellar_module_get_ctx(mod), 1);
|
||||
module_set_ctx(mod, (void*)1);
|
||||
EXPECT_EQ((long)module_get_ctx(mod), 1);
|
||||
|
||||
stellar_module_free(mod);
|
||||
module_free(mod);
|
||||
}
|
||||
|
||||
/***********************************
|
||||
@@ -72,57 +72,57 @@ TEST(stellar_module, basic_new_and_free) {
|
||||
TEST(stellar_module_manager, new_with_null_toml) {
|
||||
|
||||
struct mq_schema *mq_schema=NULL;
|
||||
struct stellar_module_manager *mod_mgr = stellar_module_manager_new(NULL, 10, mq_schema, NULL);
|
||||
struct module_manager *mod_mgr = module_manager_new(NULL, 10, mq_schema, NULL);
|
||||
EXPECT_TRUE(mod_mgr!=NULL);
|
||||
EXPECT_TRUE(stellar_module_manager_get_module(mod_mgr, "test")==NULL);
|
||||
EXPECT_EQ(stellar_module_manager_get_max_thread_num(mod_mgr), 10);
|
||||
EXPECT_EQ(stellar_module_manager_get_mq_schema(mod_mgr), mq_schema);
|
||||
EXPECT_TRUE(module_manager_get_module(mod_mgr, "test")==NULL);
|
||||
EXPECT_EQ(module_manager_get_max_thread_num(mod_mgr), 10);
|
||||
EXPECT_EQ(module_manager_get_mq_schema(mod_mgr), mq_schema);
|
||||
|
||||
EXPECT_TRUE(stellar_module_manager_get_mq_runtime(mod_mgr)==NULL);
|
||||
EXPECT_EQ(stellar_module_manager_get_thread_id(mod_mgr), -1);// no thread registered
|
||||
EXPECT_TRUE(module_manager_get_mq_runtime(mod_mgr)==NULL);
|
||||
EXPECT_EQ(module_manager_get_thread_id(mod_mgr), -1);// no thread registered
|
||||
|
||||
stellar_module_manager_free(mod_mgr);
|
||||
module_manager_free(mod_mgr);
|
||||
}
|
||||
|
||||
TEST(stellar_module_manager, new_with_empty_toml) {
|
||||
|
||||
struct mq_schema *mq_schema=NULL;
|
||||
struct stellar_module_manager *mod_mgr = stellar_module_manager_new("/dev/null", 10, mq_schema, NULL);
|
||||
struct module_manager *mod_mgr = module_manager_new("/dev/null", 10, mq_schema, NULL);
|
||||
EXPECT_TRUE(mod_mgr!=NULL);
|
||||
EXPECT_TRUE(stellar_module_manager_get_module(mod_mgr, "test")==NULL);
|
||||
EXPECT_EQ(stellar_module_manager_get_max_thread_num(mod_mgr), 10);
|
||||
EXPECT_EQ(stellar_module_manager_get_mq_schema(mod_mgr), mq_schema);
|
||||
EXPECT_TRUE(module_manager_get_module(mod_mgr, "test")==NULL);
|
||||
EXPECT_EQ(module_manager_get_max_thread_num(mod_mgr), 10);
|
||||
EXPECT_EQ(module_manager_get_mq_schema(mod_mgr), mq_schema);
|
||||
|
||||
EXPECT_EQ(stellar_module_manager_get_thread_id(mod_mgr), -1);// no thread registered
|
||||
EXPECT_TRUE(stellar_module_manager_get_mq_runtime(mod_mgr)==NULL);
|
||||
EXPECT_EQ(module_manager_get_thread_id(mod_mgr), -1);// no thread registered
|
||||
EXPECT_TRUE(module_manager_get_mq_runtime(mod_mgr)==NULL);
|
||||
|
||||
stellar_module_manager_free(mod_mgr);
|
||||
module_manager_free(mod_mgr);
|
||||
}
|
||||
|
||||
TEST(stellar_module_manager, register_thread) {
|
||||
|
||||
struct mq_schema *mq_schema=(struct mq_schema*)1;
|
||||
struct stellar_module_manager *mod_mgr=stellar_module_manager_new(NULL, 10, mq_schema, NULL);
|
||||
struct module_manager *mod_mgr=module_manager_new(NULL, 10, mq_schema, NULL);
|
||||
|
||||
EXPECT_TRUE(mod_mgr!=NULL);
|
||||
|
||||
EXPECT_EQ((long)stellar_module_manager_get_mq_schema(mod_mgr), 1);
|
||||
EXPECT_EQ((long)module_manager_get_mq_schema(mod_mgr), 1);
|
||||
|
||||
EXPECT_EQ(stellar_module_manager_get_thread_id(mod_mgr), -1);// no thread registered
|
||||
EXPECT_TRUE(stellar_module_manager_get_mq_runtime(mod_mgr)==NULL);
|
||||
EXPECT_EQ(module_manager_get_thread_id(mod_mgr), -1);// no thread registered
|
||||
EXPECT_TRUE(module_manager_get_mq_runtime(mod_mgr)==NULL);
|
||||
|
||||
struct mq_runtime *mq_rt = (struct mq_runtime*)2;
|
||||
stellar_module_manager_register_thread(mod_mgr, 1, mq_rt);
|
||||
module_manager_register_thread(mod_mgr, 1, mq_rt);
|
||||
|
||||
EXPECT_EQ(stellar_module_manager_get_thread_id(mod_mgr), 1);
|
||||
EXPECT_EQ((long)stellar_module_manager_get_mq_runtime(mod_mgr), 2);
|
||||
EXPECT_EQ(module_manager_get_thread_id(mod_mgr), 1);
|
||||
EXPECT_EQ((long)module_manager_get_mq_runtime(mod_mgr), 2);
|
||||
|
||||
stellar_module_manager_unregister_thread(mod_mgr, 1);
|
||||
module_manager_unregister_thread(mod_mgr, 1);
|
||||
|
||||
EXPECT_EQ(stellar_module_manager_get_thread_id(mod_mgr), -1);
|
||||
EXPECT_EQ((long)stellar_module_manager_get_mq_runtime(mod_mgr), 0);
|
||||
EXPECT_EQ(module_manager_get_thread_id(mod_mgr), -1);
|
||||
EXPECT_EQ((long)module_manager_get_mq_runtime(mod_mgr), 0);
|
||||
|
||||
stellar_module_manager_free(mod_mgr);
|
||||
module_manager_free(mod_mgr);
|
||||
|
||||
}
|
||||
|
||||
@@ -130,38 +130,38 @@ TEST(stellar_module_manager, register_thread) {
|
||||
* TEST MODULE MANAGER API *
|
||||
***********************************/
|
||||
|
||||
extern "C" struct stellar_module *gtest_module_init(struct stellar_module_manager *mod_mgr)
|
||||
extern "C" struct module *gtest_module_init(struct module_manager *mod_mgr)
|
||||
{
|
||||
struct stellar_module *mod = stellar_module_new("gtest", NULL);
|
||||
EXPECT_STREQ(stellar_module_get_name(mod), "gtest");
|
||||
stellar_module_set_ctx(mod, (void*)1);
|
||||
struct module *mod = module_new("gtest", NULL);
|
||||
EXPECT_STREQ(module_get_name(mod), "gtest");
|
||||
module_set_ctx(mod, (void*)1);
|
||||
|
||||
return mod;
|
||||
}
|
||||
|
||||
extern "C" void gtest_module_exit(struct stellar_module_manager *mod_mgr, struct stellar_module *mod)
|
||||
extern "C" void gtest_module_exit(struct module_manager *mod_mgr, struct module *mod)
|
||||
{
|
||||
EXPECT_STREQ(stellar_module_get_name(mod), "gtest");
|
||||
EXPECT_EQ((long)stellar_module_get_ctx(mod), 1);
|
||||
EXPECT_STREQ(module_get_name(mod), "gtest");
|
||||
EXPECT_EQ((long)module_get_ctx(mod), 1);
|
||||
|
||||
EXPECT_EQ(stellar_module_manager_get_module(mod_mgr, "gtest"), mod);
|
||||
EXPECT_EQ(module_manager_get_module(mod_mgr, "gtest"), mod);
|
||||
|
||||
EXPECT_EQ(stellar_module_manager_get_thread_id(mod_mgr), -1);
|
||||
EXPECT_EQ((long)stellar_module_manager_get_mq_runtime(mod_mgr), 0);
|
||||
EXPECT_EQ(module_manager_get_thread_id(mod_mgr), -1);
|
||||
EXPECT_EQ((long)module_manager_get_mq_runtime(mod_mgr), 0);
|
||||
|
||||
stellar_module_free(mod);
|
||||
module_free(mod);
|
||||
}
|
||||
|
||||
extern "C" void gtest_thread_init(struct stellar_module_manager *mod_mgr, int thread_id, struct stellar_module *mod)
|
||||
extern "C" void gtest_thread_init(struct module_manager *mod_mgr, int thread_id, struct module *mod)
|
||||
{
|
||||
EXPECT_STREQ(stellar_module_get_name(mod), "gtest");
|
||||
EXPECT_EQ((long)stellar_module_get_ctx(mod), 1);
|
||||
EXPECT_STREQ(module_get_name(mod), "gtest");
|
||||
EXPECT_EQ((long)module_get_ctx(mod), 1);
|
||||
}
|
||||
|
||||
extern "C" void gtest_thread_exit(struct stellar_module_manager *mod_mgr, int thread_id, struct stellar_module *mod)
|
||||
extern "C" void gtest_thread_exit(struct module_manager *mod_mgr, int thread_id, struct module *mod)
|
||||
{
|
||||
EXPECT_STREQ(stellar_module_get_name(mod), "gtest");
|
||||
EXPECT_EQ((long)stellar_module_get_ctx(mod), 1);
|
||||
EXPECT_STREQ(module_get_name(mod), "gtest");
|
||||
EXPECT_EQ((long)module_get_ctx(mod), 1);
|
||||
}
|
||||
|
||||
const char *gtest_module_spec_toml =
|
||||
@@ -182,26 +182,26 @@ TEST(module_manager, basic_module) {
|
||||
write(fd, gtest_module_spec_toml, strlen(gtest_module_spec_toml));
|
||||
close(fd);
|
||||
|
||||
struct stellar_module_manager *mod_mgr=stellar_module_manager_new(toml_template, 10, mq_schema, NULL);
|
||||
struct module_manager *mod_mgr=module_manager_new(toml_template, 10, mq_schema, NULL);
|
||||
EXPECT_TRUE(mod_mgr!=NULL);
|
||||
|
||||
EXPECT_TRUE(stellar_module_manager_get_module(mod_mgr, "gtest")!=NULL);
|
||||
EXPECT_TRUE(module_manager_get_module(mod_mgr, "gtest")!=NULL);
|
||||
|
||||
EXPECT_EQ(stellar_module_manager_get_max_thread_num(mod_mgr), 10);
|
||||
EXPECT_EQ((long)stellar_module_manager_get_mq_schema(mod_mgr), 1);
|
||||
EXPECT_STREQ(stellar_module_manager_get_toml_path(mod_mgr), toml_template);
|
||||
EXPECT_EQ(module_manager_get_max_thread_num(mod_mgr), 10);
|
||||
EXPECT_EQ((long)module_manager_get_mq_schema(mod_mgr), 1);
|
||||
EXPECT_STREQ(module_manager_get_toml_path(mod_mgr), toml_template);
|
||||
|
||||
struct mq_runtime *mq_rt = (struct mq_runtime*)2;
|
||||
stellar_module_manager_register_thread(mod_mgr, 1, mq_rt);
|
||||
module_manager_register_thread(mod_mgr, 1, mq_rt);
|
||||
|
||||
EXPECT_EQ((long)stellar_module_manager_get_thread_id(mod_mgr), 1);
|
||||
EXPECT_EQ((long)stellar_module_manager_get_mq_runtime(mod_mgr), 2);
|
||||
EXPECT_EQ((long)module_manager_get_thread_id(mod_mgr), 1);
|
||||
EXPECT_EQ((long)module_manager_get_mq_runtime(mod_mgr), 2);
|
||||
|
||||
stellar_module_manager_unregister_thread(mod_mgr, 1);
|
||||
EXPECT_EQ((long)stellar_module_manager_get_thread_id(mod_mgr), -1);
|
||||
EXPECT_EQ((long)stellar_module_manager_get_mq_runtime(mod_mgr), 0);
|
||||
module_manager_unregister_thread(mod_mgr, 1);
|
||||
EXPECT_EQ((long)module_manager_get_thread_id(mod_mgr), -1);
|
||||
EXPECT_EQ((long)module_manager_get_mq_runtime(mod_mgr), 0);
|
||||
|
||||
stellar_module_manager_free(mod_mgr);
|
||||
module_manager_free(mod_mgr);
|
||||
unlink(toml_template);
|
||||
}
|
||||
|
||||
@@ -216,13 +216,13 @@ struct test_module_polling_env
|
||||
int polling_active_count;
|
||||
};
|
||||
|
||||
void test_module_on_polling(struct stellar_module_manager* mod_mgr, void *polling_arg)
|
||||
void test_module_on_polling(struct module_manager* mod_mgr, void *polling_arg)
|
||||
{
|
||||
struct test_module_polling_env *env = (struct test_module_polling_env*)polling_arg;
|
||||
env->polling_count++;
|
||||
if(env->polling_count%2==0)
|
||||
{
|
||||
stellar_module_manager_polling_active(mod_mgr);
|
||||
module_manager_polling_active(mod_mgr);
|
||||
env->polling_active_count++;
|
||||
}
|
||||
}
|
||||
@@ -232,34 +232,34 @@ TEST(module_manager, basic_polling_module) {
|
||||
|
||||
struct mq_schema *mq_schema=mq_schema_new();
|
||||
|
||||
struct stellar_module_manager *mod_mgr=stellar_module_manager_new(NULL, 10, mq_schema, NULL);
|
||||
struct module_manager *mod_mgr=module_manager_new(NULL, 10, mq_schema, NULL);
|
||||
EXPECT_TRUE(mod_mgr!=NULL);
|
||||
|
||||
|
||||
EXPECT_EQ(stellar_module_manager_get_max_thread_num(mod_mgr), 10);
|
||||
EXPECT_EQ(stellar_module_manager_get_mq_schema(mod_mgr), mq_schema);
|
||||
EXPECT_EQ(module_manager_get_max_thread_num(mod_mgr), 10);
|
||||
EXPECT_EQ(module_manager_get_mq_schema(mod_mgr), mq_schema);
|
||||
|
||||
struct test_module_polling_env env={};
|
||||
env.N_round=10;
|
||||
|
||||
stellar_module_manager_polling_subscribe(mod_mgr, test_module_on_polling, &env);
|
||||
module_manager_polling_subscribe(mod_mgr, test_module_on_polling, &env);
|
||||
|
||||
struct mq_runtime *mq_rt = mq_runtime_new(mq_schema);
|
||||
stellar_module_manager_register_thread(mod_mgr, 1, mq_rt);
|
||||
module_manager_register_thread(mod_mgr, 1, mq_rt);
|
||||
|
||||
EXPECT_EQ((long)stellar_module_manager_get_thread_id(mod_mgr), 1);
|
||||
EXPECT_EQ(stellar_module_manager_get_mq_runtime(mod_mgr), mq_rt);
|
||||
EXPECT_EQ((long)module_manager_get_thread_id(mod_mgr), 1);
|
||||
EXPECT_EQ(module_manager_get_mq_runtime(mod_mgr), mq_rt);
|
||||
|
||||
for(int i=0; i<env.N_round; i++)
|
||||
{
|
||||
stellar_polling_dispatch(mod_mgr);
|
||||
}
|
||||
|
||||
stellar_module_manager_unregister_thread(mod_mgr, 1);
|
||||
module_manager_unregister_thread(mod_mgr, 1);
|
||||
|
||||
mq_runtime_free(mq_rt);
|
||||
mq_schema_free(mq_schema);
|
||||
stellar_module_manager_free(mod_mgr);
|
||||
module_manager_free(mod_mgr);
|
||||
|
||||
EXPECT_EQ(env.polling_count, env.N_round+env.polling_active_count);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "packet_manager.h"
|
||||
#include "fieldstat/fieldstat_easy.h"
|
||||
|
||||
#define PACKET_MANAGER_MODULE_NAME "packet_manager_module"
|
||||
|
||||
|
||||
#define PACKET_MANAGER_LOG_ERROR(format, ...) STELLAR_LOG_ERROR(__thread_local_logger, "packet manager", format, ##__VA_ARGS__)
|
||||
#define PACKET_MANAGER_LOG_FATAL(format, ...) STELLAR_LOG_FATAL(__thread_local_logger, "packet manager", format, ##__VA_ARGS__)
|
||||
@@ -436,10 +436,10 @@ void packet_manager_print_stat(struct packet_manager *pkt_mgr, uint16_t thread_i
|
||||
* packet manager module
|
||||
******************************************************************************/
|
||||
|
||||
static void on_polling(struct stellar_module_manager *mod_mgr, void *args)
|
||||
static void on_polling(struct module_manager *mod_mgr, void *args)
|
||||
{
|
||||
uint64_t now_ms = clock_get_real_time_ms();
|
||||
int thread_id = stellar_module_manager_get_thread_id(mod_mgr);
|
||||
int thread_id = module_manager_get_thread_id(mod_mgr);
|
||||
struct packet_manager *pkt_mgr = (struct packet_manager *)args;
|
||||
|
||||
static __thread uint64_t last_sync_stat_ms = 0;
|
||||
@@ -457,61 +457,57 @@ static void on_polling(struct stellar_module_manager *mod_mgr, void *args)
|
||||
}
|
||||
}
|
||||
|
||||
struct packet_manager *stellar_module_get_packet_manager(struct stellar_module_manager *mod_mgr)
|
||||
struct packet_manager *module_to_packet_manager(struct module *mod)
|
||||
{
|
||||
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);
|
||||
assert(mod);
|
||||
assert(strcmp(module_get_name(mod), PACKET_MANAGER_MODULE_NAME) == 0);
|
||||
return (struct packet_manager *)module_get_ctx(mod);
|
||||
}
|
||||
|
||||
struct stellar_module *packet_manager_on_init(struct stellar_module_manager *mod_mgr)
|
||||
struct module *packet_manager_on_init(struct module_manager *mod_mgr)
|
||||
{
|
||||
assert(mod_mgr);
|
||||
struct mq_schema *mq_sche = stellar_module_manager_get_mq_schema(mod_mgr);
|
||||
struct mq_schema *mq_sche = module_manager_get_mq_schema(mod_mgr);
|
||||
assert(mq_sche);
|
||||
uint16_t thread_num = stellar_module_manager_get_max_thread_num(mod_mgr);
|
||||
uint16_t thread_num = module_manager_get_max_thread_num(mod_mgr);
|
||||
|
||||
struct packet_manager *pkt_mgr = packet_manager_new(mq_sche, thread_num);
|
||||
if (pkt_mgr == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
stellar_module_manager_polling_subscribe(mod_mgr, on_polling, pkt_mgr);
|
||||
module_manager_polling_subscribe(mod_mgr, on_polling, pkt_mgr);
|
||||
|
||||
struct stellar_module *pkt_mgr_mod = stellar_module_new(PACKET_MANAGER_MODULE_NAME, NULL);
|
||||
struct module *pkt_mgr_mod = module_new(PACKET_MANAGER_MODULE_NAME, NULL);
|
||||
if (pkt_mgr_mod == NULL)
|
||||
{
|
||||
PACKET_MANAGER_LOG_ERROR("failed to create packet_manager");
|
||||
packet_manager_free(pkt_mgr);
|
||||
return NULL;
|
||||
}
|
||||
stellar_module_set_ctx(pkt_mgr_mod, pkt_mgr);
|
||||
module_set_ctx(pkt_mgr_mod, pkt_mgr);
|
||||
|
||||
PACKET_MANAGER_LOG_FATAL("packet_manager init");
|
||||
return pkt_mgr_mod;
|
||||
}
|
||||
|
||||
void packet_manager_on_exit(struct stellar_module_manager *mod_mgr __attribute__((unused)), struct stellar_module *mod)
|
||||
void packet_manager_on_exit(struct module_manager *mod_mgr __attribute__((unused)), struct module *mod)
|
||||
{
|
||||
if (mod)
|
||||
{
|
||||
struct packet_manager *pkt_mgr = stellar_module_get_ctx(mod);
|
||||
struct packet_manager *pkt_mgr = module_get_ctx(mod);
|
||||
|
||||
packet_manager_free(pkt_mgr);
|
||||
stellar_module_free(mod);
|
||||
module_free(mod);
|
||||
PACKET_MANAGER_LOG_FATAL("packet_manager exit");
|
||||
}
|
||||
}
|
||||
|
||||
struct stellar_module *packet_manager_on_thread_init(struct stellar_module_manager *mod_mgr, int thread_id, struct stellar_module *mod)
|
||||
struct module *packet_manager_on_thread_init(struct module_manager *mod_mgr, int thread_id, struct module *mod)
|
||||
{
|
||||
struct packet_manager *pkt_mgr = stellar_module_get_ctx(mod);
|
||||
struct packet_manager *pkt_mgr = module_get_ctx(mod);
|
||||
assert(pkt_mgr);
|
||||
struct mq_runtime *mq_rte = stellar_module_manager_get_mq_runtime(mod_mgr);
|
||||
struct mq_runtime *mq_rte = module_manager_get_mq_runtime(mod_mgr);
|
||||
assert(mq_rte);
|
||||
assert(thread_id < pkt_mgr->thread_num);
|
||||
|
||||
@@ -526,9 +522,9 @@ struct stellar_module *packet_manager_on_thread_init(struct stellar_module_manag
|
||||
}
|
||||
}
|
||||
|
||||
void packet_manager_on_thread_exit(struct stellar_module_manager *mod_mgr __attribute__((unused)), int thread_id, struct stellar_module *mod)
|
||||
void packet_manager_on_thread_exit(struct module_manager *mod_mgr __attribute__((unused)), int thread_id, struct module *mod)
|
||||
{
|
||||
struct packet_manager *pkt_mgr = stellar_module_get_ctx(mod);
|
||||
struct packet_manager *pkt_mgr = module_get_ctx(mod);
|
||||
assert(pkt_mgr);
|
||||
assert(thread_id < pkt_mgr->thread_num);
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "fieldstat/fieldstat_easy.h"
|
||||
|
||||
#define CLEAN_SESSION_BURST 1024
|
||||
#define SESSION_MANAGER_MODULE_NAME "session_manager_module"
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
||||
@@ -33,7 +32,7 @@ struct session_manager
|
||||
struct session_manager_sche *sche;
|
||||
struct session_manager_rte *rte[MAX_THREAD_NUM];
|
||||
struct mq_runtime *mq[MAX_THREAD_NUM];
|
||||
struct stellar_module_manager *mod_mgr;
|
||||
struct module_manager *mod_mgr;
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
@@ -94,7 +93,7 @@ static void on_sess_msg_free(void *msg, void *args)
|
||||
if (session_get_current_state(sess) == SESSION_STATE_CLOSED)
|
||||
{
|
||||
struct session_manager *sess_mgr = (struct session_manager *)args;
|
||||
int thread_id = stellar_module_manager_get_thread_id(sess_mgr->mod_mgr);
|
||||
int thread_id = module_manager_get_thread_id(sess_mgr->mod_mgr);
|
||||
struct session_manager_rte *sess_mgr_rte = sess_mgr->rte[thread_id];
|
||||
|
||||
char buffer[4096] = {0};
|
||||
@@ -118,7 +117,7 @@ static void on_tcp_payload_msg_free(void *msg, void *args)
|
||||
static void on_packet_forward(struct packet *pkt, enum packet_stage stage, void *args)
|
||||
{
|
||||
struct session_manager *sess_mgr = (struct session_manager *)args;
|
||||
int thread_id = stellar_module_manager_get_thread_id(sess_mgr->mod_mgr);
|
||||
int thread_id = module_manager_get_thread_id(sess_mgr->mod_mgr);
|
||||
struct mq_runtime *mq_rte = sess_mgr->mq[thread_id];
|
||||
struct session_manager_rte *sess_mgr_rte = sess_mgr->rte[thread_id];
|
||||
|
||||
@@ -209,7 +208,7 @@ fast_path:
|
||||
static void on_packet_output(struct packet *pkt, enum packet_stage stage, void *args)
|
||||
{
|
||||
struct session_manager *sess_mgr = (struct session_manager *)args;
|
||||
int thread_id = stellar_module_manager_get_thread_id(sess_mgr->mod_mgr);
|
||||
int thread_id = module_manager_get_thread_id(sess_mgr->mod_mgr);
|
||||
struct session_manager_rte *sess_mgr_rte = sess_mgr->rte[thread_id];
|
||||
|
||||
struct session *sess = (struct session *)packet_get_exdata(pkt, sess_mgr->sche->pkt_ex_id);
|
||||
@@ -254,11 +253,11 @@ static void on_packet_output(struct packet *pkt, enum packet_stage stage, void *
|
||||
}
|
||||
}
|
||||
|
||||
static void on_polling(struct stellar_module_manager *mod_mgr, void *args)
|
||||
static void on_polling(struct module_manager *mod_mgr, void *args)
|
||||
{
|
||||
uint64_t now_ms = clock_get_real_time_ms();
|
||||
struct session_manager *sess_mgr = (struct session_manager *)args;
|
||||
int thread_id = stellar_module_manager_get_thread_id(mod_mgr);
|
||||
int thread_id = module_manager_get_thread_id(mod_mgr);
|
||||
struct session_manager_rte *sess_mgr_rte = sess_mgr->rte[thread_id];
|
||||
struct session_manager_stat *sess_mgr_stat = session_manager_rte_get_stat(sess_mgr_rte);
|
||||
|
||||
@@ -523,25 +522,22 @@ void session_manager_clean(struct session_manager *sess_mgr, uint16_t thread_id)
|
||||
* session manager module
|
||||
******************************************************************************/
|
||||
|
||||
struct session_manager *stellar_module_get_session_manager(struct stellar_module_manager *mod_mgr)
|
||||
struct session_manager *module_to_session_manager(struct module *mod)
|
||||
{
|
||||
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);
|
||||
assert(mod);
|
||||
assert(strcmp(module_get_name(mod), SESSION_MANAGER_MODULE_NAME) == 0);
|
||||
return module_get_ctx(mod);
|
||||
}
|
||||
|
||||
struct stellar_module *session_manager_on_init(struct stellar_module_manager *mod_mgr)
|
||||
struct module *session_manager_on_init(struct module_manager *mod_mgr)
|
||||
{
|
||||
assert(mod_mgr);
|
||||
struct packet_manager *pkt_mgr = stellar_module_get_packet_manager(mod_mgr);
|
||||
struct module *pkt_mgr_mod= module_manager_get_module(mod_mgr, PACKET_MANAGER_MODULE_NAME);
|
||||
struct packet_manager *pkt_mgr = module_to_packet_manager(pkt_mgr_mod);
|
||||
assert(pkt_mgr);
|
||||
struct mq_schema *mq_sche = stellar_module_manager_get_mq_schema(mod_mgr);
|
||||
struct mq_schema *mq_sche = module_manager_get_mq_schema(mod_mgr);
|
||||
assert(mq_sche);
|
||||
const char *toml_file = stellar_module_manager_get_toml_path(mod_mgr);
|
||||
const char *toml_file = module_manager_get_toml_path(mod_mgr);
|
||||
assert(toml_file);
|
||||
|
||||
struct session_manager *sess_mgr = session_manager_new(pkt_mgr, mq_sche, toml_file);
|
||||
@@ -549,37 +545,37 @@ struct stellar_module *session_manager_on_init(struct stellar_module_manager *mo
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
stellar_module_manager_polling_subscribe(mod_mgr, on_polling, sess_mgr);
|
||||
module_manager_polling_subscribe(mod_mgr, on_polling, sess_mgr);
|
||||
|
||||
struct stellar_module *sess_mgr_mod = stellar_module_new(SESSION_MANAGER_MODULE_NAME, NULL);
|
||||
struct module *sess_mgr_mod = module_new(SESSION_MANAGER_MODULE_NAME, NULL);
|
||||
if (sess_mgr_mod == NULL)
|
||||
{
|
||||
SESSION_MANAGER_LOG_ERROR("failed to create session_manager");
|
||||
session_manager_free(sess_mgr);
|
||||
return NULL;
|
||||
}
|
||||
stellar_module_set_ctx(sess_mgr_mod, sess_mgr);
|
||||
module_set_ctx(sess_mgr_mod, sess_mgr);
|
||||
|
||||
SESSION_MANAGER_LOG_FATAL("session_manager init");
|
||||
return sess_mgr_mod;
|
||||
}
|
||||
|
||||
void session_manager_on_exit(struct stellar_module_manager *mod_mgr, struct stellar_module *mod)
|
||||
void session_manager_on_exit(struct module_manager *mod_mgr, struct module *mod)
|
||||
{
|
||||
if (mod)
|
||||
{
|
||||
struct session_manager *sess_mgr = stellar_module_get_ctx(mod);
|
||||
struct session_manager *sess_mgr = module_get_ctx(mod);
|
||||
session_manager_free(sess_mgr);
|
||||
stellar_module_free(mod);
|
||||
module_free(mod);
|
||||
SESSION_MANAGER_LOG_FATAL("session_manager exit");
|
||||
}
|
||||
}
|
||||
|
||||
struct stellar_module *session_manager_on_thread_init(struct stellar_module_manager *mod_mgr, int thread_id, struct stellar_module *mod)
|
||||
struct module *session_manager_on_thread_init(struct module_manager *mod_mgr, int thread_id, struct module *mod)
|
||||
{
|
||||
struct session_manager *sess_mgr = stellar_module_get_ctx(mod);
|
||||
struct session_manager *sess_mgr = module_get_ctx(mod);
|
||||
assert(sess_mgr);
|
||||
struct mq_runtime *mq_rte = stellar_module_manager_get_mq_runtime(mod_mgr);
|
||||
struct mq_runtime *mq_rte = module_manager_get_mq_runtime(mod_mgr);
|
||||
assert(mq_rte);
|
||||
|
||||
if (session_manager_init(sess_mgr, thread_id, mq_rte) != 0)
|
||||
@@ -593,9 +589,9 @@ struct stellar_module *session_manager_on_thread_init(struct stellar_module_mana
|
||||
}
|
||||
}
|
||||
|
||||
void session_manager_on_thread_exit(struct stellar_module_manager *mod_mgr, int thread_id, struct stellar_module *mod)
|
||||
void session_manager_on_thread_exit(struct module_manager *mod_mgr, int thread_id, struct module *mod)
|
||||
{
|
||||
struct session_manager *sess_mgr = stellar_module_get_ctx(mod);
|
||||
struct session_manager *sess_mgr = module_get_ctx(mod);
|
||||
assert(sess_mgr);
|
||||
session_manager_clean(sess_mgr, thread_id);
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#include "stellar/stellar.h"
|
||||
#include "stellar/module_manager.h"
|
||||
#include "stellar/module.h"
|
||||
|
||||
#include "packet_io.h"
|
||||
#include "log_internal.h"
|
||||
@@ -37,7 +37,7 @@ struct stellar
|
||||
struct logger *logger;
|
||||
struct packet_io *pkt_io;
|
||||
struct mq_schema *mq_schema;
|
||||
struct stellar_module_manager *mod_mgr;
|
||||
struct module_manager *mod_mgr;
|
||||
struct thread threads[MAX_THREAD_NUM];
|
||||
};
|
||||
|
||||
@@ -51,15 +51,16 @@ static void *worker_thread(void *arg)
|
||||
uint16_t thread_id = thread->idx;
|
||||
struct stellar *st = thread->st;
|
||||
struct packet_io *pkt_io = st->pkt_io;
|
||||
struct stellar_module_manager *mod_mgr = st->mod_mgr;
|
||||
struct module_manager *mod_mgr = st->mod_mgr;
|
||||
struct mq_runtime *mq_rt = mq_runtime_new(st->mq_schema);
|
||||
struct packet_manager *pkt_mgr = stellar_module_get_packet_manager(mod_mgr);
|
||||
struct module *pkt_mgr_mod= module_manager_get_module(mod_mgr, PACKET_MANAGER_MODULE_NAME);
|
||||
struct packet_manager *pkt_mgr = module_to_packet_manager(pkt_mgr_mod);
|
||||
|
||||
snprintf(thread_name, sizeof(thread_name), "stellar:%d", thread_id);
|
||||
prctl(PR_SET_NAME, (unsigned long long)thread_name, NULL, NULL, NULL);
|
||||
|
||||
__thread_local_logger = st->logger;
|
||||
stellar_module_manager_register_thread(mod_mgr, thread_id, mq_rt);
|
||||
module_manager_register_thread(mod_mgr, thread_id, mq_rt);
|
||||
|
||||
ATOMIC_SET(&thread->is_runing, 1);
|
||||
CORE_LOG_FATAL("worker thread %d runing", thread_id);
|
||||
@@ -94,7 +95,7 @@ static void *worker_thread(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
stellar_module_manager_unregister_thread(mod_mgr, thread_id);
|
||||
module_manager_unregister_thread(mod_mgr, thread_id);
|
||||
mq_runtime_free(mq_rt);
|
||||
|
||||
ATOMIC_SET(&thread->is_runing, 0);
|
||||
@@ -172,7 +173,7 @@ struct stellar *stellar_new(const char *toml_file)
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
st->mod_mgr = stellar_module_manager_new(toml_file, st->thread_num, st->mq_schema, st->logger);
|
||||
st->mod_mgr = module_manager_new(toml_file, st->thread_num, st->mq_schema, st->logger);
|
||||
if (st->mod_mgr == NULL)
|
||||
{
|
||||
CORE_LOG_ERROR("unable to create packet manager");
|
||||
@@ -227,7 +228,7 @@ void stellar_free(struct stellar *st)
|
||||
if (st)
|
||||
{
|
||||
packet_io_free(st->pkt_io);
|
||||
stellar_module_manager_free(st->mod_mgr);
|
||||
module_manager_free(st->mod_mgr);
|
||||
mq_schema_free(st->mq_schema);
|
||||
|
||||
CORE_LOG_FATAL("stellar exit\n");
|
||||
|
||||
@@ -52,7 +52,7 @@ global:
|
||||
|
||||
exdata_*;
|
||||
mq_*;
|
||||
stellar_module_*;
|
||||
module_*;
|
||||
|
||||
stellar_new;
|
||||
stellar_run;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "stellar/appid.h"
|
||||
#include "stellar/module_manager.h"
|
||||
#include "stellar/module.h"
|
||||
#include "stellar/session.h"
|
||||
#include "stellar/utils.h"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
struct test_lpip_env
|
||||
{
|
||||
struct stellar_module_manager *mod_mgr;
|
||||
struct module_manager *mod_mgr;
|
||||
struct lpi_plus_mapper *lpi_mapper;
|
||||
int l7_exdata_idx;
|
||||
int session_num;
|
||||
@@ -152,12 +152,13 @@ static void on_session(struct session *sess, enum session_state state, struct pa
|
||||
return;
|
||||
}
|
||||
|
||||
struct stellar_module *gtest_lpip_module_init(struct stellar_module_manager *mod_mgr)
|
||||
struct module *gtest_lpip_module_init(struct module_manager *mod_mgr)
|
||||
{
|
||||
struct test_lpip_env *env = (struct test_lpip_env *)calloc(1, sizeof(struct test_lpip_env));
|
||||
|
||||
env->lpi_mapper=stellar_module_get_lpip(mod_mgr);
|
||||
struct session_manager *sess_mgr = stellar_module_get_session_manager(mod_mgr);
|
||||
struct module *lpip_mod = module_manager_get_module(mod_mgr, LPI_PLUS_MODULE_NAME);
|
||||
env->lpi_mapper=module_to_lpip_mapper(lpip_mod);
|
||||
struct module *sess_mgr_mod=module_manager_get_module(mod_mgr, SESSION_MANAGER_MODULE_NAME);
|
||||
struct session_manager *sess_mgr = module_to_session_manager(sess_mgr_mod);
|
||||
if(sess_mgr == NULL)
|
||||
{
|
||||
perror("gtest_lpi_plugin_load:stellar_module_get_session_manager failed !!!\n");
|
||||
@@ -172,15 +173,15 @@ struct stellar_module *gtest_lpip_module_init(struct stellar_module_manager *mod
|
||||
stellar_appid_subscribe(mod_mgr, gtest_lpip_on_appid_msg, env);
|
||||
printf("gtest_lpip_module_init OK!\n");
|
||||
|
||||
return stellar_module_new("TEST_LPIP", env);
|
||||
return module_new("TEST_LPIP", env);
|
||||
}
|
||||
|
||||
void gtest_lpip_module_exit(struct stellar_module_manager *mod_mgr, struct stellar_module *mod)
|
||||
void gtest_lpip_module_exit(struct module_manager *mod_mgr, struct module *mod)
|
||||
{
|
||||
assert(mod_mgr!=NULL);
|
||||
struct test_lpip_env *env = (struct test_lpip_env *)stellar_module_get_ctx(mod);
|
||||
struct test_lpip_env *env = (struct test_lpip_env *)module_get_ctx(mod);
|
||||
free(env);
|
||||
printf("gtest_lpip_module_exit OK!\n");
|
||||
stellar_module_free(mod);
|
||||
module_free(mod);
|
||||
return ;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "session_internal.h"
|
||||
|
||||
#include "stellar/log.h"
|
||||
#include "stellar/module_manager.h"
|
||||
#include "stellar/module.h"
|
||||
#include "stellar/session.h"
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
@@ -431,13 +431,13 @@ error_out:
|
||||
* Plugin API
|
||||
******************************************************************************/
|
||||
|
||||
struct stellar_module *session_debugger_on_init(struct stellar_module_manager *mod_mgr)
|
||||
struct module *session_debugger_on_init(struct module_manager *mod_mgr)
|
||||
{
|
||||
assert(mod_mgr);
|
||||
|
||||
struct session_manager *sess_mgr = stellar_module_get_session_manager(mod_mgr);
|
||||
struct module *sess_mgr_mod=module_manager_get_module(mod_mgr, SESSION_MANAGER_MODULE_NAME);
|
||||
struct session_manager *sess_mgr = module_to_session_manager(sess_mgr_mod);
|
||||
assert(sess_mgr);
|
||||
struct logger *logger = stellar_module_manager_get_logger(mod_mgr);
|
||||
struct logger *logger = module_manager_get_logger(mod_mgr);
|
||||
assert(logger);
|
||||
|
||||
struct session_debugger *dbg = session_debugger_new(sess_mgr, logger);
|
||||
@@ -446,29 +446,29 @@ struct stellar_module *session_debugger_on_init(struct stellar_module_manager *m
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct stellar_module *dbg_mod = stellar_module_new("session_debugger", NULL);
|
||||
struct module *dbg_mod = module_new("session_debugger", NULL);
|
||||
if (dbg_mod == NULL)
|
||||
{
|
||||
session_debugger_free(dbg);
|
||||
return NULL;
|
||||
}
|
||||
stellar_module_set_ctx(dbg_mod, dbg);
|
||||
module_set_ctx(dbg_mod, dbg);
|
||||
|
||||
STELLAR_LOG_FATAL(dbg->logger, "session debugger", "session_debugger init")
|
||||
|
||||
return dbg_mod;
|
||||
}
|
||||
|
||||
void session_debugger_on_exit(struct stellar_module_manager *mod_mgr, struct stellar_module *mod)
|
||||
void session_debugger_on_exit(struct module_manager *mod_mgr, struct module *mod)
|
||||
{
|
||||
if (mod)
|
||||
{
|
||||
struct session_debugger *dbg = stellar_module_get_ctx(mod);
|
||||
struct session_debugger *dbg = module_get_ctx(mod);
|
||||
if (dbg)
|
||||
{
|
||||
STELLAR_LOG_FATAL(dbg->logger, "session debugger", "session_debugger exit")
|
||||
session_debugger_free(dbg);
|
||||
}
|
||||
stellar_module_free(mod);
|
||||
module_free(mod);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user