mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-16 23:08:32 +00:00
Merge "pjproject: Add cache_pools debugging option." into 13
This commit is contained in:
11
CHANGES
11
CHANGES
@@ -8,6 +8,17 @@
|
||||
===
|
||||
==============================================================================
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
--- Functionality changes from Asterisk 13.20.0 to Asterisk 13.21.0 ----------
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
res_pjproject
|
||||
------------------
|
||||
* 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.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
--- Functionality changes from Asterisk 13.19.0 to Asterisk 13.20.0 ----------
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
@@ -5,6 +5,13 @@
|
||||
; NOTES: The name of this section in the pjproject.conf configuration file must
|
||||
; remain startup or the configuration will not be applied.
|
||||
;
|
||||
;cache_pools = yes ; Cache pjproject memory pools for performance
|
||||
; Disable this option to help 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 being freed and who
|
||||
; freed it.
|
||||
; Default yes
|
||||
;log_level=default ; Initial maximum pjproject logging level to log
|
||||
; Valid values are: 0-6, and default
|
||||
;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
#ifndef _RES_PJPROJECT_H
|
||||
#define _RES_PJPROJECT_H
|
||||
|
||||
#include <pj/types.h>
|
||||
#include <pj/pool.h>
|
||||
|
||||
/*! \brief Determines whether the res_pjproject module is loaded */
|
||||
#define CHECK_PJPROJECT_MODULE_LOADED() \
|
||||
do { \
|
||||
@@ -93,4 +96,27 @@ void ast_pjproject_ref(void);
|
||||
*/
|
||||
void ast_pjproject_unref(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 */
|
||||
|
||||
@@ -327,6 +327,7 @@ int option_verbose; /*!< Verbosity level */
|
||||
int option_debug; /*!< Debug level */
|
||||
int ast_pjproject_max_log_level = -1;/* Default to -1 to know if we have read the level from pjproject yet. */
|
||||
int ast_option_pjproject_log_level;
|
||||
int ast_option_pjproject_cache_pools;
|
||||
double ast_option_maxload; /*!< Max load avg on system */
|
||||
int ast_option_maxcalls; /*!< Max number of active calls */
|
||||
int ast_option_maxfiles; /*!< Max number of open file handles (files, sockets) */
|
||||
@@ -3877,6 +3878,7 @@ static void read_pjproject_startup_options(void)
|
||||
struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE | CONFIG_FLAG_NOREALTIME };
|
||||
|
||||
ast_option_pjproject_log_level = DEFAULT_PJ_LOG_MAX_LEVEL;
|
||||
ast_option_pjproject_cache_pools = DEFAULT_PJPROJECT_CACHE_POOLS;
|
||||
|
||||
cfg = ast_config_load2("pjproject.conf", "" /* core, can't reload */, config_flags);
|
||||
if (!cfg
|
||||
@@ -3895,6 +3897,8 @@ static void read_pjproject_startup_options(void)
|
||||
} else if (MAX_PJ_LOG_MAX_LEVEL < ast_option_pjproject_log_level) {
|
||||
ast_option_pjproject_log_level = MAX_PJ_LOG_MAX_LEVEL;
|
||||
}
|
||||
} else if (!strcasecmp(v->name, "cache_pools")) {
|
||||
ast_option_pjproject_cache_pools = !ast_false(v->value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -471,6 +471,18 @@ static struct ast_cli_entry pjproject_cli[] = {
|
||||
AST_CLI_DEFINE(handle_pjproject_show_log_level, "Show the maximum active pjproject logging level"),
|
||||
};
|
||||
|
||||
void ast_pjproject_caching_pool_init(pj_caching_pool *cp,
|
||||
const pj_pool_factory_policy *policy, pj_size_t max_capacity)
|
||||
{
|
||||
/* Passing a max_capacity of zero disables caching pools */
|
||||
pj_caching_pool_init(cp, policy, ast_option_pjproject_cache_pools ? max_capacity : 0);
|
||||
}
|
||||
|
||||
void ast_pjproject_caching_pool_destroy(pj_caching_pool *cp)
|
||||
{
|
||||
pj_caching_pool_destroy(cp);
|
||||
}
|
||||
|
||||
static int load_module(void)
|
||||
{
|
||||
ast_debug(3, "Starting PJPROJECT logging to Asterisk logger\n");
|
||||
|
||||
@@ -4753,7 +4753,7 @@ static int unload_pjsip(void *data)
|
||||
ast_pjsip_endpoint = NULL;
|
||||
|
||||
if (caching_pool.lock) {
|
||||
pj_caching_pool_destroy(&caching_pool);
|
||||
ast_pjproject_caching_pool_destroy(&caching_pool);
|
||||
}
|
||||
|
||||
pj_shutdown();
|
||||
@@ -4770,7 +4770,7 @@ static int load_pjsip(void)
|
||||
* example code from PJLIB. This can be adjusted
|
||||
* if necessary.
|
||||
*/
|
||||
pj_caching_pool_init(&caching_pool, NULL, 1024 * 1024);
|
||||
ast_pjproject_caching_pool_init(&caching_pool, NULL, 1024 * 1024);
|
||||
if (pjsip_endpt_create(&caching_pool.factory, "SIP", &ast_pjsip_endpoint) != PJ_SUCCESS) {
|
||||
ast_log(LOG_ERROR, "Failed to create PJSIP endpoint structure. Aborting load\n");
|
||||
goto error;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
*/
|
||||
|
||||
#include "asterisk.h"
|
||||
#include "pjsip.h"
|
||||
#include "pjlib.h"
|
||||
#include <pjsip.h>
|
||||
#include <pjlib.h>
|
||||
|
||||
#include "asterisk/res_pjsip.h"
|
||||
#include "asterisk/logger.h"
|
||||
|
||||
@@ -44,6 +44,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
#include "asterisk/netsock2.h"
|
||||
#include "asterisk/vector.h"
|
||||
#include "asterisk/lock.h"
|
||||
#include "asterisk/res_pjproject.h"
|
||||
|
||||
#define HISTORY_INITIAL_SIZE 256
|
||||
|
||||
@@ -1373,7 +1374,7 @@ static int load_module(void)
|
||||
ast_log(LOG_WARNING, "Unable to register history log level\n");
|
||||
}
|
||||
|
||||
pj_caching_pool_init(&cachingpool, &pj_pool_factory_default_policy, 0);
|
||||
ast_pjproject_caching_pool_init(&cachingpool, &pj_pool_factory_default_policy, 0);
|
||||
|
||||
AST_VECTOR_INIT(&vector_history, HISTORY_INITIAL_SIZE);
|
||||
|
||||
@@ -1391,7 +1392,7 @@ static int unload_module(void)
|
||||
ast_sip_push_task_synchronous(NULL, clear_history_entries, NULL);
|
||||
AST_VECTOR_FREE(&vector_history);
|
||||
|
||||
pj_caching_pool_destroy(&cachingpool);
|
||||
ast_pjproject_caching_pool_destroy(&cachingpool);
|
||||
|
||||
if (log_level != -1) {
|
||||
ast_logger_unregister_level("PJSIP_HISTORY");
|
||||
|
||||
@@ -72,6 +72,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
#include "asterisk/rtp_engine.h"
|
||||
#include "asterisk/smoother.h"
|
||||
#include "asterisk/test.h"
|
||||
#ifdef HAVE_PJPROJECT
|
||||
#include "asterisk/res_pjproject.h"
|
||||
#endif
|
||||
|
||||
#define MAX_TIMESTAMP_SKEW 640
|
||||
|
||||
@@ -6717,7 +6720,7 @@ static void rtp_terminate_pjproject(void)
|
||||
pj_thread_destroy(timer_thread);
|
||||
}
|
||||
|
||||
pj_caching_pool_destroy(&cachingpool);
|
||||
ast_pjproject_caching_pool_destroy(&cachingpool);
|
||||
pj_shutdown();
|
||||
}
|
||||
#endif
|
||||
@@ -6742,7 +6745,7 @@ static int load_module(void)
|
||||
return AST_MODULE_LOAD_DECLINE;
|
||||
}
|
||||
|
||||
pj_caching_pool_init(&cachingpool, &pj_pool_factory_default_policy, 0);
|
||||
ast_pjproject_caching_pool_init(&cachingpool, &pj_pool_factory_default_policy, 0);
|
||||
|
||||
pool = pj_pool_create(&cachingpool.factory, "timer", 512, 512, NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user