fix compile error
This commit is contained in:
@@ -536,45 +536,42 @@ static void on_sess_msg(struct session *sess, int topic_id, const void *msg, voi
|
||||
* Plugin API
|
||||
******************************************************************************/
|
||||
|
||||
extern "C"
|
||||
void *packet_inject_init(struct stellar *st)
|
||||
{
|
||||
void *packet_inject_init(struct stellar *st)
|
||||
struct inject_plugin_ctx *ctx = (struct inject_plugin_ctx *)calloc(1, sizeof(struct inject_plugin_ctx));
|
||||
if (ctx == NULL)
|
||||
{
|
||||
struct inject_plugin_ctx *ctx = (struct inject_plugin_ctx *)calloc(1, sizeof(struct inject_plugin_ctx));
|
||||
if (ctx == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx->st = st;
|
||||
ctx->logger = stellar_get_logger(st);
|
||||
INJTECT_PLUGIN_LOG_INFO(ctx->logger, "packet inject plugin init");
|
||||
|
||||
if (load_config(ctx->logger, &ctx->config, "./plugin/inject.toml") == -1)
|
||||
{
|
||||
INJTECT_PLUGIN_LOG_ERROR(ctx->logger, "load config failed");
|
||||
free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
print_config(ctx->logger, &ctx->config);
|
||||
|
||||
ctx->sess_plug_id = stellar_session_plugin_register(st, on_sess_new, on_sess_free, ctx);
|
||||
ctx->tcp_topic_id = stellar_mq_get_topic_id(st, TOPIC_TCP);
|
||||
ctx->udp_topic_id = stellar_mq_get_topic_id(st, TOPIC_UDP);
|
||||
|
||||
stellar_session_mq_subscribe(st, ctx->tcp_topic_id, on_sess_msg, ctx->sess_plug_id);
|
||||
stellar_session_mq_subscribe(st, ctx->udp_topic_id, on_sess_msg, ctx->sess_plug_id);
|
||||
|
||||
return ctx;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void packet_inject_exit(void *plugin_ctx)
|
||||
ctx->st = st;
|
||||
ctx->logger = stellar_get_logger(st);
|
||||
INJTECT_PLUGIN_LOG_INFO(ctx->logger, "packet inject plugin init");
|
||||
|
||||
if (load_config(ctx->logger, &ctx->config, "./plugin/inject.toml") == -1)
|
||||
{
|
||||
struct inject_plugin_ctx *ctx = (struct inject_plugin_ctx *)plugin_ctx;
|
||||
if (ctx)
|
||||
{
|
||||
INJTECT_PLUGIN_LOG_INFO(ctx->logger, "packet inject plugin exit");
|
||||
free(ctx);
|
||||
}
|
||||
INJTECT_PLUGIN_LOG_ERROR(ctx->logger, "load config failed");
|
||||
free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
print_config(ctx->logger, &ctx->config);
|
||||
|
||||
ctx->sess_plug_id = stellar_session_plugin_register(st, on_sess_new, on_sess_free, ctx);
|
||||
ctx->tcp_topic_id = stellar_mq_get_topic_id(st, TOPIC_TCP);
|
||||
ctx->udp_topic_id = stellar_mq_get_topic_id(st, TOPIC_UDP);
|
||||
|
||||
stellar_session_mq_subscribe(st, ctx->tcp_topic_id, on_sess_msg, ctx->sess_plug_id);
|
||||
stellar_session_mq_subscribe(st, ctx->udp_topic_id, on_sess_msg, ctx->sess_plug_id);
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void packet_inject_exit(void *plugin_ctx)
|
||||
{
|
||||
struct inject_plugin_ctx *ctx = (struct inject_plugin_ctx *)plugin_ctx;
|
||||
if (ctx)
|
||||
{
|
||||
INJTECT_PLUGIN_LOG_INFO(ctx->logger, "packet inject plugin exit");
|
||||
free(ctx);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user