From 1a36a452bd92eba702170ac2fe9bf2d83fbfaa98 Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Tue, 27 Feb 2018 15:40:18 -0600 Subject: 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 --- include/asterisk/res_pjproject.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'include/asterisk/res_pjproject.h') 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 +#include + /*! * \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 */ -- cgit v1.2.3