diff options
author | George Joseph <george.joseph@fairview5.com> | 2014-02-20 20:45:30 +0000 |
---|---|---|
committer | George Joseph <george.joseph@fairview5.com> | 2014-02-20 20:45:30 +0000 |
commit | a94c8562fd70bc5b317a434db36f19fd34c70f8c (patch) | |
tree | 33079e3ce84fd9b653bbaf2e448d28b2fed06a4d /include | |
parent | 8e1c5b62be1a4e33d4ec0167fdba9596f213baaa (diff) |
sorcery: Create sorcery instance registry.
In order to retrieve an arbitrary sorcery instance from a dialplan function
(or any place else) there needs to be a registry of sorcery instances.
ast_sorcery_init now creates a hashtab as a registry.
ast_sorcery_open now checks the hashtab for an existing sorcery instance
matching the caller's module name. If it finds one, it bumps the
refcount and returns it. If not, it creates a new sorcery instance,
adds it to the hashtab, then returns it.
ast_sorcery_retrieve_by_module_name is a new function that does a hashtab
lookup by module name. It can be called by the future dialplan function.
res_pjsip/config_system needed a small change to share the main res_pjsip
sorcery instance.
tests/test_sorcery was updated to include a test for the registry.
(closes issue ASTERISK-22537)
Review: http://reviewboard.asterisk.org/r/3184/
........
Merged revisions 408518 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@408519 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/sorcery.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/include/asterisk/sorcery.h b/include/asterisk/sorcery.h index 47ad5e40f..cf11528d1 100644 --- a/include/asterisk/sorcery.h +++ b/include/asterisk/sorcery.h @@ -302,10 +302,28 @@ int ast_sorcery_wizard_unregister(const struct ast_sorcery_wizard *interface); /*! * \brief Open a new sorcery structure * + * \param module The module name (AST_MODULE) + * * \retval non-NULL success * \retval NULL if allocation failed */ -struct ast_sorcery *ast_sorcery_open(void); +struct ast_sorcery *__ast_sorcery_open(const char *module); + +#define ast_sorcery_open() __ast_sorcery_open(AST_MODULE) + +/*! + * \brief Retrieves an existing sorcery instance by module name + * + * \param module The module name + * + * \retval non-NULL success + * \retval NULL if no instance was found + * + * \note The returned instance has its reference count incremented. The caller + * must decrement the count when they're finished with it. + * + */ +struct ast_sorcery *ast_sorcery_retrieve_by_module_name(const char *module); /*! * \brief Apply configured wizard mappings |