[asterisk-commits] sorcery: Add ast sorcery object unregister() API call. (asterisk[13])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jun 26 11:26:06 CDT 2015
Matt Jordan has submitted this change and it was merged.
Change subject: sorcery: Add ast_sorcery_object_unregister() API call.
......................................................................
sorcery: Add ast_sorcery_object_unregister() API call.
Find and unlink the specified sorcery object type to complement
ast_sorcery_object_register(). Without this function you cannot
completely unload individual modules that use sorcery for configuration.
ASTERISK-24907
Reported by: Kevin Harwell
Change-Id: I1c04634fe9a90921bf676725c7d6bb2aeaab1c88
---
M include/asterisk/sorcery.h
M main/sorcery.c
2 files changed, 30 insertions(+), 0 deletions(-)
Approvals:
Matt Jordan: Looks good to me, approved; Verified
Joshua Colp: Looks good to me, but someone else must approve
diff --git a/include/asterisk/sorcery.h b/include/asterisk/sorcery.h
index 92d6f6c..30fb0dd 100644
--- a/include/asterisk/sorcery.h
+++ b/include/asterisk/sorcery.h
@@ -617,6 +617,17 @@
const char *type, int index, struct ast_sorcery_wizard **wizard, void **data);
/*!
+ * \brief Unregister an object type
+ *
+ * \param sorcery Pointer to a sorcery structure
+ * \param type Type of object
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int ast_sorcery_object_unregister(struct ast_sorcery *sorcery, const char *type);
+
+/*!
* \brief Register an object type
*
* \param sorcery Pointer to a sorcery structure
diff --git a/main/sorcery.c b/main/sorcery.c
index 8101af0..063e8c4 100644
--- a/main/sorcery.c
+++ b/main/sorcery.c
@@ -1106,6 +1106,25 @@
return 0;
}
+int ast_sorcery_object_unregister(struct ast_sorcery *sorcery, const char *type)
+{
+ struct ast_sorcery_object_type *object_type;
+ int res = -1;
+
+ ao2_wrlock(sorcery->types);
+ object_type = ao2_find(sorcery->types, type, OBJ_SEARCH_KEY | OBJ_NOLOCK);
+ if (object_type && object_type->type.type == ACO_ITEM) {
+ ao2_unlink_flags(sorcery->types, object_type, OBJ_NOLOCK);
+ res = 0;
+ }
+ ao2_unlock(sorcery->types);
+
+ /* XXX may need to add an instance unregister observer callback on success. */
+
+ ao2_cleanup(object_type);
+ return res;
+}
+
int __ast_sorcery_object_register(struct ast_sorcery *sorcery, const char *type, unsigned int hidden, unsigned int reloadable, aco_type_item_alloc alloc, sorcery_transform_handler transform, sorcery_apply_handler apply)
{
RAII_VAR(struct ast_sorcery_object_type *, object_type, ao2_find(sorcery->types, type, OBJ_KEY), ao2_cleanup);
--
To view, visit https://gerrit.asterisk.org/687
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1c04634fe9a90921bf676725c7d6bb2aeaab1c88
Gerrit-PatchSet: 3
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
More information about the asterisk-commits
mailing list