From de515d259a359930568a856b177596fc9548d189 Mon Sep 17 00:00:00 2001 From: Sean Bright Date: Thu, 10 Feb 2022 12:06:41 -0500 Subject: [PATCH] res_pjsip_logger.c: Don't touch logger settings when res_pjsip reloads. ASTERISK-29912 #close Change-Id: I3c9e6f39da65a625d8295178b526ed2cce4be115 --- res/res_pjsip_logger.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/res/res_pjsip_logger.c b/res/res_pjsip_logger.c index 957020f8a0..6286fb0ea0 100644 --- a/res/res_pjsip_logger.c +++ b/res/res_pjsip_logger.c @@ -120,6 +120,9 @@ struct pjsip_logger_session { /*! \brief The default logger session */ static struct pjsip_logger_session *default_logger; +/*! \brief The cached value of the global 'debug' option */ +static char *global_debug_state; + /*! \brief Destructor for logger session */ static void pjsip_logger_session_destroy(void *obj) { @@ -513,7 +516,16 @@ static struct ast_cli_entry cli_pjsip[] = { static void check_debug(void) { - RAII_VAR(char *, debug, ast_sip_get_debug(), ast_free); + char *debug = ast_sip_get_debug(); + + if (global_debug_state && !strcmp(global_debug_state, debug)) { + /* The 'debug' setting hasn't changed, so bail early */ + ast_free(debug); + return; + } + + ast_free(global_debug_state); + global_debug_state = debug; if (ast_false(debug)) { pjsip_disable_logger(-1); @@ -574,6 +586,8 @@ static int unload_module(void) ao2_cleanup(default_logger); default_logger = NULL; + ast_free(global_debug_state); + return 0; } -- 2.32.0