🦄 refactor(rename plug mgr api): session plug register with hooks
This commit is contained in:
@@ -878,7 +878,7 @@ static void http_decoder_on_session_free(struct session *sess,void *per_session_
|
|||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
httpd_env->st = st;
|
httpd_env->st = st;
|
||||||
httpd_env->plugin_id = stellar_session_plugin_register_with_hook(st, httpd_session_ctx_new_cb,
|
httpd_env->plugin_id = stellar_session_plugin_register_with_hooks(st, httpd_session_ctx_new_cb,
|
||||||
httpd_session_ctx_free_cb, NULL,http_decoder_on_session_free,(void *)httpd_env);
|
httpd_session_ctx_free_cb, NULL,http_decoder_on_session_free,(void *)httpd_env);
|
||||||
if (httpd_env->plugin_id < 0)
|
if (httpd_env->plugin_id < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ typedef void plugin_on_unload_func(void *plugin_env);
|
|||||||
typedef void *session_ctx_new_func(struct session *sess, void *plugin_env);
|
typedef void *session_ctx_new_func(struct session *sess, void *plugin_env);
|
||||||
typedef void session_ctx_free_func(struct session *sess, void *session_ctx, void *plugin_env);
|
typedef void session_ctx_free_func(struct session *sess, void *session_ctx, void *plugin_env);
|
||||||
|
|
||||||
typedef void session_on_new_func(struct session *sess, void *session_ctx, void *plugin_env);
|
typedef void on_session_new_func(struct session *sess, void *session_ctx, void *plugin_env);
|
||||||
typedef void session_on_free_func(struct session *sess, void *session_ctx, void *plugin_env);
|
typedef void on_session_free_func(struct session *sess, void *session_ctx, void *plugin_env);
|
||||||
|
|
||||||
// INTRINSIC TOPIC
|
// INTRINSIC TOPIC
|
||||||
// TOPIC_TCP_STREAM on_msg need convert msg to (const struct tcp_segment *)
|
// TOPIC_TCP_STREAM on_msg need convert msg to (const struct tcp_segment *)
|
||||||
@@ -40,11 +40,11 @@ int stellar_session_plugin_register(struct stellar *st,
|
|||||||
session_ctx_free_func session_ctx_free,
|
session_ctx_free_func session_ctx_free,
|
||||||
void *plugin_env);
|
void *plugin_env);
|
||||||
|
|
||||||
int stellar_session_plugin_register_with_hook(struct stellar *st,
|
int stellar_session_plugin_register_with_hooks(struct stellar *st,
|
||||||
session_ctx_new_func session_ctx_new,
|
session_ctx_new_func session_ctx_new,
|
||||||
session_ctx_free_func session_ctx_free,
|
session_ctx_free_func session_ctx_free,
|
||||||
session_on_new_func session_on_new,
|
on_session_new_func on_session_new,
|
||||||
session_on_free_func session_on_free,
|
on_session_free_func on_session_free,
|
||||||
void *plugin_env);
|
void *plugin_env);
|
||||||
|
|
||||||
void stellar_session_plugin_dettach_current_session(struct session *sess);
|
void stellar_session_plugin_dettach_current_session(struct session *sess);
|
||||||
|
|||||||
@@ -984,11 +984,11 @@ int plugin_manager_on_polling(struct plugin_manager_schema *plug_mgr)
|
|||||||
*********************************************/
|
*********************************************/
|
||||||
UT_icd registered_session_plugin_schema_icd = {sizeof(struct registered_session_plugin_schema), NULL, NULL, NULL};
|
UT_icd registered_session_plugin_schema_icd = {sizeof(struct registered_session_plugin_schema), NULL, NULL, NULL};
|
||||||
|
|
||||||
int stellar_session_plugin_register_with_hook(struct stellar *st,
|
int stellar_session_plugin_register_with_hooks(struct stellar *st,
|
||||||
session_ctx_new_func session_ctx_new,
|
session_ctx_new_func session_ctx_new,
|
||||||
session_ctx_free_func session_ctx_free,
|
session_ctx_free_func session_ctx_free,
|
||||||
session_on_new_func session_on_new,
|
on_session_new_func session_on_new,
|
||||||
session_on_free_func session_on_free,
|
on_session_free_func session_on_free,
|
||||||
void *plugin_env)
|
void *plugin_env)
|
||||||
{
|
{
|
||||||
struct plugin_manager_schema *plug_mgr = stellar_get_plugin_manager(st);
|
struct plugin_manager_schema *plug_mgr = stellar_get_plugin_manager(st);
|
||||||
@@ -1012,7 +1012,7 @@ int stellar_session_plugin_register(struct stellar *st,
|
|||||||
session_ctx_free_func session_ctx_free,
|
session_ctx_free_func session_ctx_free,
|
||||||
void *plugin_env)
|
void *plugin_env)
|
||||||
{
|
{
|
||||||
return stellar_session_plugin_register_with_hook(st, session_ctx_new, session_ctx_free, NULL, NULL, plugin_env);
|
return stellar_session_plugin_register_with_hooks(st, session_ctx_new, session_ctx_free, NULL, NULL, plugin_env);
|
||||||
}
|
}
|
||||||
|
|
||||||
void plugin_manager_on_session_input(struct session *sess, struct packet *pkt)
|
void plugin_manager_on_session_input(struct session *sess, struct packet *pkt)
|
||||||
@@ -1117,16 +1117,16 @@ void plugin_manager_on_session_free(struct session *sess)
|
|||||||
if(plug_mgr_rt->plug_mgr->registered_session_plugin_array==NULL)return;
|
if(plug_mgr_rt->plug_mgr->registered_session_plugin_array==NULL)return;
|
||||||
plug_mgr_rt->pub_session_msg_cnt=0;// reset pub_msg_cnt
|
plug_mgr_rt->pub_session_msg_cnt=0;// reset pub_msg_cnt
|
||||||
|
|
||||||
struct registered_session_plugin_schema *s = NULL;
|
struct registered_session_plugin_schema *session_plugin_schema = NULL;
|
||||||
struct session_plugin_ctx_runtime *plugin_ctx_rt;
|
struct session_plugin_ctx_runtime *plugin_ctx_rt;
|
||||||
for(unsigned int i = 0; i < utarray_len(plug_mgr_rt->plug_mgr->registered_session_plugin_array); i++)
|
for(unsigned int i = 0; i < utarray_len(plug_mgr_rt->plug_mgr->registered_session_plugin_array); i++)
|
||||||
{
|
{
|
||||||
s = (struct registered_session_plugin_schema *)utarray_eltptr(plug_mgr_rt->plug_mgr->registered_session_plugin_array, i);
|
session_plugin_schema = (struct registered_session_plugin_schema *)utarray_eltptr(plug_mgr_rt->plug_mgr->registered_session_plugin_array, i);
|
||||||
if (s->on_session_free)
|
|
||||||
{
|
|
||||||
plugin_ctx_rt = (plug_mgr_rt->plugin_ctx_array + i);
|
plugin_ctx_rt = (plug_mgr_rt->plugin_ctx_array + i);
|
||||||
plugin_manager_runtime_update_plugin_ctx(sess, s, plugin_ctx_rt);
|
if (session_plugin_schema->on_session_free && plugin_ctx_rt->state != EXIT)//dettached session plugin do not call on_session_free
|
||||||
s->on_session_free(sess, plugin_ctx_rt->plugin_ctx, s->plugin_env);
|
{
|
||||||
|
plugin_manager_runtime_update_plugin_ctx(sess, session_plugin_schema, plugin_ctx_rt);
|
||||||
|
session_plugin_schema->on_session_free(sess, plugin_ctx_rt->plugin_ctx, session_plugin_schema->plugin_env);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,8 +172,8 @@ struct registered_session_plugin_schema
|
|||||||
{
|
{
|
||||||
session_ctx_new_func *on_ctx_new;
|
session_ctx_new_func *on_ctx_new;
|
||||||
session_ctx_free_func *on_ctx_free;
|
session_ctx_free_func *on_ctx_free;
|
||||||
session_on_new_func *on_session_new;
|
on_session_new_func *on_session_new;
|
||||||
session_on_free_func *on_session_free;
|
on_session_free_func *on_session_free;
|
||||||
void *plugin_env;
|
void *plugin_env;
|
||||||
UT_array *registed_session_mq_subscriber_info;
|
UT_array *registed_session_mq_subscriber_info;
|
||||||
}__attribute__((aligned(sizeof(void*))));
|
}__attribute__((aligned(sizeof(void*))));
|
||||||
|
|||||||
@@ -1700,7 +1700,7 @@ TEST(plugin_manager, session_plugin_pub_msg_on_closing) {
|
|||||||
|
|
||||||
// plugin manager register plugin
|
// plugin manager register plugin
|
||||||
|
|
||||||
int plugin_id=stellar_session_plugin_register_with_hook(&st, test_session_closing_ctx_new, test_session_closing_ctx_free, NULL, test_session_closing_on_session_free , &env);
|
int plugin_id=stellar_session_plugin_register_with_hooks(&st, test_session_closing_ctx_new, test_session_closing_ctx_free, NULL, test_session_closing_on_session_free , &env);
|
||||||
EXPECT_GE(plugin_id,0);
|
EXPECT_GE(plugin_id,0);
|
||||||
|
|
||||||
env.intrinsc_tcp_topic_id=stellar_mq_get_topic_id(&st, TOPIC_TCP_INPUT);
|
env.intrinsc_tcp_topic_id=stellar_mq_get_topic_id(&st, TOPIC_TCP_INPUT);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ global:
|
|||||||
session_set_discard;
|
session_set_discard;
|
||||||
|
|
||||||
stellar_session_plugin_register;
|
stellar_session_plugin_register;
|
||||||
stellar_session_plugin_register_with_hook;
|
stellar_session_plugin_register_with_hooks;
|
||||||
stellar_session_plugin_dettach_current_session;
|
stellar_session_plugin_dettach_current_session;
|
||||||
stellar_packet_plugin_register;
|
stellar_packet_plugin_register;
|
||||||
stellar_polling_plugin_register;
|
stellar_polling_plugin_register;
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ extern "C" void *gtest_lpi_plugin_load(struct stellar *st)
|
|||||||
perror("gtest_lpi_plugin_load:l7_protocol_mapper failed !!!\n");
|
perror("gtest_lpi_plugin_load:l7_protocol_mapper failed !!!\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
env->test_app_plugin_id=stellar_session_plugin_register_with_hook(st, NULL, NULL, NULL, gtest_lpi_on_session_free, env);
|
env->test_app_plugin_id=stellar_session_plugin_register_with_hooks(st, NULL, NULL, NULL, gtest_lpi_on_session_free, env);
|
||||||
if(env->test_app_plugin_id < 0)
|
if(env->test_app_plugin_id < 0)
|
||||||
{
|
{
|
||||||
perror("gtest_lpi_plugin_load:stellar_plugin_register failed !!!\n");
|
perror("gtest_lpi_plugin_load:stellar_plugin_register failed !!!\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user