]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Give sorcery instances a reference to their wizards.
authorMark Michelson <mmichelson@digium.com>
Thu, 27 Mar 2014 14:20:10 +0000 (14:20 +0000)
committerMark Michelson <mmichelson@digium.com>
Thu, 27 Mar 2014 14:20:10 +0000 (14:20 +0000)
On graceful shutdown, sorcery wizards are all killed off, but it is
possible for sorcery instances to still have dangling pointers after
this, possibly causing a crash. Giving the sorcery instances a reference
to their wizards ensures that the wizard reference will remain valid for
the lifetime of the sorcery instance.

Review: https://reviewboard.asterisk.org/r/3401

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

main/sorcery.c

index 01ef6ffdbb6096b6565c013f68cd555dbe9dd8e5..9488dee4b2693dfb198c60c528321b11225af25f 100644 (file)
@@ -688,6 +688,8 @@ static void sorcery_object_wizard_destructor(void *obj)
        if (object_wizard->wizard) {
                ast_module_unref(object_wizard->wizard->module);
        }
+
+       ao2_cleanup(object_wizard->wizard);
 }
 
 /*! \brief Internal function which creates an object type and adds a wizard mapping */
@@ -728,7 +730,7 @@ static enum ast_sorcery_apply_result sorcery_apply_wizard_mapping(struct ast_sor
 
        ast_module_ref(wizard->module);
 
-       object_wizard->wizard = wizard;
+       object_wizard->wizard = ao2_bump(wizard);
        object_wizard->caching = caching;
 
        ao2_link(object_type->wizards, object_wizard);