[Asterisk-code-review] res_pjsip_logger.c: Don't blindly disable logging on res_pjsip reload. (asterisk[16])
Sean Bright
asteriskteam at digium.com
Thu Feb 10 13:20:24 CST 2022
Sean Bright has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18010 )
Change subject: res_pjsip_logger.c: Don't blindly disable logging on res_pjsip reload.
......................................................................
res_pjsip_logger.c: Don't blindly disable logging on res_pjsip reload.
When res_pjsip is reloaded, the logger module will look at the 'debug'
option under a type=global PJSIP section and react
appropriately. Unfortunately, because 'debug' defaults to 'no',
issuing a reload will disable all logging even if you haven't
explicitly asked for it to be disabled.
Now we check that the value of the 'debug' option has changed between
reload invocations and only react when it has.
ASTERISK-29912 #close
Change-Id: I3c9e6f39da65a625d8295178b526ed2cce4be115
---
M res/res_pjsip_logger.c
1 file changed, 15 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/10/18010/1
diff --git a/res/res_pjsip_logger.c b/res/res_pjsip_logger.c
index 957020f..6286fb0 100644
--- a/res/res_pjsip_logger.c
+++ b/res/res_pjsip_logger.c
@@ -120,6 +120,9 @@
/*! \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 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 @@
ao2_cleanup(default_logger);
default_logger = NULL;
+ ast_free(global_debug_state);
+
return 0;
}
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18010
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I3c9e6f39da65a625d8295178b526ed2cce4be115
Gerrit-Change-Number: 18010
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean at seanbright.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220210/374fe947/attachment.html>
More information about the asterisk-code-review
mailing list