summaryrefslogtreecommitdiff
path: root/include/asterisk
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2017-12-29 15:50:12 -0500
committerCorey Farrell <git@cfware.com>2017-12-29 16:16:11 -0500
commit0fe7df641aa0e23b8400d32b935de4834ee4f182 (patch)
tree74e162d10c8b00645d2da5b9b62b1f629c7eeee9 /include/asterisk
parent80e6b2eff54a4ff57e2521164224b1b1c878ae94 (diff)
datastore: Add automatic module references.
Add a reference to the calling module when it is active to protect access to datastore->info. Remove module references done by func_periodic_hook as the datastore now handles it. ASTERISK-25128 #close Change-Id: I8357a3711e77591d0d1dd8ab4211a7eedd782c89
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/datastore.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/include/asterisk/datastore.h b/include/asterisk/datastore.h
index 85e9c6890..8d6516bc1 100644
--- a/include/asterisk/datastore.h
+++ b/include/asterisk/datastore.h
@@ -69,6 +69,7 @@ struct ast_datastore {
const char *uid; /*!< Unique data store identifier */
void *data; /*!< Contained data */
const struct ast_datastore_info *info; /*!< Data store type information */
+ struct ast_module *mod; /*!< Module referenced by this datastore */
unsigned int inheritance; /*!< Number of levels this item will continue to be inherited */
AST_LIST_ENTRY(ast_datastore) entry; /*!< Used for easy linking */
};
@@ -77,13 +78,16 @@ struct ast_datastore {
* \brief Create a data store object
* \param[in] info information describing the data store object
* \param[in] uid unique identifer
+ * \param[in] mod The module to hold until this datastore is freed.
* \param file, line, function
* \version 1.6.1 moved here and renamed from ast_channel_datastore_alloc
*/
-struct ast_datastore * attribute_malloc __ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid,
- const char *file, int line, const char *function);
+struct ast_datastore * attribute_malloc __ast_datastore_alloc(
+ const struct ast_datastore_info *info, const char *uid, struct ast_module *mod,
+ const char *file, int line, const char *function);
-#define ast_datastore_alloc(info, uid) __ast_datastore_alloc(info, uid, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ast_datastore_alloc(info, uid) \
+ __ast_datastore_alloc(info, uid, AST_MODULE_SELF, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*!
* \brief Free a data store object