diff options
author | Mark Michelson <mmichelson@digium.com> | 2014-03-27 14:21:15 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2014-03-27 14:21:15 +0000 |
commit | a8629e53c19774b679a102dc2ee5c11a63583315 (patch) | |
tree | c656ac0bda6610f13f64a176b58b927a19a1764a | |
parent | 7dddd694cb0a9c6024cda5099cb8f410eb07ba97 (diff) |
Give sorcery instances a reference to their wizards.
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
........
Merged revisions 411295 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@411296 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | main/sorcery.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/main/sorcery.c b/main/sorcery.c index 2ab4933be..4291530d1 100644 --- a/main/sorcery.c +++ b/main/sorcery.c @@ -680,6 +680,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 */ @@ -707,7 +709,7 @@ static int sorcery_apply_wizard_mapping(struct ast_sorcery *sorcery, const char 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); |