summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2018-02-27 15:40:18 -0600
committerRichard Mudgett <rmudgett@digium.com>2018-02-28 11:41:30 -0600
commit1a36a452bd92eba702170ac2fe9bf2d83fbfaa98 (patch)
tree3ac4af64b514aa7b5ceaf27aa9267d79c183f066 /include
parent53ed437db3f37d941538ec1bf0ff96c422c7bef5 (diff)
pjproject: Add cache_pools debugging option.
The pool cache gets in the way of finding use after free errors of memory pool contents. Tools like valgrind and MALLOC_DEBUG don't know when a pool is released because it gets put into the cache instead of being freed. * Added the "cache_pools" option to pjproject.conf. Disabling the option helps track down pool content mismanagement when using valgrind or MALLOC_DEBUG. The cache gets in the way of determining if the pool contents are used after free and who freed it. To disable the pool caching simply disable the cache_pools option in pjproject.conf and restart Asterisk. Sample pjproject.conf setting: [startup] cache_pools=no * Made current users of the caching pool factory initialization and destruction calls call common routines to create and destroy cached pools. ASTERISK-27704 Change-Id: I64d5befbaeed2532f93aa027a51eb52347d2b828
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/options.h5
-rw-r--r--include/asterisk/res_pjproject.h26
2 files changed, 31 insertions, 0 deletions
diff --git a/include/asterisk/options.h b/include/asterisk/options.h
index 878748d16..78f596a88 100644
--- a/include/asterisk/options.h
+++ b/include/asterisk/options.h
@@ -173,6 +173,11 @@ enum ast_option_flags {
/*! Current linked pjproject maximum logging level */
extern int ast_pjproject_max_log_level;
+#define DEFAULT_PJPROJECT_CACHE_POOLS 1
+
+/*! Current pjproject pool caching enable */
+extern int ast_option_pjproject_cache_pools;
+
/*! Current pjproject logging level */
extern int ast_option_pjproject_log_level;
diff --git a/include/asterisk/res_pjproject.h b/include/asterisk/res_pjproject.h
index 4993be610..17ebdd201 100644
--- a/include/asterisk/res_pjproject.h
+++ b/include/asterisk/res_pjproject.h
@@ -19,6 +19,9 @@
#ifndef _RES_PJPROJECT_H
#define _RES_PJPROJECT_H
+#include <pj/types.h>
+#include <pj/pool.h>
+
/*!
* \brief Retrieve a pjproject build option
*
@@ -71,4 +74,27 @@ void ast_pjproject_log_intercept_begin(int fd);
*/
void ast_pjproject_log_intercept_end(void);
+/*!
+ * \brief Initialize the caching pool factory.
+ * \since 13.21.0
+ *
+ * \param cp Caching pool factory to initialize
+ * \param policy Pool factory policy
+ * \param max_capacity Total capacity to be retained in the cache. Zero disables caching.
+ *
+ * \return Nothing
+ */
+void ast_pjproject_caching_pool_init(pj_caching_pool *cp,
+ const pj_pool_factory_policy *policy, pj_size_t max_capacity);
+
+/*!
+ * \brief Destroy caching pool factory and all cached pools.
+ * \since 13.21.0
+ *
+ * \param cp Caching pool factory to destroy
+ *
+ * \return Nothing
+ */
+void ast_pjproject_caching_pool_destroy(pj_caching_pool *cp);
+
#endif /* _RES_PJPROJECT_H */