]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Clean up resources in features on exit
authorMatthew Jordan <mjordan@digium.com>
Fri, 26 Apr 2013 21:11:33 +0000 (21:11 +0000)
committerMatthew Jordan <mjordan@digium.com>
Fri, 26 Apr 2013 21:11:33 +0000 (21:11 +0000)
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)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@386641 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/features.c

index 203d95486f2afa2819b10ce46a2d4321767473a9..a445ee5f555186dc3408ae33a000d36cf92608a8 100644 (file)
@@ -8269,6 +8269,7 @@ exit_features_test:
 /*! \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_manager_unregister("Bridge");
        ast_manager_unregister("Park");
@@ -8279,6 +8280,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);
 }