summaryrefslogtreecommitdiff
path: root/res/res_parking.c
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2013-08-17 15:01:54 +0000
committerKinsey Moore <kmoore@digium.com>2013-08-17 15:01:54 +0000
commit56aea1c030a6ee322446b5c687da164246b0c0d5 (patch)
tree5c7729fcff1c8660d559f68a78f07d0fde579516 /res/res_parking.c
parentd7f1f3127084e4b7b204141c0b40c28c327f74b0 (diff)
Allow res_parking to be unloadable
This change protects accesses of res_parking such that it can unload safely once transient uses of its registered functions are complete. The parking API has been restructured such that its consumers do not have access to the vtable exposed by the parking provider, but instead route through stubs to prevent consumers from holding on to function pointers. This adds calls to all the parking unload functions and moves application loading and unloading into functions in parking_applications.c similar to the rest of the parts of res_parking. Review: https://reviewboard.asterisk.org/r/2763/ (closes issue ASTERISK-22142) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396890 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_parking.c')
-rw-r--r--res/res_parking.c60
1 files changed, 26 insertions, 34 deletions
diff --git a/res/res_parking.c b/res/res_parking.c
index 3cd10a1dd..33cc56071 100644
--- a/res/res_parking.c
+++ b/res/res_parking.c
@@ -33,6 +33,9 @@
<configFile name="res_parking.conf">
<configObject name="globals">
<synopsis>Options that apply to every parking lot</synopsis>
+ <configOption name="parkeddynamic">
+ <synopsis>Enables dynamically created parkinglots.</synopsis>
+ </configOption>
</configObject>
<configObject name="parking_lot">
<synopsis>Defined parking lots for res_parking to use to park calls on</synopsis>
@@ -192,9 +195,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/manager.h"
#include "asterisk/pbx.h"
-#define PARKED_CALL_APPLICATION "ParkedCall"
-#define PARK_AND_ANNOUNCE_APPLICATION "ParkAndAnnounce"
-
static int parking_lot_sort_fn(const void *obj_left, const void *obj_right, int flags)
{
const struct parking_lot *left = obj_left;
@@ -1152,6 +1152,27 @@ static void link_configured_disable_marked_lots(void)
disable_marked_lots();
}
+const struct ast_module_info *parking_get_module_info(void)
+{
+ return ast_module_info;
+}
+
+static int unload_module(void)
+{
+ unload_parking_bridge_features();
+ remove_all_configured_parking_lot_extensions();
+ unload_parking_applications();
+ unload_parking_manager();
+ unload_parking_ui();
+ unload_parking_devstate();
+ unload_parking_tests();
+ ao2_cleanup(parking_lot_container);
+ parking_lot_container = NULL;
+ aco_info_destroy(&cfg_info);
+
+ return 0;
+}
+
static int load_module(void)
{
parking_lot_container = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_MUTEX,
@@ -1194,15 +1215,7 @@ static int load_module(void)
goto error;
}
- if (ast_register_application_xml(PARK_APPLICATION, park_app_exec)) {
- goto error;
- }
-
- if (ast_register_application_xml(PARKED_CALL_APPLICATION, parked_call_app_exec)) {
- goto error;
- }
-
- if (ast_register_application_xml(PARK_AND_ANNOUNCE_APPLICATION, park_and_announce_app_exec)) {
+ if (load_parking_applications()) {
goto error;
}
@@ -1229,9 +1242,7 @@ static int load_module(void)
return AST_MODULE_LOAD_SUCCESS;
error:
- /* XXX errored loads don't currently do a good job of cleaning up after themselves */
- ao2_cleanup(parking_lot_container);
- aco_info_destroy(&cfg_info);
+ unload_module();
return AST_MODULE_LOAD_DECLINE;
}
@@ -1244,25 +1255,6 @@ static int reload_module(void)
return 0;
}
-static int unload_module(void)
-{
-
- /*ast_parking_unregister_bridge_features(parking_provider.module_name);*/
-
- /* XXX Parking is currently not unloadable due to the fact that it loads features which could cause
- * significant problems if they disappeared while a channel still had access to them.
- */
- return -1;
-
- /* TODO Things we will need to do here:
- *
- * destroy existing parking lots
- * uninstall parking related bridge features
- * remove extensions owned by the parking registrar
- * unload currently loaded unit tests, CLI/AMI commands, etc.
- */
-}
-
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Call Parking Resource",
.load = load_module,
.unload = unload_module,