From e875e1c12a4b954b18e136b25c2a83b5f8e15f5d Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Fri, 26 Aug 2016 18:22:51 -0400 Subject: sorcery: Create function ast_sorcery_lockable_alloc. Create an alternative to ast_sorcery_generic_alloc which uses astobj2 shared locking. Use this new method for the 'struct ast_sip_aor' allocator. Change-Id: I3f62f2ada64b622571950278fbb6ad57395b5d6f --- include/asterisk/sorcery.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include/asterisk') diff --git a/include/asterisk/sorcery.h b/include/asterisk/sorcery.h index 23219ec41..896633816 100644 --- a/include/asterisk/sorcery.h +++ b/include/asterisk/sorcery.h @@ -988,9 +988,29 @@ int ast_sorcery_changeset_create(const struct ast_variable *original, const stru * * \retval non-NULL success * \retval NULL failure + * + * \note The returned object does not support AO2 locking. */ void *ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor); +/*! + * \since 14.1.0 + * \brief Allocate a generic sorcery capable object with locking. + * + * \details Sorcery objects may be replaced with new allocations during reloads. + * If locking is required on sorcery objects it must be shared between the old + * object and the new one. lockobj can be any AO2 object with locking enabled, + * but in most cases named locks should be used to provide stable locking. + * + * \param size Size of the object + * \param destructor Optional destructor function + * \param lockobj An AO2 object that will provide locking. + * + * \retval non-NULL success + * \retval NULL failure + */ +void *ast_sorcery_lockable_alloc(size_t size, ao2_destructor_fn destructor, void *lockobj); + /*! * \brief Allocate an object * -- cgit v1.2.3