From b3e3dfa51ca8e632d17cff81a59810eb5fdad6f2 Mon Sep 17 00:00:00 2001 From: Matthew Jordan <mjordan@digium.com> Date: Fri, 26 Apr 2013 21:27:24 +0000 Subject: [PATCH] Clean up resources in features on exit This patch cleans up two things features: * It properly unregisters the CLI commands that features registered * It cancels and performs a pthread_join on the created parking thread. This not only properly joins a non-detached thread, but also prevents disposing of the parking lots prior to the parking thread completely exiting. (closes issue ASTERISK-21407) Reported by: Corey Farrell patches: features_shutdown-r2.patch uploaded by Corey Farrell (License 5909) ........ Merged revisions 386641 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 386642 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@386676 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/features.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main/features.c b/main/features.c index 755007e249..8d2cffb208 100644 --- a/main/features.c +++ b/main/features.c @@ -9130,6 +9130,7 @@ static struct ast_custom_function featuremap_function = { /*! \internal \brief Clean up resources on Asterisk shutdown */ static void features_shutdown(void) { + ast_cli_unregister_multiple(cli_features, ARRAY_LEN(cli_features)); ast_devstate_prov_del("Park"); ast_custom_function_unregister(&featuremap_function); ast_custom_function_unregister(&feature_function); @@ -9142,6 +9143,9 @@ static void features_shutdown(void) ast_unregister_application(app_bridge); pthread_cancel(parking_thread); + pthread_kill(parking_thread, SIGURG); + pthread_join(parking_thread, NULL); + ast_context_destroy(NULL, registrar); ao2_ref(parkinglots, -1); } -- GitLab