mirror of https://gerrit.osmocom.org/libosmocore
logging_gsmtap: Temporarily disable logging when sending the logs
This avoids an infinite recursion when sending a gsmtap log message causes a log message. Temporarily set target->loglevel higher than LOGL_FATAL, which effectively disables logging for that target. Other targets like stderr will still log this message so there is still an indication that something went wrong. Change-Id: I19203cadbad6019a3834793b8ac816d903fe088e Related: OS#6213
This commit is contained in:
parent
11a416827d
commit
f2629675aa
|
@ -65,6 +65,7 @@ static void _gsmtap_raw_output(struct log_target *target, int subsys,
|
|||
struct timeval tv;
|
||||
int rc;
|
||||
const char *file_basename;
|
||||
unsigned int _level;
|
||||
|
||||
/* get timestamp ASAP */
|
||||
osmo_gettimeofday(&tv, NULL);
|
||||
|
@ -114,7 +115,11 @@ static void _gsmtap_raw_output(struct log_target *target, int subsys,
|
|||
}
|
||||
msgb_put(msg, rc);
|
||||
|
||||
/* Ensure that any error occurring when sending the log message doesn't cause infinite recursion */
|
||||
_level = target->loglevel;
|
||||
target->loglevel = UINT8_MAX;
|
||||
rc = gsmtap_sendmsg(target->tgt_gsmtap.gsmtap_inst, msg);
|
||||
target->loglevel = _level;
|
||||
if (rc)
|
||||
msgb_free(msg);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue