diff --git a/decoders/http/http_decoder.c b/decoders/http/http_decoder.c index 9d22c76..b65599f 100644 --- a/decoders/http/http_decoder.c +++ b/decoders/http/http_decoder.c @@ -878,7 +878,7 @@ static void http_decoder_on_session_free(struct session *sess,void *per_session_ goto failed; } 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); if (httpd_env->plugin_id < 0) { diff --git a/include/stellar/stellar.h b/include/stellar/stellar.h index 2cce7db..6d9532b 100644 --- a/include/stellar/stellar.h +++ b/include/stellar/stellar.h @@ -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_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 session_on_free_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 on_session_free_func(struct session *sess, void *session_ctx, void *plugin_env); // INTRINSIC TOPIC // 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, 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_free_func session_ctx_free, - session_on_new_func session_on_new, - session_on_free_func session_on_free, + on_session_new_func on_session_new, + on_session_free_func on_session_free, void *plugin_env); void stellar_session_plugin_dettach_current_session(struct session *sess); diff --git a/infra/plugin_manager/plugin_manager.c b/infra/plugin_manager/plugin_manager.c index 775dd8f..78aca4f 100644 --- a/infra/plugin_manager/plugin_manager.c +++ b/infra/plugin_manager/plugin_manager.c @@ -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}; -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_free_func session_ctx_free, - session_on_new_func session_on_new, - session_on_free_func session_on_free, + on_session_new_func session_on_new, + on_session_free_func session_on_free, void *plugin_env) { 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, 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) @@ -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; 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; 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); - if (s->on_session_free) + session_plugin_schema = (struct registered_session_plugin_schema *)utarray_eltptr(plug_mgr_rt->plug_mgr->registered_session_plugin_array, i); + plugin_ctx_rt = (plug_mgr_rt->plugin_ctx_array + i); + if (session_plugin_schema->on_session_free && plugin_ctx_rt->state != EXIT)//dettached session plugin do not call on_session_free { - plugin_ctx_rt = (plug_mgr_rt->plugin_ctx_array + i); - plugin_manager_runtime_update_plugin_ctx(sess, s, plugin_ctx_rt); - 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); } } diff --git a/infra/plugin_manager/plugin_manager_interna.h b/infra/plugin_manager/plugin_manager_interna.h index 91233cf..350be6a 100644 --- a/infra/plugin_manager/plugin_manager_interna.h +++ b/infra/plugin_manager/plugin_manager_interna.h @@ -172,8 +172,8 @@ struct registered_session_plugin_schema { session_ctx_new_func *on_ctx_new; session_ctx_free_func *on_ctx_free; - session_on_new_func *on_session_new; - session_on_free_func *on_session_free; + on_session_new_func *on_session_new; + on_session_free_func *on_session_free; void *plugin_env; UT_array *registed_session_mq_subscriber_info; }__attribute__((aligned(sizeof(void*)))); diff --git a/infra/plugin_manager/test/plugin_manager_gtest_main.cpp b/infra/plugin_manager/test/plugin_manager_gtest_main.cpp index 00f89c8..f2a10ad 100644 --- a/infra/plugin_manager/test/plugin_manager_gtest_main.cpp +++ b/infra/plugin_manager/test/plugin_manager_gtest_main.cpp @@ -1700,7 +1700,7 @@ TEST(plugin_manager, session_plugin_pub_msg_on_closing) { // 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); env.intrinsc_tcp_topic_id=stellar_mq_get_topic_id(&st, TOPIC_TCP_INPUT); diff --git a/infra/version.map b/infra/version.map index 3723eb8..5e87ff7 100644 --- a/infra/version.map +++ b/infra/version.map @@ -51,7 +51,7 @@ global: session_set_discard; stellar_session_plugin_register; - stellar_session_plugin_register_with_hook; + stellar_session_plugin_register_with_hooks; stellar_session_plugin_dettach_current_session; stellar_packet_plugin_register; stellar_polling_plugin_register; diff --git a/test/lpi_plugin/gtest_lpi_plugin.cpp b/test/lpi_plugin/gtest_lpi_plugin.cpp index 41478f8..6bbd7f2 100644 --- a/test/lpi_plugin/gtest_lpi_plugin.cpp +++ b/test/lpi_plugin/gtest_lpi_plugin.cpp @@ -142,7 +142,7 @@ extern "C" void *gtest_lpi_plugin_load(struct stellar *st) perror("gtest_lpi_plugin_load:l7_protocol_mapper failed !!!\n"); 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) { perror("gtest_lpi_plugin_load:stellar_plugin_register failed !!!\n");