mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
res_pjsip: Add CLI "pjsip dump endpt [details]"
Dump the res_pjsip endpt internals. In non-developer mode we will not document or make easily accessible the "details" option even though it is still available. The user has to know it exists to use it. Presumably they would also be aware of the potential crash warning below. Warning: PJPROJECT documents that the function used by this CLI command may cause a crash when asking for details because it tries to access all active memory pools. Change-Id: If2d98a3641c9873364d1daaad971376311aef3cb
This commit is contained in:
@@ -57,6 +57,19 @@ static unsigned decor_orig;
|
||||
|
||||
static AST_VECTOR(buildopts, char *) buildopts;
|
||||
|
||||
/*! Protection from other log intercept instances. There can be only one at a time. */
|
||||
AST_MUTEX_DEFINE_STATIC(pjproject_log_intercept_lock);
|
||||
|
||||
struct pjproject_log_intercept_data {
|
||||
pthread_t thread;
|
||||
int fd;
|
||||
};
|
||||
|
||||
static struct pjproject_log_intercept_data pjproject_log_intercept = {
|
||||
.thread = AST_PTHREADT_NULL,
|
||||
.fd = -1,
|
||||
};
|
||||
|
||||
static void log_forwarder(int level, const char *data, int len)
|
||||
{
|
||||
int ast_level;
|
||||
@@ -66,6 +79,16 @@ static void log_forwarder(int level, const char *data, int len)
|
||||
const char *log_func = "<?>";
|
||||
int mod_level;
|
||||
|
||||
if (pjproject_log_intercept.fd != -1
|
||||
&& pjproject_log_intercept.thread == pthread_self()) {
|
||||
/*
|
||||
* We are handling a CLI command intercepting PJPROJECT
|
||||
* log output.
|
||||
*/
|
||||
ast_cli(pjproject_log_intercept.fd, "%s\n", data);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Lower number indicates higher importance */
|
||||
switch (level) {
|
||||
case 0: /* level zero indicates fatal error, according to docs */
|
||||
@@ -124,6 +147,23 @@ int ast_pjproject_get_buildopt(char *option, char *format_string, ...)
|
||||
return res;
|
||||
}
|
||||
|
||||
void ast_pjproject_log_intercept_begin(int fd)
|
||||
{
|
||||
/* Protect from other CLI instances trying to do this at the same time. */
|
||||
ast_mutex_lock(&pjproject_log_intercept_lock);
|
||||
|
||||
pjproject_log_intercept.thread = pthread_self();
|
||||
pjproject_log_intercept.fd = fd;
|
||||
}
|
||||
|
||||
void ast_pjproject_log_intercept_end(void)
|
||||
{
|
||||
pjproject_log_intercept.fd = -1;
|
||||
pjproject_log_intercept.thread = AST_PTHREADT_NULL;
|
||||
|
||||
ast_mutex_unlock(&pjproject_log_intercept_lock);
|
||||
}
|
||||
|
||||
void ast_pjproject_ref(void)
|
||||
{
|
||||
ast_module_ref(ast_module_info->self);
|
||||
|
Reference in New Issue
Block a user