summaryrefslogtreecommitdiff
path: root/res/parking/parking_applications.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/parking/parking_applications.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/parking/parking_applications.c')
-rw-r--r--res/parking/parking_applications.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/res/parking/parking_applications.c b/res/parking/parking_applications.c
index 4b854759d..29f38b4b8 100644
--- a/res/parking/parking_applications.c
+++ b/res/parking/parking_applications.c
@@ -194,6 +194,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
</application>
***/
+#define PARK_AND_ANNOUNCE_APPLICATION "ParkAndAnnounce"
+
/* Park a call */
enum park_args {
@@ -488,7 +490,7 @@ struct ast_bridge *park_application_setup(struct ast_channel *parkee, struct ast
}
-int park_app_exec(struct ast_channel *chan, const char *data)
+static int park_app_exec(struct ast_channel *chan, const char *data)
{
RAII_VAR(struct ast_bridge *, parking_bridge, NULL, ao2_cleanup);
@@ -547,7 +549,7 @@ int park_app_exec(struct ast_channel *chan, const char *data)
/* Retrieve a parked call */
-int parked_call_app_exec(struct ast_channel *chan, const char *data)
+static int parked_call_app_exec(struct ast_channel *chan, const char *data)
{
RAII_VAR(struct parking_lot *, lot, NULL, ao2_cleanup);
RAII_VAR(struct parked_user *, pu, NULL, ao2_cleanup); /* Parked user being retrieved */
@@ -765,7 +767,7 @@ static void park_announce_update_cb(void *data, struct stasis_subscription *sub,
*dial_string = '\0'; /* If we observe this dial string on a second pass, we don't want to do anything with it. */
}
-int park_and_announce_app_exec(struct ast_channel *chan, const char *data)
+static int park_and_announce_app_exec(struct ast_channel *chan, const char *data)
{
struct ast_bridge_features chan_features;
char *parse;
@@ -857,3 +859,29 @@ int park_and_announce_app_exec(struct ast_channel *chan, const char *data)
return res;
}
+
+int load_parking_applications(void)
+{
+ const struct ast_module_info *ast_module_info = parking_get_module_info();
+
+ if (ast_register_application_xml(PARK_APPLICATION, park_app_exec)) {
+ return -1;
+ }
+
+ if (ast_register_application_xml(PARKED_CALL_APPLICATION, parked_call_app_exec)) {
+ return -1;
+ }
+
+ if (ast_register_application_xml(PARK_AND_ANNOUNCE_APPLICATION, park_and_announce_app_exec)) {
+ return -1;
+ }
+
+ return 0;
+}
+
+void unload_parking_applications(void)
+{
+ ast_unregister_application(PARK_APPLICATION);
+ ast_unregister_application(PARKED_CALL_APPLICATION);
+ ast_unregister_application(PARK_AND_ANNOUNCE_APPLICATION);
+}